diff --git a/internal/services/databricks/client/client.go b/internal/services/databricks/client/client.go index 080f71dd5d04..88036ed562c8 100644 --- a/internal/services/databricks/client/client.go +++ b/internal/services/databricks/client/client.go @@ -1,19 +1,24 @@ package client import ( - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - WorkspacesClient *workspaces.WorkspacesClient + AccessConnectorClient *accessconnector.AccessConnectorClient + WorkspacesClient *workspaces.WorkspacesClient } func NewClient(o *common.ClientOptions) *Client { + AccessConnectorClient := accessconnector.NewAccessConnectorClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&AccessConnectorClient.Client, o.ResourceManagerAuthorizer) WorkspacesClient := workspaces.NewWorkspacesClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&WorkspacesClient.Client, o.ResourceManagerAuthorizer) return &Client{ - WorkspacesClient: &WorkspacesClient, + AccessConnectorClient: &AccessConnectorClient, + WorkspacesClient: &WorkspacesClient, } } diff --git a/internal/services/databricks/databricks_access_connector_resource.go b/internal/services/databricks/databricks_access_connector_resource.go new file mode 100644 index 000000000000..904a8d657730 --- /dev/null +++ b/internal/services/databricks/databricks_access_connector_resource.go @@ -0,0 +1,150 @@ +package databricks + +import ( + "fmt" + "log" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/databricks/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" +) + +func resourceDatabricksAccessConnector() *pluginsdk.Resource { + return &pluginsdk.Resource{ + Create: resourceDatabricksAccessConnectorCreateUpdate, + Read: resourceDatabricksAccessConnectorRead, + Update: resourceDatabricksAccessConnectorCreateUpdate, + Delete: resourceDatabricksAccessConnectorDelete, + + Timeouts: &pluginsdk.ResourceTimeout{ + Create: pluginsdk.DefaultTimeout(5 * time.Minute), + Read: pluginsdk.DefaultTimeout(5 * time.Minute), + Update: pluginsdk.DefaultTimeout(5 * time.Minute), + Delete: pluginsdk.DefaultTimeout(5 * time.Minute), + }, + + Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { + _, err := accessconnector.ParseAccessConnectorID(id) + return err + }), + + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.AccessConnectorName, + }, + + "location": commonschema.Location(), + "resource_group_name": commonschema.ResourceGroupName(), + "identity": commonschema.SystemAssignedIdentityRequired(), + "tags": commonschema.Tags(), + }, + } +} + +func resourceDatabricksAccessConnectorCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).DataBricks.AccessConnectorClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id := accessconnector.NewAccessConnectorID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + if d.IsNewResource() { + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + } + + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_databricks_access_connector", id.ID()) + } + } + + location := azure.NormalizeLocation(d.Get("location").(string)) + + identity, err := identity.ExpandSystemAssigned(d.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + + accessConnector := accessconnector.AccessConnector{ + Location: location, + Identity: identity, + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, accessConnector); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) + } + + d.SetId(id.ID()) + + return resourceDatabricksAccessConnectorRead(d, meta) +} + +func resourceDatabricksAccessConnectorRead(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).DataBricks.AccessConnectorClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := accessconnector.ParseAccessConnectorID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + log.Printf("[DEBUG] %s was not found - removing from state", *id) + d.SetId("") + return nil + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + d.Set("name", id.ConnectorName) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + d.Set("location", azure.NormalizeLocation(model.Location)) + + if err := d.Set("identity", identity.FlattenSystemAssigned(model.Identity)); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } + + return tags.FlattenAndSet(d, model.Tags) + } + + return nil +} + +func resourceDatabricksAccessConnectorDelete(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).DataBricks.AccessConnectorClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := accessconnector.ParseAccessConnectorID(d.Id()) + if err != nil { + return err + } + + if err = client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil +} diff --git a/internal/services/databricks/databricks_access_connector_resource_test.go b/internal/services/databricks/databricks_access_connector_resource_test.go new file mode 100644 index 000000000000..168cefe7da54 --- /dev/null +++ b/internal/services/databricks/databricks_access_connector_resource_test.go @@ -0,0 +1,95 @@ +package databricks_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type DatabricksAccessConnectorResource struct{} + +func TestAccDatabricksAccessConnector_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_databricks_access_connector", "test") + r := DatabricksAccessConnectorResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccDatabricksAccessConnector_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_databricks_access_connector", "test") + r := DatabricksAccessConnectorResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (DatabricksAccessConnectorResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := accessconnector.ParseAccessConnectorID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.DataBricks.AccessConnectorClient.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving Databricks Access Connector %q (resource group: %q): %+v", id.ConnectorName, id.ResourceGroupName, err) + } + + return utils.Bool(resp.Model != nil), nil +} + +func (DatabricksAccessConnectorResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-databricks-%d" + location = "%s" +} + +resource "azurerm_databricks_access_connector" "test" { + name = "acctestDBAC%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + identity { + type = "SystemAssigned" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func (DatabricksAccessConnectorResource) requiresImport(data acceptance.TestData) string { + template := DatabricksAccessConnectorResource{}.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_databricks_access_connector" "import" { + name = azurerm_databricks_access_connector.test.name + resource_group_name = azurerm_databricks_access_connector.test.resource_group_name + location = azurerm_databricks_access_connector.test.location +} +`, template) +} diff --git a/internal/services/databricks/databricks_customer_managed_key_resource.go b/internal/services/databricks/databricks_customer_managed_key_resource.go index 5165572d6175..418900dd99a7 100644 --- a/internal/services/databricks/databricks_customer_managed_key_resource.go +++ b/internal/services/databricks/databricks_customer_managed_key_resource.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" diff --git a/internal/services/databricks/databricks_customer_managed_key_resource_test.go b/internal/services/databricks/databricks_customer_managed_key_resource_test.go index a35375172d87..2885f8972b99 100644 --- a/internal/services/databricks/databricks_customer_managed_key_resource_test.go +++ b/internal/services/databricks/databricks_customer_managed_key_resource_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" diff --git a/internal/services/databricks/databricks_workspace_data_source.go b/internal/services/databricks/databricks_workspace_data_source.go index 071d71b7a226..fb902d6677e1 100644 --- a/internal/services/databricks/databricks_workspace_data_source.go +++ b/internal/services/databricks/databricks_workspace_data_source.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" diff --git a/internal/services/databricks/databricks_workspace_private_endpoint_connection_data_source.go b/internal/services/databricks/databricks_workspace_private_endpoint_connection_data_source.go index 7e6dac9bfb76..ff1ae4023b49 100644 --- a/internal/services/databricks/databricks_workspace_private_endpoint_connection_data_source.go +++ b/internal/services/databricks/databricks_workspace_private_endpoint_connection_data_source.go @@ -5,7 +5,7 @@ import ( "time" "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" diff --git a/internal/services/databricks/databricks_workspace_resource.go b/internal/services/databricks/databricks_workspace_resource.go index 01284e50000b..bf95672c4fe3 100644 --- a/internal/services/databricks/databricks_workspace_resource.go +++ b/internal/services/databricks/databricks_workspace_resource.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" diff --git a/internal/services/databricks/databricks_workspace_resource_test.go b/internal/services/databricks/databricks_workspace_resource_test.go index fe2090403e06..b6a42c118a2c 100644 --- a/internal/services/databricks/databricks_workspace_resource_test.go +++ b/internal/services/databricks/databricks_workspace_resource_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" diff --git a/internal/services/databricks/migration/customer_managed_key.go b/internal/services/databricks/migration/customer_managed_key.go index dc10bb2bb6ae..8c16f3a0a91f 100644 --- a/internal/services/databricks/migration/customer_managed_key.go +++ b/internal/services/databricks/migration/customer_managed_key.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" - "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) diff --git a/internal/services/databricks/registration.go b/internal/services/databricks/registration.go index 0f18bbccd7ef..0897e5cf3efb 100644 --- a/internal/services/databricks/registration.go +++ b/internal/services/databricks/registration.go @@ -36,6 +36,7 @@ func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ + "azurerm_databricks_access_connector": resourceDatabricksAccessConnector(), "azurerm_databricks_workspace": resourceDatabricksWorkspace(), "azurerm_databricks_workspace_customer_managed_key": resourceDatabricksWorkspaceCustomerManagedKey(), } diff --git a/internal/services/databricks/validate/access_conector_name_test.go b/internal/services/databricks/validate/access_conector_name_test.go new file mode 100644 index 000000000000..3d032a82a756 --- /dev/null +++ b/internal/services/databricks/validate/access_conector_name_test.go @@ -0,0 +1,93 @@ +package validate + +import ( + "strings" + "testing" +) + +func TestAccessConnectorName(t *testing.T) { + const errEmpty = "cannot be an empty string" + const errMinLen = "must be at least 1 character" + const errMaxLen = "must be no more than 30 characters" + const errAllowList = "can contain only alphanumeric characters, underscores, and hyphens" + + cases := []struct { + Name string + Input string + ExpectedErrors []string + }{ + // Happy paths: + { + Name: "Entire character allow-list", + Input: "aZ09_-", + }, + { + Name: "Minimum character length", + Input: "---", + }, + { + Name: "Maximum character length", + Input: "012345678901234567890123456789", // 30 chars + }, + + // Simple negative cases: + { + Name: "Introduce a non-allowed character", + Input: "aZ09_-$", // dollar sign + ExpectedErrors: []string{errAllowList}, + }, + { + Name: "Below minimum character length", + Input: "--", + ExpectedErrors: []string{errMinLen}, + }, + { + Name: "Above maximum character length", + Input: "01234567890123456789012345678901234567890123456789012345678901234", // 31 chars + ExpectedErrors: []string{errMaxLen}, + }, + { + Name: "Specifically test for emptiness", + Input: "", + ExpectedErrors: []string{errEmpty}, + }, + + // Complex negative cases + { + Name: "Too short and non-allowed char", + Input: "*^", + ExpectedErrors: []string{errMinLen, errAllowList}, + }, + { + Name: "Too long and non-allowed char", + Input: "0123456789012345678901234567890123456789012345678901234567890123ß", + ExpectedErrors: []string{errMaxLen, errAllowList}, + }, + } + + errsContain := func(errors []error, text string) bool { + for _, err := range errors { + if strings.Contains(err.Error(), text) { + return true + } + } + return false + } + + t.Parallel() + for _, tc := range cases { + t.Run(tc.Name, func(t *testing.T) { + _, errors := AccessConnectorName(tc.Input, "azurerm_databricks_access_connector.test.name") + + if len(errors) != len(tc.ExpectedErrors) { + t.Fatalf("Expected %d errors but got %d for %q: %v", len(tc.ExpectedErrors), len(errors), tc.Input, errors) + } + + for _, expectedError := range tc.ExpectedErrors { + if !errsContain(errors, expectedError) { + t.Fatalf("Errors did not contain expected error: %s", expectedError) + } + } + }) + } +} diff --git a/internal/services/databricks/validate/access_connector_name.go b/internal/services/databricks/validate/access_connector_name.go new file mode 100644 index 000000000000..5408b2205c30 --- /dev/null +++ b/internal/services/databricks/validate/access_connector_name.go @@ -0,0 +1,40 @@ +package validate + +import ( + "fmt" + "regexp" +) + +func AccessConnectorName(i interface{}, k string) (warnings []string, errors []error) { + v, ok := i.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q type to be string", k)) + return warnings, errors + } + + // The Azure Portal shows the following validation criteria: + + // 1) Cannot be empty + if len(v) == 0 { + errors = append(errors, fmt.Errorf("%q cannot be an empty string: %q", k, v)) + // Treating this as a special case and returning early to match Azure Portal behaviour. + return warnings, errors + } + + // 2) Must be at least 1 characters: + if len(v) < 1 { + errors = append(errors, fmt.Errorf("%q must be at least 1 character: %q", k, v)) + } + + // 3) The value must have a length of at most 30 + if len(v) > 30 { + errors = append(errors, fmt.Errorf("%q must be no more than 64 characters: %q", k, v)) + } + + // 4) Only alphanumeric characters, underscores, and hyphens are allowed. + if !regexp.MustCompile("^[a-zA-Z0-9_-]*$").MatchString(v) { + errors = append(errors, fmt.Errorf("%q can contain only alphanumeric characters, underscores, and hyphens: %q", k, v)) + } + + return warnings, errors +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/README.md new file mode 100644 index 000000000000..5c5ee0dbbfd5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector` Documentation + +The `accessconnector` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2022-04-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector" +``` + + +### Client Initialization + +```go +client := accessconnector.NewAccessConnectorClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AccessConnectorClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectorValue") + +payload := accessconnector.AccessConnector{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AccessConnectorClient.Delete` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectorValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AccessConnectorClient.Get` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectorValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AccessConnectorClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := accessconnector.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AccessConnectorClient.ListBySubscription` + +```go +ctx := context.TODO() +id := accessconnector.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AccessConnectorClient.Update` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectorValue") + +payload := accessconnector.AccessConnectorUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/client.go new file mode 100644 index 000000000000..9ec59d8b9c96 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/client.go @@ -0,0 +1,18 @@ +package accessconnector + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorClient struct { + Client autorest.Client + baseUri string +} + +func NewAccessConnectorClientWithBaseURI(endpoint string) AccessConnectorClient { + return AccessConnectorClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/constants.go new file mode 100644 index 000000000000..3e62efe7638a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/constants.go @@ -0,0 +1,37 @@ +package accessconnector + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleted), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleted": ProvisioningStateDeleted, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/id_accessconnector.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/id_accessconnector.go new file mode 100644 index 000000000000..9f2375851465 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/id_accessconnector.go @@ -0,0 +1,124 @@ +package accessconnector + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = AccessConnectorId{} + +// AccessConnectorId is a struct representing the Resource ID for a Access Connector +type AccessConnectorId struct { + SubscriptionId string + ResourceGroupName string + ConnectorName string +} + +// NewAccessConnectorID returns a new AccessConnectorId struct +func NewAccessConnectorID(subscriptionId string, resourceGroupName string, connectorName string) AccessConnectorId { + return AccessConnectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectorName: connectorName, + } +} + +// ParseAccessConnectorID parses 'input' into a AccessConnectorId +func ParseAccessConnectorID(input string) (*AccessConnectorId, error) { + parser := resourceids.NewParserFromResourceIdType(AccessConnectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AccessConnectorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ConnectorName, ok = parsed.Parsed["connectorName"]; !ok { + return nil, fmt.Errorf("the segment 'connectorName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseAccessConnectorIDInsensitively parses 'input' case-insensitively into a AccessConnectorId +// note: this method should only be used for API response data and not user input +func ParseAccessConnectorIDInsensitively(input string) (*AccessConnectorId, error) { + parser := resourceids.NewParserFromResourceIdType(AccessConnectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AccessConnectorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ConnectorName, ok = parsed.Parsed["connectorName"]; !ok { + return nil, fmt.Errorf("the segment 'connectorName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateAccessConnectorID checks that 'input' can be parsed as a Access Connector ID +func ValidateAccessConnectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAccessConnectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Access Connector ID +func (id AccessConnectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/accessConnectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Access Connector ID +func (id AccessConnectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticAccessConnectors", "accessConnectors", "accessConnectors"), + resourceids.UserSpecifiedSegment("connectorName", "connectorValue"), + } +} + +// String returns a human-readable description of this Access Connector ID +func (id AccessConnectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connector Name: %q", id.ConnectorName), + } + return fmt.Sprintf("Access Connector (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_createorupdate_autorest.go new file mode 100644 index 000000000000..4ccc83ab18be --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_createorupdate_autorest.go @@ -0,0 +1,79 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c AccessConnectorClient) CreateOrUpdate(ctx context.Context, id AccessConnectorId, input AccessConnector) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AccessConnectorClient) CreateOrUpdateThenPoll(ctx context.Context, id AccessConnectorId, input AccessConnector) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c AccessConnectorClient) preparerForCreateOrUpdate(ctx context.Context, id AccessConnectorId, input AccessConnector) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c AccessConnectorClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_delete_autorest.go new file mode 100644 index 000000000000..261be118404b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_delete_autorest.go @@ -0,0 +1,78 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c AccessConnectorClient) Delete(ctx context.Context, id AccessConnectorId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AccessConnectorClient) DeleteThenPoll(ctx context.Context, id AccessConnectorId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c AccessConnectorClient) preparerForDelete(ctx context.Context, id AccessConnectorId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c AccessConnectorClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_get_autorest.go new file mode 100644 index 000000000000..7b451ff212b5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_get_autorest.go @@ -0,0 +1,68 @@ +package accessconnector + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *AccessConnector +} + +// Get ... +func (c AccessConnectorClient) Get(ctx context.Context, id AccessConnectorId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c AccessConnectorClient) preparerForGet(ctx context.Context, id AccessConnectorId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c AccessConnectorClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..49f6ef6e509d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_listbyresourcegroup_autorest.go @@ -0,0 +1,187 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]AccessConnector + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []AccessConnector +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c AccessConnectorClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c AccessConnectorClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Databricks/accessConnectors", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c AccessConnectorClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c AccessConnectorClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []AccessConnector `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c AccessConnectorClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccessConnectorOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c AccessConnectorClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccessConnectorOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]AccessConnector, 0) + + page, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_listbysubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_listbysubscription_autorest.go new file mode 100644 index 000000000000..9b98dacd4157 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_listbysubscription_autorest.go @@ -0,0 +1,187 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + Model *[]AccessConnector + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) +} + +type ListBySubscriptionCompleteResult struct { + Items []AccessConnector +} + +func (r ListBySubscriptionOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListBySubscription ... +func (c AccessConnectorClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscription(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListBySubscription(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListBySubscription prepares the ListBySubscription request. +func (c AccessConnectorClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Databricks/accessConnectors", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. +func (c AccessConnectorClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListBySubscription handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (c AccessConnectorClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { + type page struct { + Values []AccessConnector `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListBySubscription", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListBySubscription(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListBySubscriptionComplete retrieves all of the results into a single object +func (c AccessConnectorClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AccessConnectorOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c AccessConnectorClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccessConnectorOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { + items := make([]AccessConnector, 0) + + page, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListBySubscriptionCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_update_autorest.go new file mode 100644 index 000000000000..efcffc7eeb7c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/method_update_autorest.go @@ -0,0 +1,79 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Update ... +func (c AccessConnectorClient) Update(ctx context.Context, id AccessConnectorId, input AccessConnectorUpdate) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Update", nil, "Failure preparing request") + return + } + + result, err = c.senderForUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "accessconnector.AccessConnectorClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c AccessConnectorClient) UpdateThenPoll(ctx context.Context, id AccessConnectorId, input AccessConnectorUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} + +// preparerForUpdate prepares the Update request. +func (c AccessConnectorClient) preparerForUpdate(ctx context.Context, id AccessConnectorId, input AccessConnectorUpdate) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForUpdate sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (c AccessConnectorClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnector.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnector.go new file mode 100644 index 000000000000..20f672fba11d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnector.go @@ -0,0 +1,18 @@ +package accessconnector + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnector struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AccessConnectorProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnectorproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnectorproperties.go new file mode 100644 index 000000000000..790a88d80e31 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnectorproperties.go @@ -0,0 +1,8 @@ +package accessconnector + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnectorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnectorupdate.go new file mode 100644 index 000000000000..26b8921d0d66 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/model_accessconnectorupdate.go @@ -0,0 +1,13 @@ +package accessconnector + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorUpdate struct { + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/predicates.go new file mode 100644 index 000000000000..4b93e35b27cb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/predicates.go @@ -0,0 +1,29 @@ +package accessconnector + +type AccessConnectorOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AccessConnectorOperationPredicate) Matches(input AccessConnector) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/version.go new file mode 100644 index 000000000000..f099c1d48662 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector/version.go @@ -0,0 +1,12 @@ +package accessconnector + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-04-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/accessconnector/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/README.md new file mode 100644 index 000000000000..c473e0a8a4ca --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces` Documentation + +The `workspaces` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2022-04-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces" +``` + + +### Client Initialization + +```go +client := workspaces.NewWorkspacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkspacesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +payload := workspaces.Workspace{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Delete` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Get` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := workspaces.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspacesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := workspaces.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspacesClient.Update` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +payload := workspaces.WorkspaceUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/client.go new file mode 100644 index 000000000000..02d022fa85e3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/client.go @@ -0,0 +1,18 @@ +package workspaces + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacesClient struct { + Client autorest.Client + baseUri string +} + +func NewWorkspacesClientWithBaseURI(endpoint string) WorkspacesClient { + return WorkspacesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/constants.go new file mode 100644 index 000000000000..130ad6fbf3d5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/constants.go @@ -0,0 +1,275 @@ +package workspaces + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomParameterType string + +const ( + CustomParameterTypeBool CustomParameterType = "Bool" + CustomParameterTypeObject CustomParameterType = "Object" + CustomParameterTypeString CustomParameterType = "String" +) + +func PossibleValuesForCustomParameterType() []string { + return []string{ + string(CustomParameterTypeBool), + string(CustomParameterTypeObject), + string(CustomParameterTypeString), + } +} + +func parseCustomParameterType(input string) (*CustomParameterType, error) { + vals := map[string]CustomParameterType{ + "bool": CustomParameterTypeBool, + "object": CustomParameterTypeObject, + "string": CustomParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomParameterType(input) + return &out, nil +} + +type EncryptionKeySource string + +const ( + EncryptionKeySourceMicrosoftPointKeyvault EncryptionKeySource = "Microsoft.Keyvault" +) + +func PossibleValuesForEncryptionKeySource() []string { + return []string{ + string(EncryptionKeySourceMicrosoftPointKeyvault), + } +} + +func parseEncryptionKeySource(input string) (*EncryptionKeySource, error) { + vals := map[string]EncryptionKeySource{ + "microsoft.keyvault": EncryptionKeySourceMicrosoftPointKeyvault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionKeySource(input) + return &out, nil +} + +type KeySource string + +const ( + KeySourceDefault KeySource = "Default" + KeySourceMicrosoftPointKeyvault KeySource = "Microsoft.Keyvault" +) + +func PossibleValuesForKeySource() []string { + return []string{ + string(KeySourceDefault), + string(KeySourceMicrosoftPointKeyvault), + } +} + +func parseKeySource(input string) (*KeySource, error) { + vals := map[string]KeySource{ + "default": KeySourceDefault, + "microsoft.keyvault": KeySourceMicrosoftPointKeyvault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeySource(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateReady ProvisioningState = "Ready" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreated), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateReady), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "created": ProvisioningStateCreated, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "ready": ProvisioningStateReady, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type RequiredNsgRules string + +const ( + RequiredNsgRulesAllRules RequiredNsgRules = "AllRules" + RequiredNsgRulesNoAzureDatabricksRules RequiredNsgRules = "NoAzureDatabricksRules" + RequiredNsgRulesNoAzureServiceRules RequiredNsgRules = "NoAzureServiceRules" +) + +func PossibleValuesForRequiredNsgRules() []string { + return []string{ + string(RequiredNsgRulesAllRules), + string(RequiredNsgRulesNoAzureDatabricksRules), + string(RequiredNsgRulesNoAzureServiceRules), + } +} + +func parseRequiredNsgRules(input string) (*RequiredNsgRules, error) { + vals := map[string]RequiredNsgRules{ + "allrules": RequiredNsgRulesAllRules, + "noazuredatabricksrules": RequiredNsgRulesNoAzureDatabricksRules, + "noazureservicerules": RequiredNsgRulesNoAzureServiceRules, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequiredNsgRules(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/id_workspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/id_workspace.go new file mode 100644 index 000000000000..7225328c81aa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/id_workspace.go @@ -0,0 +1,124 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_createorupdate_autorest.go new file mode 100644 index 000000000000..7e742b0f05f9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_createorupdate_autorest.go @@ -0,0 +1,79 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c WorkspacesClient) CreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c WorkspacesClient) CreateOrUpdateThenPoll(ctx context.Context, id WorkspaceId, input Workspace) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c WorkspacesClient) preparerForCreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c WorkspacesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_delete_autorest.go new file mode 100644 index 000000000000..3475fce1278b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_delete_autorest.go @@ -0,0 +1,78 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c WorkspacesClient) Delete(ctx context.Context, id WorkspaceId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c WorkspacesClient) DeleteThenPoll(ctx context.Context, id WorkspaceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c WorkspacesClient) preparerForDelete(ctx context.Context, id WorkspaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c WorkspacesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_get_autorest.go new file mode 100644 index 000000000000..c16924832e34 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_get_autorest.go @@ -0,0 +1,68 @@ +package workspaces + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *Workspace +} + +// Get ... +func (c WorkspacesClient) Get(ctx context.Context, id WorkspaceId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c WorkspacesClient) preparerForGet(ctx context.Context, id WorkspaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c WorkspacesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..d0a813176128 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_listbyresourcegroup_autorest.go @@ -0,0 +1,187 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]Workspace + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []Workspace +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c WorkspacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c WorkspacesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Databricks/workspaces", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c WorkspacesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c WorkspacesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []Workspace `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, WorkspaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c WorkspacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WorkspaceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]Workspace, 0) + + page, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_listbysubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_listbysubscription_autorest.go new file mode 100644 index 000000000000..418bad379f48 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_listbysubscription_autorest.go @@ -0,0 +1,187 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + Model *[]Workspace + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) +} + +type ListBySubscriptionCompleteResult struct { + Items []Workspace +} + +func (r ListBySubscriptionOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListBySubscription ... +func (c WorkspacesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscription(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListBySubscription(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListBySubscription prepares the ListBySubscription request. +func (c WorkspacesClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Databricks/workspaces", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. +func (c WorkspacesClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListBySubscription handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (c WorkspacesClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { + type page struct { + Values []Workspace `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListBySubscription(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListBySubscriptionComplete retrieves all of the results into a single object +func (c WorkspacesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, WorkspaceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c WorkspacesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WorkspaceOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { + items := make([]Workspace, 0) + + page, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListBySubscriptionCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_update_autorest.go new file mode 100644 index 000000000000..1bff4b670d16 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/method_update_autorest.go @@ -0,0 +1,79 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Update ... +func (c WorkspacesClient) Update(ctx context.Context, id WorkspaceId, input WorkspaceUpdate) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = c.senderForUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c WorkspacesClient) UpdateThenPoll(ctx context.Context, id WorkspaceId, input WorkspaceUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} + +// preparerForUpdate prepares the Update request. +func (c WorkspacesClient) preparerForUpdate(ctx context.Context, id WorkspaceId, input WorkspaceUpdate) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForUpdate sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (c WorkspacesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_createdby.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_createdby.go new file mode 100644 index 000000000000..fa06a35a393b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_createdby.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatedBy struct { + ApplicationId *string `json:"applicationId,omitempty"` + Oid *string `json:"oid,omitempty"` + Puid *string `json:"puid,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryption.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryption.go new file mode 100644 index 000000000000..3d37fddd7e5f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryption.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Encryption struct { + KeyName *string `json:"KeyName,omitempty"` + KeySource *KeySource `json:"keySource,omitempty"` + Keyvaulturi *string `json:"keyvaulturi,omitempty"` + Keyversion *string `json:"keyversion,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionentitiesdefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionentitiesdefinition.go new file mode 100644 index 000000000000..37c7a8fdbfb6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionentitiesdefinition.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionEntitiesDefinition struct { + ManagedServices *EncryptionV2 `json:"managedServices,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionv2.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionv2.go new file mode 100644 index 000000000000..1569f86ef50e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionv2.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionV2 struct { + KeySource EncryptionKeySource `json:"keySource"` + KeyVaultProperties *EncryptionV2KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionv2keyvaultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionv2keyvaultproperties.go new file mode 100644 index 000000000000..86adbd8c6a54 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_encryptionv2keyvaultproperties.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionV2KeyVaultProperties struct { + KeyName string `json:"keyName"` + KeyVaultUri string `json:"keyVaultUri"` + KeyVersion string `json:"keyVersion"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_managedidentityconfiguration.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_managedidentityconfiguration.go new file mode 100644 index 000000000000..aeea7f937c85 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_managedidentityconfiguration.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedIdentityConfiguration struct { + PrincipalId *string `json:"principalId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpoint.go new file mode 100644 index 000000000000..9f81ff8b836c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpoint.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpointconnection.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpointconnection.go new file mode 100644 index 000000000000..aee2db4a4b3c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties PrivateEndpointConnectionProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpointconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..34f25f6a480a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privateendpointconnectionproperties.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privatelinkserviceconnectionstate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..bdea419278ee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionRequired *string `json:"actionRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status PrivateLinkServiceConnectionStatus `json:"status"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_sku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_sku.go new file mode 100644 index 000000000000..e5316e27b309 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_sku.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name string `json:"name"` + Tier *string `json:"tier,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspace.go new file mode 100644 index 000000000000..2a205ac19021 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspace.go @@ -0,0 +1,19 @@ +package workspaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Workspace struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties WorkspaceProperties `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustombooleanparameter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustombooleanparameter.go new file mode 100644 index 000000000000..a2e256bd2f0d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustombooleanparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomBooleanParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value bool `json:"value"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomobjectparameter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomobjectparameter.go new file mode 100644 index 000000000000..85cfe0983914 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomobjectparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomObjectParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value interface{} `json:"value"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomparameters.go new file mode 100644 index 000000000000..3c55d9c99e75 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomparameters.go @@ -0,0 +1,23 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomParameters struct { + AmlWorkspaceId *WorkspaceCustomStringParameter `json:"amlWorkspaceId,omitempty"` + CustomPrivateSubnetName *WorkspaceCustomStringParameter `json:"customPrivateSubnetName,omitempty"` + CustomPublicSubnetName *WorkspaceCustomStringParameter `json:"customPublicSubnetName,omitempty"` + CustomVirtualNetworkId *WorkspaceCustomStringParameter `json:"customVirtualNetworkId,omitempty"` + EnableNoPublicIP *WorkspaceCustomBooleanParameter `json:"enableNoPublicIp,omitempty"` + Encryption *WorkspaceEncryptionParameter `json:"encryption,omitempty"` + LoadBalancerBackendPoolName *WorkspaceCustomStringParameter `json:"loadBalancerBackendPoolName,omitempty"` + LoadBalancerId *WorkspaceCustomStringParameter `json:"loadBalancerId,omitempty"` + NatGatewayName *WorkspaceCustomStringParameter `json:"natGatewayName,omitempty"` + PrepareEncryption *WorkspaceCustomBooleanParameter `json:"prepareEncryption,omitempty"` + PublicIPName *WorkspaceCustomStringParameter `json:"publicIpName,omitempty"` + RequireInfrastructureEncryption *WorkspaceCustomBooleanParameter `json:"requireInfrastructureEncryption,omitempty"` + ResourceTags *WorkspaceCustomObjectParameter `json:"resourceTags,omitempty"` + StorageAccountName *WorkspaceCustomStringParameter `json:"storageAccountName,omitempty"` + StorageAccountSkuName *WorkspaceCustomStringParameter `json:"storageAccountSkuName,omitempty"` + VnetAddressPrefix *WorkspaceCustomStringParameter `json:"vnetAddressPrefix,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomstringparameter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomstringparameter.go new file mode 100644 index 000000000000..c983ffae968f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacecustomstringparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomStringParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value string `json:"value"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceencryptionparameter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceencryptionparameter.go new file mode 100644 index 000000000000..551ca748c04c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceencryptionparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceEncryptionParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value *Encryption `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceproperties.go new file mode 100644 index 000000000000..1a968a53acb3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceproperties.go @@ -0,0 +1,40 @@ +package workspaces + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceProperties struct { + Authorizations *[]WorkspaceProviderAuthorization `json:"authorizations,omitempty"` + CreatedBy *CreatedBy `json:"createdBy,omitempty"` + CreatedDateTime *string `json:"createdDateTime,omitempty"` + Encryption *WorkspacePropertiesEncryption `json:"encryption,omitempty"` + ManagedResourceGroupId string `json:"managedResourceGroupId"` + Parameters *WorkspaceCustomParameters `json:"parameters,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RequiredNsgRules *RequiredNsgRules `json:"requiredNsgRules,omitempty"` + StorageAccountIdentity *ManagedIdentityConfiguration `json:"storageAccountIdentity,omitempty"` + UiDefinitionUri *string `json:"uiDefinitionUri,omitempty"` + UpdatedBy *CreatedBy `json:"updatedBy,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceUrl *string `json:"workspaceUrl,omitempty"` +} + +func (o *WorkspaceProperties) GetCreatedDateTimeAsTime() (*time.Time, error) { + if o.CreatedDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkspaceProperties) SetCreatedDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedDateTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacepropertiesencryption.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacepropertiesencryption.go new file mode 100644 index 000000000000..ddb3625ee748 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspacepropertiesencryption.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePropertiesEncryption struct { + Entities EncryptionEntitiesDefinition `json:"entities"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceproviderauthorization.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceproviderauthorization.go new file mode 100644 index 000000000000..98d6f732126c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceproviderauthorization.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceProviderAuthorization struct { + PrincipalId string `json:"principalId"` + RoleDefinitionId string `json:"roleDefinitionId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceupdate.go new file mode 100644 index 000000000000..079a43eda11b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/model_workspaceupdate.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/predicates.go new file mode 100644 index 000000000000..aed808b5b33d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/predicates.go @@ -0,0 +1,29 @@ +package workspaces + +type WorkspaceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkspaceOperationPredicate) Matches(input Workspace) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/version.go new file mode 100644 index 000000000000..51a37b51aa6b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces/version.go @@ -0,0 +1,12 @@ +package workspaces + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-04-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workspaces/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d998cf366fdd..836fb2c25604 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -214,6 +214,8 @@ github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/sqldedica github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2021-10-01/exports github.com/hashicorp/go-azure-sdk/resource-manager/dashboard/2022-08-01/grafanaresource github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2021-04-01-preview/workspaces +github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector +github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2022-04-01/backupinstances github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2022-04-01/backuppolicies github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2022-04-01/backupvaults diff --git a/website/docs/r/databricks_access_connector.html.markdown b/website/docs/r/databricks_access_connector.html.markdown new file mode 100644 index 000000000000..b366d31a1c26 --- /dev/null +++ b/website/docs/r/databricks_access_connector.html.markdown @@ -0,0 +1,72 @@ +--- +subcategory: "Databricks" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_databricks_access_connector" +description: |- + Manages a Databricks Access Connector +--- + +# azurerm_databricks_access_connector + +~> **NOTE:** Databricks Access Connectors are in Private Preview and potentially subject to breaking change without notice. If you would like to use these features please contact your Microsoft support representative on how to opt-in to the Databricks Access Connector Private Preview feature program. + +Manages a Databricks Access Connector + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_databricks_access_connector" "example" { + name = "databrickstest" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + identity { + type = "SystemAssigned" + } + + tags = { + Environment = "Production" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Databricks Access Connector resource. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group in which the Databricks Access Connector should exist. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource has to be created. Changing this forces a new resource to be created. + + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Databricks Workspace in the Azure management plane. + + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 5 minutes) Used when creating the Databricks Access Connector. +* `update` - (Defaults to 5 minutes) Used when updating the Databricks Access Connector. +* `read` - (Defaults to 5 minutes) Used when retrieving the Databricks Access Connector. +* `delete` - (Defaults to 5 minutes) Used when deleting the Databricks Access Connector. + +## Import + +Databricks Access Connectors can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_databricks_access_connector.connector1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Databricks/accessConnectors/connector1 +```