diff --git a/sdk/resourcemanager/databricks/armdatabricks/CHANGELOG.md b/sdk/resourcemanager/databricks/armdatabricks/CHANGELOG.md new file mode 100644 index 000000000000..f3d80a0b8362 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-10-26) + +- Initial preview release. diff --git a/sdk/resourcemanager/databricks/armdatabricks/LICENSE.txt b/sdk/resourcemanager/databricks/armdatabricks/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/databricks/armdatabricks/README.md b/sdk/resourcemanager/databricks/armdatabricks/README.md new file mode 100644 index 000000000000..7d53c9de891e --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/README.md @@ -0,0 +1,76 @@ +# Azure Databricks Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databricks/armdatabricks)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databricks/armdatabricks) + +The `armdatabricks` module provides operations for working with Azure Databricks. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/databricks/armdatabricks) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Databricks module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databricks/armdatabricks +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Databricks. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Databricks + +Once you have a credential, create a connection to the desired ARM endpoint. The `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := arm.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +## Clients + +Azure Databricks modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `arm.Connection`. + +```go +client := armdatabricks.NewWorkspacesClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Databricks` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/databricks/armdatabricks/autorest.md b/sdk/resourcemanager/databricks/armdatabricks/autorest.md new file mode 100644 index 000000000000..0dc9df444ac5 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/3c16aae50c7110e1aad241ac93995621d4093d46/specification/databricks/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/3c16aae50c7110e1aad241ac93995621d4093d46/specification/databricks/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/resourcemanager/databricks/armdatabricks/build.go b/sdk/resourcemanager/databricks/armdatabricks/build.go new file mode 100644 index 000000000000..b98147c2087c --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/databricks/armdatabricks + +package armdatabricks diff --git a/sdk/resourcemanager/databricks/armdatabricks/ci.yml b/sdk/resourcemanager/databricks/armdatabricks/ci.yml new file mode 100644 index 000000000000..e6b4b3961392 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/databricks/armdatabricks/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/databricks/armdatabricks/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/databricks/armdatabricks' diff --git a/sdk/resourcemanager/databricks/armdatabricks/go.mod b/sdk/resourcemanager/databricks/armdatabricks/go.mod new file mode 100644 index 000000000000..416ec90638d6 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databricks/armdatabricks + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v58.2.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 +) diff --git a/sdk/resourcemanager/databricks/armdatabricks/go.sum b/sdk/resourcemanager/databricks/armdatabricks/go.sum new file mode 100644 index 000000000000..c8ff7a2143ad --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go v58.2.0+incompatible h1:iCb2tuoEm3N7ZpUDOvu1Yxl1B3iOVDmaD6weaRuIPzs= +github.com/Azure/azure-sdk-for-go v58.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/databricks/armdatabricks/go_mod_tidy_hack.go b/sdk/resourcemanager/databricks/armdatabricks/go_mod_tidy_hack.go new file mode 100644 index 000000000000..fd1479661fa0 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armdatabricks + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_constants.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_constants.go new file mode 100644 index 000000000000..46af945b4ff7 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_constants.go @@ -0,0 +1,287 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +const ( + module = "armdatabricks" + version = "v0.1.0" +) + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// CustomParameterType - Provisioning status of the workspace. +type CustomParameterType string + +const ( + CustomParameterTypeBool CustomParameterType = "Bool" + CustomParameterTypeObject CustomParameterType = "Object" + CustomParameterTypeString CustomParameterType = "String" +) + +// PossibleCustomParameterTypeValues returns the possible values for the CustomParameterType const type. +func PossibleCustomParameterTypeValues() []CustomParameterType { + return []CustomParameterType{ + CustomParameterTypeBool, + CustomParameterTypeObject, + CustomParameterTypeString, + } +} + +// ToPtr returns a *CustomParameterType pointing to the current value. +func (c CustomParameterType) ToPtr() *CustomParameterType { + return &c +} + +// EncryptionKeySource - The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Keyvault +type EncryptionKeySource string + +const ( + EncryptionKeySourceMicrosoftKeyvault EncryptionKeySource = "Microsoft.Keyvault" +) + +// PossibleEncryptionKeySourceValues returns the possible values for the EncryptionKeySource const type. +func PossibleEncryptionKeySourceValues() []EncryptionKeySource { + return []EncryptionKeySource{ + EncryptionKeySourceMicrosoftKeyvault, + } +} + +// ToPtr returns a *EncryptionKeySource pointing to the current value. +func (c EncryptionKeySource) ToPtr() *EncryptionKeySource { + return &c +} + +// KeySource - The encryption keySource (provider). Possible values (case-insensitive): Default, Microsoft.Keyvault +type KeySource string + +const ( + KeySourceDefault KeySource = "Default" + KeySourceMicrosoftKeyvault KeySource = "Microsoft.Keyvault" +) + +// PossibleKeySourceValues returns the possible values for the KeySource const type. +func PossibleKeySourceValues() []KeySource { + return []KeySource{ + KeySourceDefault, + KeySourceMicrosoftKeyvault, + } +} + +// ToPtr returns a *KeySource pointing to the current value. +func (c KeySource) ToPtr() *KeySource { + return &c +} + +// PeeringProvisioningState - The current provisioning state. +type PeeringProvisioningState string + +const ( + PeeringProvisioningStateDeleting PeeringProvisioningState = "Deleting" + PeeringProvisioningStateFailed PeeringProvisioningState = "Failed" + PeeringProvisioningStateSucceeded PeeringProvisioningState = "Succeeded" + PeeringProvisioningStateUpdating PeeringProvisioningState = "Updating" +) + +// PossiblePeeringProvisioningStateValues returns the possible values for the PeeringProvisioningState const type. +func PossiblePeeringProvisioningStateValues() []PeeringProvisioningState { + return []PeeringProvisioningState{ + PeeringProvisioningStateDeleting, + PeeringProvisioningStateFailed, + PeeringProvisioningStateSucceeded, + PeeringProvisioningStateUpdating, + } +} + +// ToPtr returns a *PeeringProvisioningState pointing to the current value. +func (c PeeringProvisioningState) ToPtr() *PeeringProvisioningState { + return &c +} + +// PeeringState - The status of the virtual network peering. +type PeeringState string + +const ( + PeeringStateConnected PeeringState = "Connected" + PeeringStateDisconnected PeeringState = "Disconnected" + PeeringStateInitiated PeeringState = "Initiated" +) + +// PossiblePeeringStateValues returns the possible values for the PeeringState const type. +func PossiblePeeringStateValues() []PeeringState { + return []PeeringState{ + PeeringStateConnected, + PeeringStateDisconnected, + PeeringStateInitiated, + } +} + +// ToPtr returns a *PeeringState pointing to the current value. +func (c PeeringState) ToPtr() *PeeringState { + return &c +} + +// PrivateEndpointConnectionProvisioningState - The current provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns the possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{ + PrivateEndpointConnectionProvisioningStateCreating, + PrivateEndpointConnectionProvisioningStateDeleting, + PrivateEndpointConnectionProvisioningStateFailed, + PrivateEndpointConnectionProvisioningStateSucceeded, + PrivateEndpointConnectionProvisioningStateUpdating, + } +} + +// ToPtr returns a *PrivateEndpointConnectionProvisioningState pointing to the current value. +func (c PrivateEndpointConnectionProvisioningState) ToPtr() *PrivateEndpointConnectionProvisioningState { + return &c +} + +// PrivateLinkServiceConnectionStatus - The status of a private endpoint connection +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns the possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{ + PrivateLinkServiceConnectionStatusApproved, + PrivateLinkServiceConnectionStatusDisconnected, + PrivateLinkServiceConnectionStatusPending, + PrivateLinkServiceConnectionStatusRejected, + } +} + +// ToPtr returns a *PrivateLinkServiceConnectionStatus pointing to the current value. +func (c PrivateLinkServiceConnectionStatus) ToPtr() *PrivateLinkServiceConnectionStatus { + return &c +} + +// ProvisioningState - Provisioning status of the workspace. +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" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreated, + ProvisioningStateCreating, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateReady, + ProvisioningStateRunning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// PublicNetworkAccess - The network access type for accessing workspace. Set value to disabled to access workspace only via private link. +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + } +} + +// ToPtr returns a *PublicNetworkAccess pointing to the current value. +func (c PublicNetworkAccess) ToPtr() *PublicNetworkAccess { + return &c +} + +// RequiredNsgRules - Gets or sets a value indicating whether data plane (clusters) to control plane communication happen over private endpoint. Supported +// values are 'AllRules' and 'NoAzureDatabricksRules'. +// 'NoAzureServiceRules' value is for internal use only. +type RequiredNsgRules string + +const ( + RequiredNsgRulesAllRules RequiredNsgRules = "AllRules" + RequiredNsgRulesNoAzureDatabricksRules RequiredNsgRules = "NoAzureDatabricksRules" + RequiredNsgRulesNoAzureServiceRules RequiredNsgRules = "NoAzureServiceRules" +) + +// PossibleRequiredNsgRulesValues returns the possible values for the RequiredNsgRules const type. +func PossibleRequiredNsgRulesValues() []RequiredNsgRules { + return []RequiredNsgRules{ + RequiredNsgRulesAllRules, + RequiredNsgRulesNoAzureDatabricksRules, + RequiredNsgRulesNoAzureServiceRules, + } +} + +// ToPtr returns a *RequiredNsgRules pointing to the current value. +func (c RequiredNsgRules) ToPtr() *RequiredNsgRules { + return &c +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_models.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_models.go new file mode 100644 index 000000000000..bc05e96058d6 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_models.go @@ -0,0 +1,958 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "encoding/json" + "reflect" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// AddressSpace contains an array of IP address ranges that can be used by subnets of the virtual network. +type AddressSpace struct { + // A list of address blocks reserved for this virtual network in CIDR notation. + AddressPrefixes []*string `json:"addressPrefixes,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AddressSpace. +func (a AddressSpace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "addressPrefixes", a.AddressPrefixes) + return json.Marshal(objectMap) +} + +// CreatedBy - Provides details of the entity that created/updated the workspace. +type CreatedBy struct { + // READ-ONLY; The application ID of the application that initiated the creation of the workspace. For example, Azure Portal. + ApplicationID *string `json:"applicationId,omitempty" azure:"ro"` + + // READ-ONLY; The Object ID that created the workspace. + Oid *string `json:"oid,omitempty" azure:"ro"` + + // READ-ONLY; The Personal Object ID corresponding to the object ID above + Puid *string `json:"puid,omitempty" azure:"ro"` +} + +// Encryption - The object that contains details of encryption used on the workspace. +type Encryption struct { + // The name of KeyVault key. + KeyName *string `json:"KeyName,omitempty"` + + // The encryption keySource (provider). Possible values (case-insensitive): Default, Microsoft.Keyvault + KeySource *KeySource `json:"keySource,omitempty"` + + // The Uri of KeyVault. + KeyVaultURI *string `json:"keyvaulturi,omitempty"` + + // The version of KeyVault key. + KeyVersion *string `json:"keyversion,omitempty"` +} + +// EncryptionEntitiesDefinition - Encryption entities for databricks workspace resource. +type EncryptionEntitiesDefinition struct { + // Encryption properties for the databricks managed services. + ManagedServices *EncryptionV2 `json:"managedServices,omitempty"` +} + +// EncryptionV2 - The object that contains details of encryption used on the workspace. +type EncryptionV2 struct { + // REQUIRED; The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Keyvault + KeySource *EncryptionKeySource `json:"keySource,omitempty"` + + // Key Vault input properties for encryption. + KeyVaultProperties *EncryptionV2KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} + +// EncryptionV2KeyVaultProperties - Key Vault input properties for encryption. +type EncryptionV2KeyVaultProperties struct { + // REQUIRED; The name of KeyVault key. + KeyName *string `json:"keyName,omitempty"` + + // REQUIRED; The Uri of KeyVault. + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + + // REQUIRED; The version of KeyVault key. + KeyVersion *string `json:"keyVersion,omitempty"` +} + +// EndpointDependency - A domain name or IP address the Workspace is reaching at. +type EndpointDependency struct { + // The domain name of the dependency. + DomainName *string `json:"domainName,omitempty"` + + // The Ports used when connecting to domainName. + EndpointDetails []*EndpointDetail `json:"endpointDetails,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EndpointDependency. +func (e EndpointDependency) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "domainName", e.DomainName) + populate(objectMap, "endpointDetails", e.EndpointDetails) + return json.Marshal(objectMap) +} + +// EndpointDetail - Connect information from the Workspace to a single endpoint. +type EndpointDetail struct { + // An IP Address that Domain Name currently resolves to. + IPAddress *string `json:"ipAddress,omitempty"` + + // Whether it is possible to create a connection from the Workspace to this IpAddress at this Port. + IsAccessible *bool `json:"isAccessible,omitempty"` + + // The time in milliseconds it takes for the connection to be created from the Workspace to this IpAddress at this Port. + Latency *float64 `json:"latency,omitempty"` + + // The port an endpoint is connected to. + Port *int32 `json:"port,omitempty"` +} + +// ErrorDetail - Error details. +type ErrorDetail struct { + // REQUIRED; The error's code. + Code *string `json:"code,omitempty"` + + // REQUIRED; A human readable error message. + Message *string `json:"message,omitempty"` + + // Indicates which property in the request is responsible for the error. + Target *string `json:"target,omitempty"` +} + +// ErrorInfo - The code and message for an error. +type ErrorInfo struct { + // REQUIRED; A machine readable error code. + Code *string `json:"code,omitempty"` + + // REQUIRED; A human readable error message. + Message *string `json:"message,omitempty"` + + // error details. + Details []*ErrorDetail `json:"details,omitempty"` + + // Inner error details if they exist. + Innererror *string `json:"innererror,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorInfo. +func (e ErrorInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "innererror", e.Innererror) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// ErrorResponse - Contains details when the response code indicates an error. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // REQUIRED; The error details. + InnerError *ErrorInfo `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// GroupIDInformation - The group information for creating a private endpoint on a workspace +type GroupIDInformation struct { + Resource + // REQUIRED; The group id properties. + Properties *GroupIDInformationProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupIDInformation. +func (g GroupIDInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + g.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// GroupIDInformationProperties - The properties for a group information object +type GroupIDInformationProperties struct { + // The group id + GroupID *string `json:"groupId,omitempty"` + + // The required members for a specific group id + RequiredMembers []*string `json:"requiredMembers,omitempty"` + + // The required DNS zones for a specific group id + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupIDInformationProperties. +func (g GroupIDInformationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", g.GroupID) + populate(objectMap, "requiredMembers", g.RequiredMembers) + populate(objectMap, "requiredZoneNames", g.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// ManagedIdentityConfiguration - The Managed Identity details for storage account. +type ManagedIdentityConfiguration struct { + // READ-ONLY; The objectId of the Managed Identity that is linked to the Managed Storage account. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant Id where the Managed Identity is created. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` + + // READ-ONLY; The type of Identity created. It can be either SystemAssigned or UserAssigned. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// Operation - REST API operation +type Operation struct { + // The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider: Microsoft.ResourceProvider + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set +// of results. +type OperationListResult struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of Resource Provider operations supported by the Resource Provider resource provider. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// OutboundEnvironmentEndpoint - Egress endpoints which Workspace connects to for common purposes. +type OutboundEnvironmentEndpoint struct { + // The category of endpoints accessed by the Workspace, e.g. azure-storage, azure-mysql, etc. + Category *string `json:"category,omitempty"` + + // The endpoints that Workspace connect to + Endpoints []*EndpointDependency `json:"endpoints,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OutboundEnvironmentEndpoint. +func (o OutboundEnvironmentEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", o.Category) + populate(objectMap, "endpoints", o.Endpoints) + return json.Marshal(objectMap) +} + +// OutboundNetworkDependenciesEndpointsListOptions contains the optional parameters for the OutboundNetworkDependenciesEndpoints.List method. +type OutboundNetworkDependenciesEndpointsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpoint - The private endpoint property of a private endpoint connection +type PrivateEndpoint struct { + // READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` +} + +// PrivateEndpointConnection - The private endpoint connection of a workspace +type PrivateEndpointConnection struct { + // REQUIRED; The private endpoint connection properties. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + + // READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionProperties - The properties of a private endpoint connection +type PrivateEndpointConnectionProperties struct { + // REQUIRED; Private endpoint connection state + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + + // Private endpoint + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + + // READ-ONLY; Provisioning state of the private endpoint connection. + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionsBeginCreateOptions contains the optional parameters for the PrivateEndpointConnections.BeginCreate method. +type PrivateEndpointConnectionsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnections.BeginDelete method. +type PrivateEndpointConnectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. +type PrivateEndpointConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsList - List of private link connections. +type PrivateEndpointConnectionsList struct { + // The URL to get the next set of endpoint connections. + NextLink *string `json:"nextLink,omitempty"` + + // The list of returned private endpoint connection. + Value []*PrivateEndpointConnection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionsList. +func (p PrivateEndpointConnectionsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. +type PrivateEndpointConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesGetOptions contains the optional parameters for the PrivateLinkResources.Get method. +type PrivateLinkResourcesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesList - The available private link resources for a workspace +type PrivateLinkResourcesList struct { + // The URL to get the next set of private link resources. + NextLink *string `json:"nextLink,omitempty"` + + // The list of available private link resources for a workspace + Value []*GroupIDInformation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourcesList. +func (p PrivateLinkResourcesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourcesListOptions contains the optional parameters for the PrivateLinkResources.List method. +type PrivateLinkResourcesListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkServiceConnectionState - The current state of a private endpoint connection +type PrivateLinkServiceConnectionState struct { + // REQUIRED; The status of a private endpoint connection + Status *PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + + // Actions required for a private endpoint connection + ActionRequired *string `json:"actionRequired,omitempty"` + + // The description for the current state of a private endpoint connection + Description *string `json:"description,omitempty"` +} + +// Resource - The core properties of ARM resources +type Resource struct { + // READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// SKU for the resource. +type SKU struct { + // REQUIRED; The SKU name. + Name *string `json:"name,omitempty"` + + // The SKU tier. + Tier *string `json:"tier,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdAt", (*timeRFC3339)(s.CreatedAt)) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populate(objectMap, "lastModifiedAt", (*timeRFC3339)(s.LastModifiedAt)) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreatedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastModifiedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for a ARM tracked top level resource +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +// VNetPeeringBeginCreateOrUpdateOptions contains the optional parameters for the VNetPeering.BeginCreateOrUpdate method. +type VNetPeeringBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// VNetPeeringBeginDeleteOptions contains the optional parameters for the VNetPeering.BeginDelete method. +type VNetPeeringBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// VNetPeeringGetOptions contains the optional parameters for the VNetPeering.Get method. +type VNetPeeringGetOptions struct { + // placeholder for future optional parameters +} + +// VNetPeeringListByWorkspaceOptions contains the optional parameters for the VNetPeering.ListByWorkspace method. +type VNetPeeringListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworkPeering - Peerings in a VirtualNetwork resource +type VirtualNetworkPeering struct { + // REQUIRED; List of properties for vNet Peering + Properties *VirtualNetworkPeeringPropertiesFormat `json:"properties,omitempty"` + + // READ-ONLY; Resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the virtual network peering resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; type of the virtual network peering resource + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VirtualNetworkPeeringList - Gets all virtual network peerings under a workspace. +type VirtualNetworkPeeringList struct { + // URL to get the next set of virtual network peering list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of virtual network peerings on workspace. + Value []*VirtualNetworkPeering `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkPeeringList. +func (v VirtualNetworkPeeringList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// VirtualNetworkPeeringPropertiesFormat - Properties of the virtual network peering. +type VirtualNetworkPeeringPropertiesFormat struct { + // REQUIRED; The remote virtual network should be in the same region. See here to learn more (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering). + RemoteVirtualNetwork *VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork `json:"remoteVirtualNetwork,omitempty"` + + // Whether the forwarded traffic from the VMs in the local virtual network will be allowed/disallowed in remote virtual network. + AllowForwardedTraffic *bool `json:"allowForwardedTraffic,omitempty"` + + // If gateway links can be used in remote virtual networking to link to this virtual network. + AllowGatewayTransit *bool `json:"allowGatewayTransit,omitempty"` + + // Whether the VMs in the local virtual network space would be able to access the VMs in remote virtual network space. + AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,omitempty"` + + // The reference to the databricks virtual network address space. + DatabricksAddressSpace *AddressSpace `json:"databricksAddressSpace,omitempty"` + + // The remote virtual network should be in the same region. See here to learn more (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering). + DatabricksVirtualNetwork *VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork `json:"databricksVirtualNetwork,omitempty"` + + // The reference to the remote virtual network address space. + RemoteAddressSpace *AddressSpace `json:"remoteAddressSpace,omitempty"` + + // If remote gateways can be used on this virtual network. If the flag is set to true, and allowGatewayTransit on remote peering is also true, virtual network + // will use gateways of remote virtual network + // for transit. Only one peering can have this flag set to true. This flag cannot be set if virtual network already has a gateway. + UseRemoteGateways *bool `json:"useRemoteGateways,omitempty"` + + // READ-ONLY; The status of the virtual network peering. + PeeringState *PeeringState `json:"peeringState,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the virtual network peering resource. + ProvisioningState *PeeringProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork - The remote virtual network should be in the same region. See here to learn more (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering). +type VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork struct { + // The Id of the databricks virtual network. + ID *string `json:"id,omitempty"` +} + +// VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork - The remote virtual network should be in the same region. See here to learn more (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering). +type VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork struct { + // The Id of the remote virtual network. + ID *string `json:"id,omitempty"` +} + +// Workspace - Information about workspace. +type Workspace struct { + TrackedResource + // REQUIRED; The workspace properties. + Properties *WorkspaceProperties `json:"properties,omitempty"` + + // The SKU of the resource. + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; The system metadata relating to this resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "sku", w.SKU) + populate(objectMap, "systemData", w.SystemData) + return json.Marshal(objectMap) +} + +// WorkspaceCustomBooleanParameter - The value which should be used for this field. +type WorkspaceCustomBooleanParameter struct { + // REQUIRED; The value which should be used for this field. + Value *bool `json:"value,omitempty"` + + // READ-ONLY; The type of variable that this is + Type *CustomParameterType `json:"type,omitempty" azure:"ro"` +} + +// WorkspaceCustomObjectParameter - The value which should be used for this field. +type WorkspaceCustomObjectParameter struct { + // REQUIRED; The value which should be used for this field. + Value map[string]interface{} `json:"value,omitempty"` + + // READ-ONLY; The type of variable that this is + Type *CustomParameterType `json:"type,omitempty" azure:"ro"` +} + +// WorkspaceCustomParameters - Custom Parameters used for Cluster Creation. +type WorkspaceCustomParameters struct { + // The ID of a Azure Machine Learning workspace to link with Databricks workspace + AmlWorkspaceID *WorkspaceCustomStringParameter `json:"amlWorkspaceId,omitempty"` + + // The name of the Private Subnet within the Virtual Network + CustomPrivateSubnetName *WorkspaceCustomStringParameter `json:"customPrivateSubnetName,omitempty"` + + // The name of a Public Subnet within the Virtual Network + CustomPublicSubnetName *WorkspaceCustomStringParameter `json:"customPublicSubnetName,omitempty"` + + // The ID of a Virtual Network where this Databricks Cluster should be created + CustomVirtualNetworkID *WorkspaceCustomStringParameter `json:"customVirtualNetworkId,omitempty"` + + // Should the Public IP be Disabled? + EnableNoPublicIP *WorkspaceCustomBooleanParameter `json:"enableNoPublicIp,omitempty"` + + // Contains the encryption details for Customer-Managed Key (CMK) enabled workspace. + Encryption *WorkspaceEncryptionParameter `json:"encryption,omitempty"` + + // Name of the outbound Load Balancer Backend Pool for Secure Cluster Connectivity (No Public IP). + LoadBalancerBackendPoolName *WorkspaceCustomStringParameter `json:"loadBalancerBackendPoolName,omitempty"` + + // Resource URI of Outbound Load balancer for Secure Cluster Connectivity (No Public IP) workspace. + LoadBalancerID *WorkspaceCustomStringParameter `json:"loadBalancerId,omitempty"` + + // Name of the NAT gateway for Secure Cluster Connectivity (No Public IP) workspace subnets. + NatGatewayName *WorkspaceCustomStringParameter `json:"natGatewayName,omitempty"` + + // Prepare the workspace for encryption. Enables the Managed Identity for managed storage account. + PrepareEncryption *WorkspaceCustomBooleanParameter `json:"prepareEncryption,omitempty"` + + // Name of the Public IP for No Public IP workspace with managed vNet. + PublicIPName *WorkspaceCustomStringParameter `json:"publicIpName,omitempty"` + + // A boolean indicating whether or not the DBFS root file system will be enabled with secondary layer of encryption with platform managed keys for data + // at rest. + RequireInfrastructureEncryption *WorkspaceCustomBooleanParameter `json:"requireInfrastructureEncryption,omitempty"` + + // Default DBFS storage account name. + StorageAccountName *WorkspaceCustomStringParameter `json:"storageAccountName,omitempty"` + + // Storage account SKU name, ex: StandardGRS, StandardLRS. Refer https://aka.ms/storageskus for valid inputs. + StorageAccountSKUName *WorkspaceCustomStringParameter `json:"storageAccountSkuName,omitempty"` + + // Address prefix for Managed virtual network. Default value for this input is 10.139. + VnetAddressPrefix *WorkspaceCustomStringParameter `json:"vnetAddressPrefix,omitempty"` + + // READ-ONLY; Tags applied to resources under Managed resource group. These can be updated by updating tags at workspace level. + ResourceTags *WorkspaceCustomObjectParameter `json:"resourceTags,omitempty" azure:"ro"` +} + +// WorkspaceCustomStringParameter - The Value. +type WorkspaceCustomStringParameter struct { + // REQUIRED; The value which should be used for this field. + Value *string `json:"value,omitempty"` + + // READ-ONLY; The type of variable that this is + Type *CustomParameterType `json:"type,omitempty" azure:"ro"` +} + +// WorkspaceEncryptionParameter - The object that contains details of encryption used on the workspace. +type WorkspaceEncryptionParameter struct { + // The value which should be used for this field. + Value *Encryption `json:"value,omitempty"` + + // READ-ONLY; The type of variable that this is + Type *CustomParameterType `json:"type,omitempty" azure:"ro"` +} + +// WorkspaceListResult - List of workspaces. +type WorkspaceListResult struct { + // The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` + + // The array of workspaces. + Value []*Workspace `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceListResult. +func (w WorkspaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkspaceProperties - The workspace properties. +type WorkspaceProperties struct { + // REQUIRED; The managed resource group Id. + ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"` + + // The workspace provider authorizations. + Authorizations []*WorkspaceProviderAuthorization `json:"authorizations,omitempty"` + + // Indicates the Object ID, PUID and Application ID of entity that created the workspace. + CreatedBy *CreatedBy `json:"createdBy,omitempty"` + + // Encryption properties for databricks workspace + Encryption *WorkspacePropertiesEncryption `json:"encryption,omitempty"` + + // The workspace's custom parameters. + Parameters *WorkspaceCustomParameters `json:"parameters,omitempty"` + + // The network access type for accessing workspace. Set value to disabled to access workspace only via private link. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // Gets or sets a value indicating whether data plane (clusters) to control plane communication happen over private endpoint. Supported values are 'AllRules' + // and 'NoAzureDatabricksRules'. + // 'NoAzureServiceRules' value is for internal use only. + RequiredNsgRules *RequiredNsgRules `json:"requiredNsgRules,omitempty"` + + // The details of Managed Identity of Storage Account + StorageAccountIdentity *ManagedIdentityConfiguration `json:"storageAccountIdentity,omitempty"` + + // The blob URI where the UI definition file is located. + UIDefinitionURI *string `json:"uiDefinitionUri,omitempty"` + + // Indicates the Object ID, PUID and Application ID of entity that last updated the workspace. + UpdatedBy *CreatedBy `json:"updatedBy,omitempty"` + + // READ-ONLY; Specifies the date and time when the workspace is created. + CreatedDateTime *time.Time `json:"createdDateTime,omitempty" azure:"ro"` + + // READ-ONLY; Private endpoint connections created on the workspace + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + + // READ-ONLY; The workspace provisioning state. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The unique identifier of the databricks workspace in databricks control plane. + WorkspaceID *string `json:"workspaceId,omitempty" azure:"ro"` + + // READ-ONLY; The workspace URL which is of the format 'adb-{workspaceId}.{random}.azuredatabricks.net' + WorkspaceURL *string `json:"workspaceUrl,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceProperties. +func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizations", w.Authorizations) + populate(objectMap, "createdBy", w.CreatedBy) + populate(objectMap, "createdDateTime", (*timeRFC3339)(w.CreatedDateTime)) + populate(objectMap, "encryption", w.Encryption) + populate(objectMap, "managedResourceGroupId", w.ManagedResourceGroupID) + populate(objectMap, "parameters", w.Parameters) + populate(objectMap, "privateEndpointConnections", w.PrivateEndpointConnections) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "publicNetworkAccess", w.PublicNetworkAccess) + populate(objectMap, "requiredNsgRules", w.RequiredNsgRules) + populate(objectMap, "storageAccountIdentity", w.StorageAccountIdentity) + populate(objectMap, "uiDefinitionUri", w.UIDefinitionURI) + populate(objectMap, "updatedBy", w.UpdatedBy) + populate(objectMap, "workspaceId", w.WorkspaceID) + populate(objectMap, "workspaceUrl", w.WorkspaceURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceProperties. +func (w *WorkspaceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "authorizations": + err = unpopulate(val, &w.Authorizations) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &w.CreatedBy) + delete(rawMsg, key) + case "createdDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + w.CreatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "encryption": + err = unpopulate(val, &w.Encryption) + delete(rawMsg, key) + case "managedResourceGroupId": + err = unpopulate(val, &w.ManagedResourceGroupID) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, &w.Parameters) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, &w.PrivateEndpointConnections) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &w.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, &w.PublicNetworkAccess) + delete(rawMsg, key) + case "requiredNsgRules": + err = unpopulate(val, &w.RequiredNsgRules) + delete(rawMsg, key) + case "storageAccountIdentity": + err = unpopulate(val, &w.StorageAccountIdentity) + delete(rawMsg, key) + case "uiDefinitionUri": + err = unpopulate(val, &w.UIDefinitionURI) + delete(rawMsg, key) + case "updatedBy": + err = unpopulate(val, &w.UpdatedBy) + delete(rawMsg, key) + case "workspaceId": + err = unpopulate(val, &w.WorkspaceID) + delete(rawMsg, key) + case "workspaceUrl": + err = unpopulate(val, &w.WorkspaceURL) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// WorkspacePropertiesEncryption - Encryption properties for databricks workspace +type WorkspacePropertiesEncryption struct { + // REQUIRED; Encryption entities definition for the workspace. + Entities *EncryptionEntitiesDefinition `json:"entities,omitempty"` +} + +// WorkspaceProviderAuthorization - The workspace provider authorization. +type WorkspaceProviderAuthorization struct { + // REQUIRED; The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the workspace resources. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; The provider's role definition identifier. This role will define all the permissions that the provider must have on the workspace's container + // resource group. This role definition cannot have + // permission to delete the resource group. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` +} + +// WorkspaceUpdate - An update to a workspace. +type WorkspaceUpdate struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceUpdate. +func (w WorkspaceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", w.Tags) + return json.Marshal(objectMap) +} + +// WorkspacesBeginCreateOrUpdateOptions contains the optional parameters for the Workspaces.BeginCreateOrUpdate method. +type WorkspacesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesBeginDeleteOptions contains the optional parameters for the Workspaces.BeginDelete method. +type WorkspacesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesBeginUpdateOptions contains the optional parameters for the Workspaces.BeginUpdate method. +type WorkspacesBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesGetOptions contains the optional parameters for the Workspaces.Get method. +type WorkspacesGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesListByResourceGroupOptions contains the optional parameters for the Workspaces.ListByResourceGroup method. +type WorkspacesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesListBySubscriptionOptions contains the optional parameters for the Workspaces.ListBySubscription method. +type WorkspacesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_operations_client.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_operations_client.go new file mode 100644 index 000000000000..8f5e5c842f57 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_operations_client.go @@ -0,0 +1,81 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *arm.Connection) *OperationsClient { + return &OperationsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// List - Lists all of the available RP operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Databricks/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_outboundnetworkdependenciesendpoints_client.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_outboundnetworkdependenciesendpoints_client.go new file mode 100644 index 000000000000..807bb2ca41d5 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_outboundnetworkdependenciesendpoints_client.go @@ -0,0 +1,102 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// OutboundNetworkDependenciesEndpointsClient contains the methods for the OutboundNetworkDependenciesEndpoints group. +// Don't use this type directly, use NewOutboundNetworkDependenciesEndpointsClient() instead. +type OutboundNetworkDependenciesEndpointsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewOutboundNetworkDependenciesEndpointsClient creates a new instance of OutboundNetworkDependenciesEndpointsClient with the specified values. +func NewOutboundNetworkDependenciesEndpointsClient(con *arm.Connection, subscriptionID string) *OutboundNetworkDependenciesEndpointsClient { + return &OutboundNetworkDependenciesEndpointsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// List - Gets the list of endpoints that VNET Injected Workspace calls Azure Databricks Control Plane. You must configure outbound access with these endpoints. +// For more information, see +// https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/udr +// If the operation fails it returns the *ErrorResponse error type. +func (client *OutboundNetworkDependenciesEndpointsClient) List(ctx context.Context, resourceGroupName string, workspaceName string, options *OutboundNetworkDependenciesEndpointsListOptions) (OutboundNetworkDependenciesEndpointsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return OutboundNetworkDependenciesEndpointsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OutboundNetworkDependenciesEndpointsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OutboundNetworkDependenciesEndpointsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OutboundNetworkDependenciesEndpointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *OutboundNetworkDependenciesEndpointsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/outboundNetworkDependenciesEndpoints" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OutboundNetworkDependenciesEndpointsClient) listHandleResponse(resp *http.Response) (OutboundNetworkDependenciesEndpointsListResponse, error) { + result := OutboundNetworkDependenciesEndpointsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OutboundEnvironmentEndpointArray); err != nil { + return OutboundNetworkDependenciesEndpointsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OutboundNetworkDependenciesEndpointsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_pagers.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_pagers.go new file mode 100644 index 000000000000..c783ce251255 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_pagers.go @@ -0,0 +1,342 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "net/http" + "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// PrivateEndpointConnectionsListPager provides operations for iterating over paged responses. +type PrivateEndpointConnectionsListPager struct { + client *PrivateEndpointConnectionsClient + current PrivateEndpointConnectionsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrivateEndpointConnectionsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrivateEndpointConnectionsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PrivateEndpointConnectionsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateEndpointConnectionsList.NextLink == nil || len(*p.current.PrivateEndpointConnectionsList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PrivateEndpointConnectionsListResponse page. +func (p *PrivateEndpointConnectionsListPager) PageResponse() PrivateEndpointConnectionsListResponse { + return p.current +} + +// PrivateLinkResourcesListPager provides operations for iterating over paged responses. +type PrivateLinkResourcesListPager struct { + client *PrivateLinkResourcesClient + current PrivateLinkResourcesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrivateLinkResourcesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrivateLinkResourcesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PrivateLinkResourcesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateLinkResourcesList.NextLink == nil || len(*p.current.PrivateLinkResourcesList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PrivateLinkResourcesListResponse page. +func (p *PrivateLinkResourcesListPager) PageResponse() PrivateLinkResourcesListResponse { + return p.current +} + +// VNetPeeringListByWorkspacePager provides operations for iterating over paged responses. +type VNetPeeringListByWorkspacePager struct { + client *VNetPeeringClient + current VNetPeeringListByWorkspaceResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, VNetPeeringListByWorkspaceResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *VNetPeeringListByWorkspacePager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *VNetPeeringListByWorkspacePager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.VirtualNetworkPeeringList.NextLink == nil || len(*p.current.VirtualNetworkPeeringList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByWorkspaceHandleError(resp) + return false + } + result, err := p.client.listByWorkspaceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current VNetPeeringListByWorkspaceResponse page. +func (p *VNetPeeringListByWorkspacePager) PageResponse() VNetPeeringListByWorkspaceResponse { + return p.current +} + +// WorkspacesListByResourceGroupPager provides operations for iterating over paged responses. +type WorkspacesListByResourceGroupPager struct { + client *WorkspacesClient + current WorkspacesListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkspacesListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkspacesListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *WorkspacesListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkspaceListResult.NextLink == nil || len(*p.current.WorkspaceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkspacesListByResourceGroupResponse page. +func (p *WorkspacesListByResourceGroupPager) PageResponse() WorkspacesListByResourceGroupResponse { + return p.current +} + +// WorkspacesListBySubscriptionPager provides operations for iterating over paged responses. +type WorkspacesListBySubscriptionPager struct { + client *WorkspacesClient + current WorkspacesListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkspacesListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkspacesListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *WorkspacesListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkspaceListResult.NextLink == nil || len(*p.current.WorkspaceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkspacesListBySubscriptionResponse page. +func (p *WorkspacesListBySubscriptionPager) PageResponse() WorkspacesListBySubscriptionResponse { + return p.current +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_pollers.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_pollers.go new file mode 100644 index 000000000000..1197e7a22405 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_pollers.go @@ -0,0 +1,317 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// PrivateEndpointConnectionsCreatePoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionsCreatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateEndpointConnectionsCreatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *PrivateEndpointConnectionsCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final PrivateEndpointConnectionsCreateResponse will be returned. +func (p *PrivateEndpointConnectionsCreatePoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionsCreateResponse, error) { + respType := PrivateEndpointConnectionsCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionsCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *PrivateEndpointConnectionsCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateEndpointConnectionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateEndpointConnectionsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *PrivateEndpointConnectionsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final PrivateEndpointConnectionsDeleteResponse will be returned. +func (p *PrivateEndpointConnectionsDeletePoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionsDeleteResponse, error) { + respType := PrivateEndpointConnectionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PrivateEndpointConnectionsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *PrivateEndpointConnectionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VNetPeeringCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type VNetPeeringCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VNetPeeringCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *VNetPeeringCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final VNetPeeringCreateOrUpdateResponse will be returned. +func (p *VNetPeeringCreateOrUpdatePoller) FinalResponse(ctx context.Context) (VNetPeeringCreateOrUpdateResponse, error) { + respType := VNetPeeringCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.VirtualNetworkPeering) + if err != nil { + return VNetPeeringCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *VNetPeeringCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VNetPeeringDeletePoller provides polling facilities until the operation reaches a terminal state. +type VNetPeeringDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VNetPeeringDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *VNetPeeringDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final VNetPeeringDeleteResponse will be returned. +func (p *VNetPeeringDeletePoller) FinalResponse(ctx context.Context) (VNetPeeringDeleteResponse, error) { + respType := VNetPeeringDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VNetPeeringDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *VNetPeeringDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkspacesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type WorkspacesCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkspacesCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *WorkspacesCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final WorkspacesCreateOrUpdateResponse will be returned. +func (p *WorkspacesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (WorkspacesCreateOrUpdateResponse, error) { + respType := WorkspacesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Workspace) + if err != nil { + return WorkspacesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *WorkspacesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkspacesDeletePoller provides polling facilities until the operation reaches a terminal state. +type WorkspacesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkspacesDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *WorkspacesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final WorkspacesDeleteResponse will be returned. +func (p *WorkspacesDeletePoller) FinalResponse(ctx context.Context) (WorkspacesDeleteResponse, error) { + respType := WorkspacesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkspacesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *WorkspacesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkspacesUpdatePoller provides polling facilities until the operation reaches a terminal state. +type WorkspacesUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkspacesUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *WorkspacesUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final WorkspacesUpdateResponse will be returned. +func (p *WorkspacesUpdatePoller) FinalResponse(ctx context.Context) (WorkspacesUpdateResponse, error) { + respType := WorkspacesUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Workspace) + if err != nil { + return WorkspacesUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *WorkspacesUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_privateendpointconnections_client.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..c1c3e8f7cfc8 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,327 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +func NewPrivateEndpointConnectionsClient(con *arm.Connection, subscriptionID string) *PrivateEndpointConnectionsClient { + return &PrivateEndpointConnectionsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// BeginCreate - Update the status of a private endpoint connection with the specified name +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) BeginCreate(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOptions) (PrivateEndpointConnectionsCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName, privateEndpointConnection, options) + if err != nil { + return PrivateEndpointConnectionsCreatePollerResponse{}, err + } + result := PrivateEndpointConnectionsCreatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateEndpointConnectionsClient.Create", "", resp, client.pl, client.createHandleError) + if err != nil { + return PrivateEndpointConnectionsCreatePollerResponse{}, err + } + result.Poller = &PrivateEndpointConnectionsCreatePoller{ + pt: pt, + } + return result, nil +} + +// Create - Update the status of a private endpoint connection with the specified name +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) create(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName, privateEndpointConnection, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, privateEndpointConnection) +} + +// createHandleError handles the Create error response. +func (client *PrivateEndpointConnectionsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Remove private endpoint connection with the specified name +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (PrivateEndpointConnectionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsDeletePollerResponse{}, err + } + result := PrivateEndpointConnectionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateEndpointConnectionsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return PrivateEndpointConnectionsDeletePollerResponse{}, err + } + result.Poller = &PrivateEndpointConnectionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Remove private endpoint connection with the specified name +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a private endpoint connection properties for a workspace +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateEndpointConnectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Response) (PrivateEndpointConnectionsGetResponse, error) { + result := PrivateEndpointConnectionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateEndpointConnectionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List private endpoint connections of the workspace +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) List(resourceGroupName string, workspaceName string, options *PrivateEndpointConnectionsListOptions) *PrivateEndpointConnectionsListPager { + return &PrivateEndpointConnectionsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + }, + advancer: func(ctx context.Context, resp PrivateEndpointConnectionsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PrivateEndpointConnectionsList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *PrivateEndpointConnectionsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/privateEndpointConnections" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *http.Response) (PrivateEndpointConnectionsListResponse, error) { + result := PrivateEndpointConnectionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnectionsList); err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateEndpointConnectionsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_privatelinkresources_client.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_privatelinkresources_client.go new file mode 100644 index 000000000000..c8bcaa084233 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_privatelinkresources_client.go @@ -0,0 +1,166 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +func NewPrivateLinkResourcesClient(con *arm.Connection, subscriptionID string) *PrivateLinkResourcesClient { + return &PrivateLinkResourcesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// Get - Get the specified private link resource for the given group id (sub-resource) +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, groupID string, options *PrivateLinkResourcesGetOptions) (PrivateLinkResourcesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, groupID, options) + if err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateLinkResourcesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, groupID string, options *PrivateLinkResourcesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/privateLinkResources/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) (PrivateLinkResourcesGetResponse, error) { + result := PrivateLinkResourcesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GroupIDInformation); err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkResourcesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List private link resources for a given workspace +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) List(resourceGroupName string, workspaceName string, options *PrivateLinkResourcesListOptions) *PrivateLinkResourcesListPager { + return &PrivateLinkResourcesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + }, + advancer: func(ctx context.Context, resp PrivateLinkResourcesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PrivateLinkResourcesList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *PrivateLinkResourcesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/privateLinkResources" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateLinkResourcesClient) listHandleResponse(resp *http.Response) (PrivateLinkResourcesListResponse, error) { + result := PrivateLinkResourcesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResourcesList); err != nil { + return PrivateLinkResourcesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateLinkResourcesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_response_types.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_response_types.go new file mode 100644 index 000000000000..2b6e999ab47e --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_response_types.go @@ -0,0 +1,482 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "net/http" + "time" + + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" +) + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// OutboundNetworkDependenciesEndpointsListResponse contains the response from method OutboundNetworkDependenciesEndpoints.List. +type OutboundNetworkDependenciesEndpointsListResponse struct { + OutboundNetworkDependenciesEndpointsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OutboundNetworkDependenciesEndpointsListResult contains the result from method OutboundNetworkDependenciesEndpoints.List. +type OutboundNetworkDependenciesEndpointsListResult struct { + // Collection of outbound network dependency endpoints + OutboundEnvironmentEndpointArray []*OutboundEnvironmentEndpoint +} + +// PrivateEndpointConnectionsCreatePollerResponse contains the response from method PrivateEndpointConnections.Create. +type PrivateEndpointConnectionsCreatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateEndpointConnectionsCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l PrivateEndpointConnectionsCreatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionsCreateResponse, error) { + respType := PrivateEndpointConnectionsCreateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.PrivateEndpointConnection) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateEndpointConnectionsCreatePollerResponse from the provided client and resume token. +func (l *PrivateEndpointConnectionsCreatePollerResponse) Resume(ctx context.Context, client *PrivateEndpointConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateEndpointConnectionsClient.Create", token, client.pl, client.createHandleError) + if err != nil { + return err + } + poller := &PrivateEndpointConnectionsCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateEndpointConnectionsCreateResponse contains the response from method PrivateEndpointConnections.Create. +type PrivateEndpointConnectionsCreateResponse struct { + PrivateEndpointConnectionsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsCreateResult contains the result from method PrivateEndpointConnections.Create. +type PrivateEndpointConnectionsCreateResult struct { + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsDeletePollerResponse contains the response from method PrivateEndpointConnections.Delete. +type PrivateEndpointConnectionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateEndpointConnectionsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l PrivateEndpointConnectionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionsDeleteResponse, error) { + respType := PrivateEndpointConnectionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateEndpointConnectionsDeletePollerResponse from the provided client and resume token. +func (l *PrivateEndpointConnectionsDeletePollerResponse) Resume(ctx context.Context, client *PrivateEndpointConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateEndpointConnectionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &PrivateEndpointConnectionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateEndpointConnectionsDeleteResponse contains the response from method PrivateEndpointConnections.Delete. +type PrivateEndpointConnectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResponse contains the response from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResponse struct { + PrivateEndpointConnectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResult contains the result from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResult struct { + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsListResponse contains the response from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResponse struct { + PrivateEndpointConnectionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsListResult contains the result from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResult struct { + PrivateEndpointConnectionsList +} + +// PrivateLinkResourcesGetResponse contains the response from method PrivateLinkResources.Get. +type PrivateLinkResourcesGetResponse struct { + PrivateLinkResourcesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesGetResult contains the result from method PrivateLinkResources.Get. +type PrivateLinkResourcesGetResult struct { + GroupIDInformation +} + +// PrivateLinkResourcesListResponse contains the response from method PrivateLinkResources.List. +type PrivateLinkResourcesListResponse struct { + PrivateLinkResourcesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesListResult contains the result from method PrivateLinkResources.List. +type PrivateLinkResourcesListResult struct { + PrivateLinkResourcesList +} + +// VNetPeeringCreateOrUpdatePollerResponse contains the response from method VNetPeering.CreateOrUpdate. +type VNetPeeringCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *VNetPeeringCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l VNetPeeringCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VNetPeeringCreateOrUpdateResponse, error) { + respType := VNetPeeringCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.VirtualNetworkPeering) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VNetPeeringCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *VNetPeeringCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *VNetPeeringClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VNetPeeringClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &VNetPeeringCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VNetPeeringCreateOrUpdateResponse contains the response from method VNetPeering.CreateOrUpdate. +type VNetPeeringCreateOrUpdateResponse struct { + VNetPeeringCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VNetPeeringCreateOrUpdateResult contains the result from method VNetPeering.CreateOrUpdate. +type VNetPeeringCreateOrUpdateResult struct { + VirtualNetworkPeering +} + +// VNetPeeringDeletePollerResponse contains the response from method VNetPeering.Delete. +type VNetPeeringDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *VNetPeeringDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l VNetPeeringDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VNetPeeringDeleteResponse, error) { + respType := VNetPeeringDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VNetPeeringDeletePollerResponse from the provided client and resume token. +func (l *VNetPeeringDeletePollerResponse) Resume(ctx context.Context, client *VNetPeeringClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VNetPeeringClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &VNetPeeringDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VNetPeeringDeleteResponse contains the response from method VNetPeering.Delete. +type VNetPeeringDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VNetPeeringGetResponse contains the response from method VNetPeering.Get. +type VNetPeeringGetResponse struct { + VNetPeeringGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VNetPeeringGetResult contains the result from method VNetPeering.Get. +type VNetPeeringGetResult struct { + VirtualNetworkPeering +} + +// VNetPeeringListByWorkspaceResponse contains the response from method VNetPeering.ListByWorkspace. +type VNetPeeringListByWorkspaceResponse struct { + VNetPeeringListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VNetPeeringListByWorkspaceResult contains the result from method VNetPeering.ListByWorkspace. +type VNetPeeringListByWorkspaceResult struct { + VirtualNetworkPeeringList +} + +// WorkspacesCreateOrUpdatePollerResponse contains the response from method Workspaces.CreateOrUpdate. +type WorkspacesCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkspacesCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l WorkspacesCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkspacesCreateOrUpdateResponse, error) { + respType := WorkspacesCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Workspace) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkspacesCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *WorkspacesCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *WorkspacesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkspacesClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &WorkspacesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkspacesCreateOrUpdateResponse contains the response from method Workspaces.CreateOrUpdate. +type WorkspacesCreateOrUpdateResponse struct { + WorkspacesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesCreateOrUpdateResult contains the result from method Workspaces.CreateOrUpdate. +type WorkspacesCreateOrUpdateResult struct { + Workspace +} + +// WorkspacesDeletePollerResponse contains the response from method Workspaces.Delete. +type WorkspacesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkspacesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l WorkspacesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkspacesDeleteResponse, error) { + respType := WorkspacesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkspacesDeletePollerResponse from the provided client and resume token. +func (l *WorkspacesDeletePollerResponse) Resume(ctx context.Context, client *WorkspacesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkspacesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &WorkspacesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkspacesDeleteResponse contains the response from method Workspaces.Delete. +type WorkspacesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesGetResponse contains the response from method Workspaces.Get. +type WorkspacesGetResponse struct { + WorkspacesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesGetResult contains the result from method Workspaces.Get. +type WorkspacesGetResult struct { + Workspace +} + +// WorkspacesListByResourceGroupResponse contains the response from method Workspaces.ListByResourceGroup. +type WorkspacesListByResourceGroupResponse struct { + WorkspacesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesListByResourceGroupResult contains the result from method Workspaces.ListByResourceGroup. +type WorkspacesListByResourceGroupResult struct { + WorkspaceListResult +} + +// WorkspacesListBySubscriptionResponse contains the response from method Workspaces.ListBySubscription. +type WorkspacesListBySubscriptionResponse struct { + WorkspacesListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesListBySubscriptionResult contains the result from method Workspaces.ListBySubscription. +type WorkspacesListBySubscriptionResult struct { + WorkspaceListResult +} + +// WorkspacesUpdatePollerResponse contains the response from method Workspaces.Update. +type WorkspacesUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkspacesUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l WorkspacesUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkspacesUpdateResponse, error) { + respType := WorkspacesUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Workspace) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkspacesUpdatePollerResponse from the provided client and resume token. +func (l *WorkspacesUpdatePollerResponse) Resume(ctx context.Context, client *WorkspacesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkspacesClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &WorkspacesUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkspacesUpdateResponse contains the response from method Workspaces.Update. +type WorkspacesUpdateResponse struct { + WorkspacesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesUpdateResult contains the result from method Workspaces.Update. +type WorkspacesUpdateResult struct { + Workspace +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_time_rfc3339.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..436b9c34723f --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_time_rfc3339.go @@ -0,0 +1,58 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_vnetpeering_client.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_vnetpeering_client.go new file mode 100644 index 000000000000..a0132e0324b9 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_vnetpeering_client.go @@ -0,0 +1,327 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// VNetPeeringClient contains the methods for the VNetPeering group. +// Don't use this type directly, use NewVNetPeeringClient() instead. +type VNetPeeringClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVNetPeeringClient creates a new instance of VNetPeeringClient with the specified values. +func NewVNetPeeringClient(con *arm.Connection, subscriptionID string) *VNetPeeringClient { + return &VNetPeeringClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates vNet Peering for workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VNetPeeringClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, options *VNetPeeringBeginCreateOrUpdateOptions) (VNetPeeringCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, workspaceName, peeringName, virtualNetworkPeeringParameters, options) + if err != nil { + return VNetPeeringCreateOrUpdatePollerResponse{}, err + } + result := VNetPeeringCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VNetPeeringClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return VNetPeeringCreateOrUpdatePollerResponse{}, err + } + result.Poller = &VNetPeeringCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates vNet Peering for workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VNetPeeringClient) createOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, options *VNetPeeringBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, peeringName, virtualNetworkPeeringParameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VNetPeeringClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, options *VNetPeeringBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/virtualNetworkPeerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, virtualNetworkPeeringParameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *VNetPeeringClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Deletes the workspace vNetPeering. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VNetPeeringClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, options *VNetPeeringBeginDeleteOptions) (VNetPeeringDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, peeringName, options) + if err != nil { + return VNetPeeringDeletePollerResponse{}, err + } + result := VNetPeeringDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VNetPeeringClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return VNetPeeringDeletePollerResponse{}, err + } + result.Poller = &VNetPeeringDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the workspace vNetPeering. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VNetPeeringClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, options *VNetPeeringBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, peeringName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VNetPeeringClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, options *VNetPeeringBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/virtualNetworkPeerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *VNetPeeringClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the workspace vNet Peering. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VNetPeeringClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, options *VNetPeeringGetOptions) (VNetPeeringGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, peeringName, options) + if err != nil { + return VNetPeeringGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VNetPeeringGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VNetPeeringGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VNetPeeringClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, peeringName string, options *VNetPeeringGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/virtualNetworkPeerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VNetPeeringClient) getHandleResponse(resp *http.Response) (VNetPeeringGetResponse, error) { + result := VNetPeeringGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworkPeering); err != nil { + return VNetPeeringGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *VNetPeeringClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByWorkspace - Lists the workspace vNet Peerings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VNetPeeringClient) ListByWorkspace(resourceGroupName string, workspaceName string, options *VNetPeeringListByWorkspaceOptions) *VNetPeeringListByWorkspacePager { + return &VNetPeeringListByWorkspacePager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + }, + advancer: func(ctx context.Context, resp VNetPeeringListByWorkspaceResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.VirtualNetworkPeeringList.NextLink) + }, + } +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *VNetPeeringClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *VNetPeeringListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/virtualNetworkPeerings" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *VNetPeeringClient) listByWorkspaceHandleResponse(resp *http.Response) (VNetPeeringListByWorkspaceResponse, error) { + result := VNetPeeringListByWorkspaceResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworkPeeringList); err != nil { + return VNetPeeringListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *VNetPeeringClient) listByWorkspaceHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/databricks/armdatabricks/zz_generated_workspaces_client.go b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_workspaces_client.go new file mode 100644 index 000000000000..e8e53422e820 --- /dev/null +++ b/sdk/resourcemanager/databricks/armdatabricks/zz_generated_workspaces_client.go @@ -0,0 +1,441 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdatabricks + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// WorkspacesClient contains the methods for the Workspaces group. +// Don't use this type directly, use NewWorkspacesClient() instead. +type WorkspacesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewWorkspacesClient creates a new instance of WorkspacesClient with the specified values. +func NewWorkspacesClient(con *arm.Connection, subscriptionID string) *WorkspacesClient { + return &WorkspacesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates a new workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (WorkspacesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return WorkspacesCreateOrUpdatePollerResponse{}, err + } + result := WorkspacesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkspacesClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return WorkspacesCreateOrUpdatePollerResponse{}, err + } + result.Poller = &WorkspacesCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates a new workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) createOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *WorkspacesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Deletes the workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (WorkspacesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return WorkspacesDeletePollerResponse{}, err + } + result := WorkspacesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkspacesClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return WorkspacesDeletePollerResponse{}, err + } + result.Poller = &WorkspacesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *WorkspacesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesGetOptions) (WorkspacesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return WorkspacesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkspacesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkspacesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacesClient) getHandleResponse(resp *http.Response) (WorkspacesGetResponse, error) { + result := WorkspacesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *WorkspacesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Gets all the workspaces within a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) ListByResourceGroup(resourceGroupName string, options *WorkspacesListByResourceGroupOptions) *WorkspacesListByResourceGroupPager { + return &WorkspacesListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp WorkspacesListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkspaceListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WorkspacesListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *http.Response) (WorkspacesListByResourceGroupResponse, error) { + result := WorkspacesListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil { + return WorkspacesListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *WorkspacesClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Gets all the workspaces within a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) ListBySubscription(options *WorkspacesListBySubscriptionOptions) *WorkspacesListBySubscriptionPager { + return &WorkspacesListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp WorkspacesListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkspaceListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *WorkspacesClient) listBySubscriptionCreateRequest(ctx context.Context, options *WorkspacesListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Databricks/workspaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *WorkspacesClient) listBySubscriptionHandleResponse(resp *http.Response) (WorkspacesListBySubscriptionResponse, error) { + result := WorkspacesListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil { + return WorkspacesListBySubscriptionResponse{}, err + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *WorkspacesClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Updates a workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) BeginUpdate(ctx context.Context, resourceGroupName string, workspaceName string, parameters WorkspaceUpdate, options *WorkspacesBeginUpdateOptions) (WorkspacesUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return WorkspacesUpdatePollerResponse{}, err + } + result := WorkspacesUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkspacesClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return WorkspacesUpdatePollerResponse{}, err + } + result.Poller = &WorkspacesUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates a workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) update(ctx context.Context, resourceGroupName string, workspaceName string, parameters WorkspaceUpdate, options *WorkspacesBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *WorkspacesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, parameters WorkspaceUpdate, options *WorkspacesBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleError handles the Update error response. +func (client *WorkspacesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +}