From 563c897838e2353d9371832b5a73d17a54912234 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 29 Nov 2021 02:46:06 +0000 Subject: [PATCH] CodeGen from PR 16886 in Azure/azure-rest-api-specs Track2 modify readme.go.md 3 (#16886) * Track2 modify readme.go.md * directive modelerfour.lenient-model-deduplication=true --- .../kusto/armkusto/CHANGELOG.md | 3 + .../kusto/armkusto/LICENSE.txt | 21 + sdk/resourcemanager/kusto/armkusto/README.md | 75 + .../kusto/armkusto/autorest.md | 13 + sdk/resourcemanager/kusto/armkusto/build.go | 7 + sdk/resourcemanager/kusto/armkusto/ci.yml | 27 + sdk/resourcemanager/kusto/armkusto/go.mod | 8 + sdk/resourcemanager/kusto/armkusto/go.sum | 37 + .../kusto/armkusto/go_mod_tidy_hack.go | 13 + ...d_attacheddatabaseconfigurations_client.go | 402 +++ ...ated_clusterprincipalassignments_client.go | 402 +++ .../armkusto/zz_generated_clusters_client.go | 1294 ++++++++ .../kusto/armkusto/zz_generated_constants.go | 767 +++++ ...ted_databaseprincipalassignments_client.go | 422 +++ .../armkusto/zz_generated_databases_client.go | 689 +++++ .../zz_generated_dataconnections_client.go | 586 ++++ ...enerated_managedprivateendpoints_client.go | 482 +++ .../kusto/armkusto/zz_generated_models.go | 2709 +++++++++++++++++ .../zz_generated_operations_client.go | 89 + .../zz_generated_operationsresults_client.go | 108 + .../kusto/armkusto/zz_generated_pagers.go | 125 + .../kusto/armkusto/zz_generated_pollers.go | 1305 ++++++++ .../zz_generated_polymorphic_helpers.go | 129 + ...rated_privateendpointconnections_client.go | 337 ++ ...z_generated_privatelinkresources_client.go | 177 ++ .../armkusto/zz_generated_response_types.go | 2020 ++++++++++++ .../armkusto/zz_generated_scripts_client.go | 506 +++ .../armkusto/zz_generated_time_rfc3339.go | 85 + 28 files changed, 12838 insertions(+) create mode 100644 sdk/resourcemanager/kusto/armkusto/CHANGELOG.md create mode 100644 sdk/resourcemanager/kusto/armkusto/LICENSE.txt create mode 100644 sdk/resourcemanager/kusto/armkusto/README.md create mode 100644 sdk/resourcemanager/kusto/armkusto/autorest.md create mode 100644 sdk/resourcemanager/kusto/armkusto/build.go create mode 100644 sdk/resourcemanager/kusto/armkusto/ci.yml create mode 100644 sdk/resourcemanager/kusto/armkusto/go.mod create mode 100644 sdk/resourcemanager/kusto/armkusto/go.sum create mode 100644 sdk/resourcemanager/kusto/armkusto/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_attacheddatabaseconfigurations_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_clusterprincipalassignments_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_clusters_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_constants.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_databaseprincipalassignments_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_databases_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_dataconnections_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_managedprivateendpoints_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_models.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_operationsresults_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_polymorphic_helpers.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_privateendpointconnections_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_privatelinkresources_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_scripts_client.go create mode 100644 sdk/resourcemanager/kusto/armkusto/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md b/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md new file mode 100644 index 000000000000..6e36ac184e16 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-29) diff --git a/sdk/resourcemanager/kusto/armkusto/LICENSE.txt b/sdk/resourcemanager/kusto/armkusto/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/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/kusto/armkusto/README.md b/sdk/resourcemanager/kusto/armkusto/README.md new file mode 100644 index 000000000000..daf9c13f6e74 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/README.md @@ -0,0 +1,75 @@ +# Azure Kusto Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto) + +The `armkusto` module provides operations for working with Azure Kusto. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/kusto/armkusto) + +# 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 Kusto module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kusto. 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). + +## Clients + +Azure Kusto 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 credential. + +```go +client := armkusto.NewScriptsClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, 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). + +```go +options = arm.ClientOptions{ + Host: arm.AzureChina, +} +client := armkusto.NewScriptsClient(, cred, &options) +``` + +## 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 `Kusto` 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/kusto/armkusto/autorest.md b/sdk/resourcemanager/kusto/armkusto/autorest.md new file mode 100644 index 000000000000..366d8a40b5d1 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/azure-kusto/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/azure-kusto/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/kusto/armkusto/build.go b/sdk/resourcemanager/kusto/armkusto/build.go new file mode 100644 index 000000000000..76000cab1119 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/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/kusto/armkusto + +package armkusto diff --git a/sdk/resourcemanager/kusto/armkusto/ci.yml b/sdk/resourcemanager/kusto/armkusto/ci.yml new file mode 100644 index 000000000000..1aace0e105f6 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/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/kusto/armkusto/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/kusto/armkusto/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/kusto/armkusto' diff --git a/sdk/resourcemanager/kusto/armkusto/go.mod b/sdk/resourcemanager/kusto/armkusto/go.mod new file mode 100644 index 000000000000..563a44a97dd3 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.4.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/kusto/armkusto/go.sum b/sdk/resourcemanager/kusto/armkusto/go.sum new file mode 100644 index 000000000000..aa6cc05eede2 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +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/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +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.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +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.1/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 h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/kusto/armkusto/go_mod_tidy_hack.go b/sdk/resourcemanager/kusto/armkusto/go_mod_tidy_hack.go new file mode 100644 index 000000000000..287c01881895 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/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 armkusto + +// 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/kusto/armkusto/zz_generated_attacheddatabaseconfigurations_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_attacheddatabaseconfigurations_client.go new file mode 100644 index 000000000000..9e1a1bf41597 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_attacheddatabaseconfigurations_client.go @@ -0,0 +1,402 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// AttachedDatabaseConfigurationsClient contains the methods for the AttachedDatabaseConfigurations group. +// Don't use this type directly, use NewAttachedDatabaseConfigurationsClient() instead. +type AttachedDatabaseConfigurationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAttachedDatabaseConfigurationsClient creates a new instance of AttachedDatabaseConfigurationsClient with the specified values. +func NewAttachedDatabaseConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AttachedDatabaseConfigurationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AttachedDatabaseConfigurationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the attached database configuration resource name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName AttachedDatabaseConfigurationsCheckNameRequest, options *AttachedDatabaseConfigurationsCheckNameAvailabilityOptions) (AttachedDatabaseConfigurationsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, resourceName, options) + if err != nil { + return AttachedDatabaseConfigurationsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedDatabaseConfigurationsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedDatabaseConfigurationsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *AttachedDatabaseConfigurationsClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, resourceName AttachedDatabaseConfigurationsCheckNameRequest, options *AttachedDatabaseConfigurationsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resourceName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *AttachedDatabaseConfigurationsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (AttachedDatabaseConfigurationsCheckNameAvailabilityResponse, error) { + result := AttachedDatabaseConfigurationsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return AttachedDatabaseConfigurationsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *AttachedDatabaseConfigurationsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Creates or updates an attached database configuration. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, parameters AttachedDatabaseConfiguration, options *AttachedDatabaseConfigurationsBeginCreateOrUpdateOptions) (AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, attachedDatabaseConfigurationName, parameters, options) + if err != nil { + return AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse{}, err + } + result := AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("AttachedDatabaseConfigurationsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &AttachedDatabaseConfigurationsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates an attached database configuration. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, parameters AttachedDatabaseConfiguration, options *AttachedDatabaseConfigurationsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, attachedDatabaseConfigurationName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AttachedDatabaseConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, parameters AttachedDatabaseConfiguration, options *AttachedDatabaseConfigurationsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if attachedDatabaseConfigurationName == "" { + return nil, errors.New("parameter attachedDatabaseConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedDatabaseConfigurationName}", url.PathEscape(attachedDatabaseConfigurationName)) + 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-08-27") + 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 *AttachedDatabaseConfigurationsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 attached database configuration with the given name. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsBeginDeleteOptions) (AttachedDatabaseConfigurationsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, attachedDatabaseConfigurationName, options) + if err != nil { + return AttachedDatabaseConfigurationsDeletePollerResponse{}, err + } + result := AttachedDatabaseConfigurationsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("AttachedDatabaseConfigurationsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return AttachedDatabaseConfigurationsDeletePollerResponse{}, err + } + result.Poller = &AttachedDatabaseConfigurationsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the attached database configuration with the given name. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, attachedDatabaseConfigurationName, 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 *AttachedDatabaseConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if attachedDatabaseConfigurationName == "" { + return nil, errors.New("parameter attachedDatabaseConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedDatabaseConfigurationName}", url.PathEscape(attachedDatabaseConfigurationName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AttachedDatabaseConfigurationsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Returns an attached database configuration. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsGetOptions) (AttachedDatabaseConfigurationsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, attachedDatabaseConfigurationName, options) + if err != nil { + return AttachedDatabaseConfigurationsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedDatabaseConfigurationsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedDatabaseConfigurationsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AttachedDatabaseConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if attachedDatabaseConfigurationName == "" { + return nil, errors.New("parameter attachedDatabaseConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedDatabaseConfigurationName}", url.PathEscape(attachedDatabaseConfigurationName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AttachedDatabaseConfigurationsClient) getHandleResponse(resp *http.Response) (AttachedDatabaseConfigurationsGetResponse, error) { + result := AttachedDatabaseConfigurationsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AttachedDatabaseConfiguration); err != nil { + return AttachedDatabaseConfigurationsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AttachedDatabaseConfigurationsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListByCluster - Returns the list of attached database configurations of the given Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *AttachedDatabaseConfigurationsClient) ListByCluster(ctx context.Context, resourceGroupName string, clusterName string, options *AttachedDatabaseConfigurationsListByClusterOptions) (AttachedDatabaseConfigurationsListByClusterResponse, error) { + req, err := client.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return AttachedDatabaseConfigurationsListByClusterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedDatabaseConfigurationsListByClusterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedDatabaseConfigurationsListByClusterResponse{}, client.listByClusterHandleError(resp) + } + return client.listByClusterHandleResponse(resp) +} + +// listByClusterCreateRequest creates the ListByCluster request. +func (client *AttachedDatabaseConfigurationsClient) listByClusterCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *AttachedDatabaseConfigurationsListByClusterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByClusterHandleResponse handles the ListByCluster response. +func (client *AttachedDatabaseConfigurationsClient) listByClusterHandleResponse(resp *http.Response) (AttachedDatabaseConfigurationsListByClusterResponse, error) { + result := AttachedDatabaseConfigurationsListByClusterResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AttachedDatabaseConfigurationListResult); err != nil { + return AttachedDatabaseConfigurationsListByClusterResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByClusterHandleError handles the ListByCluster error response. +func (client *AttachedDatabaseConfigurationsClient) listByClusterHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_clusterprincipalassignments_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_clusterprincipalassignments_client.go new file mode 100644 index 000000000000..e974ad1d42e5 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_clusterprincipalassignments_client.go @@ -0,0 +1,402 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// ClusterPrincipalAssignmentsClient contains the methods for the ClusterPrincipalAssignments group. +// Don't use this type directly, use NewClusterPrincipalAssignmentsClient() instead. +type ClusterPrincipalAssignmentsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewClusterPrincipalAssignmentsClient creates a new instance of ClusterPrincipalAssignmentsClient with the specified values. +func NewClusterPrincipalAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ClusterPrincipalAssignmentsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ClusterPrincipalAssignmentsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the principal assignment name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName ClusterPrincipalAssignmentCheckNameRequest, options *ClusterPrincipalAssignmentsCheckNameAvailabilityOptions) (ClusterPrincipalAssignmentsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, principalAssignmentName, options) + if err != nil { + return ClusterPrincipalAssignmentsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClusterPrincipalAssignmentsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClusterPrincipalAssignmentsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *ClusterPrincipalAssignmentsClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName ClusterPrincipalAssignmentCheckNameRequest, options *ClusterPrincipalAssignmentsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, principalAssignmentName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *ClusterPrincipalAssignmentsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (ClusterPrincipalAssignmentsCheckNameAvailabilityResponse, error) { + result := ClusterPrincipalAssignmentsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return ClusterPrincipalAssignmentsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *ClusterPrincipalAssignmentsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Create a Kusto cluster principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, parameters ClusterPrincipalAssignment, options *ClusterPrincipalAssignmentsBeginCreateOrUpdateOptions) (ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, principalAssignmentName, parameters, options) + if err != nil { + return ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse{}, err + } + result := ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClusterPrincipalAssignmentsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ClusterPrincipalAssignmentsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create a Kusto cluster principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, parameters ClusterPrincipalAssignment, options *ClusterPrincipalAssignmentsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, principalAssignmentName, 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 *ClusterPrincipalAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, parameters ClusterPrincipalAssignment, options *ClusterPrincipalAssignmentsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if principalAssignmentName == "" { + return nil, errors.New("parameter principalAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{principalAssignmentName}", url.PathEscape(principalAssignmentName)) + 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-08-27") + 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 *ClusterPrincipalAssignmentsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto cluster principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsBeginDeleteOptions) (ClusterPrincipalAssignmentsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, principalAssignmentName, options) + if err != nil { + return ClusterPrincipalAssignmentsDeletePollerResponse{}, err + } + result := ClusterPrincipalAssignmentsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClusterPrincipalAssignmentsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return ClusterPrincipalAssignmentsDeletePollerResponse{}, err + } + result.Poller = &ClusterPrincipalAssignmentsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a Kusto cluster principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, principalAssignmentName, 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 *ClusterPrincipalAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if principalAssignmentName == "" { + return nil, errors.New("parameter principalAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{principalAssignmentName}", url.PathEscape(principalAssignmentName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ClusterPrincipalAssignmentsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto cluster principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsGetOptions) (ClusterPrincipalAssignmentsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, principalAssignmentName, options) + if err != nil { + return ClusterPrincipalAssignmentsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClusterPrincipalAssignmentsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClusterPrincipalAssignmentsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ClusterPrincipalAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if principalAssignmentName == "" { + return nil, errors.New("parameter principalAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{principalAssignmentName}", url.PathEscape(principalAssignmentName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ClusterPrincipalAssignmentsClient) getHandleResponse(resp *http.Response) (ClusterPrincipalAssignmentsGetResponse, error) { + result := ClusterPrincipalAssignmentsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClusterPrincipalAssignment); err != nil { + return ClusterPrincipalAssignmentsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ClusterPrincipalAssignmentsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Lists all Kusto cluster principalAssignments. +// If the operation fails it returns the *CloudError error type. +func (client *ClusterPrincipalAssignmentsClient) List(ctx context.Context, resourceGroupName string, clusterName string, options *ClusterPrincipalAssignmentsListOptions) (ClusterPrincipalAssignmentsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClusterPrincipalAssignmentsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClusterPrincipalAssignmentsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClusterPrincipalAssignmentsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *ClusterPrincipalAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClusterPrincipalAssignmentsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ClusterPrincipalAssignmentsClient) listHandleResponse(resp *http.Response) (ClusterPrincipalAssignmentsListResponse, error) { + result := ClusterPrincipalAssignmentsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClusterPrincipalAssignmentListResult); err != nil { + return ClusterPrincipalAssignmentsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ClusterPrincipalAssignmentsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_clusters_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_clusters_client.go new file mode 100644 index 000000000000..089a27c74723 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_clusters_client.go @@ -0,0 +1,1294 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// ClustersClient contains the methods for the Clusters group. +// Don't use this type directly, use NewClustersClient() instead. +type ClustersClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewClustersClient creates a new instance of ClustersClient with the specified values. +func NewClustersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ClustersClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ClustersClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginAddLanguageExtensions - Add a list of language extensions that can run within KQL queries. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginAddLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToAdd LanguageExtensionsList, options *ClustersBeginAddLanguageExtensionsOptions) (ClustersAddLanguageExtensionsPollerResponse, error) { + resp, err := client.addLanguageExtensions(ctx, resourceGroupName, clusterName, languageExtensionsToAdd, options) + if err != nil { + return ClustersAddLanguageExtensionsPollerResponse{}, err + } + result := ClustersAddLanguageExtensionsPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.AddLanguageExtensions", "", resp, client.pl, client.addLanguageExtensionsHandleError) + if err != nil { + return ClustersAddLanguageExtensionsPollerResponse{}, err + } + result.Poller = &ClustersAddLanguageExtensionsPoller{ + pt: pt, + } + return result, nil +} + +// AddLanguageExtensions - Add a list of language extensions that can run within KQL queries. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) addLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToAdd LanguageExtensionsList, options *ClustersBeginAddLanguageExtensionsOptions) (*http.Response, error) { + req, err := client.addLanguageExtensionsCreateRequest(ctx, resourceGroupName, clusterName, languageExtensionsToAdd, 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.addLanguageExtensionsHandleError(resp) + } + return resp, nil +} + +// addLanguageExtensionsCreateRequest creates the AddLanguageExtensions request. +func (client *ClustersClient) addLanguageExtensionsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToAdd LanguageExtensionsList, options *ClustersBeginAddLanguageExtensionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, languageExtensionsToAdd) +} + +// addLanguageExtensionsHandleError handles the AddLanguageExtensions error response. +func (client *ClustersClient) addLanguageExtensionsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// CheckNameAvailability - Checks that the cluster name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) CheckNameAvailability(ctx context.Context, location string, clusterName ClusterCheckNameRequest, options *ClustersCheckNameAvailabilityOptions) (ClustersCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, location, clusterName, options) + if err != nil { + return ClustersCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *ClustersClient) checkNameAvailabilityCreateRequest(ctx context.Context, location string, clusterName ClusterCheckNameRequest, options *ClustersCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, clusterName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *ClustersClient) checkNameAvailabilityHandleResponse(resp *http.Response) (ClustersCheckNameAvailabilityResponse, error) { + result := ClustersCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return ClustersCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *ClustersClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Create or update a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (ClustersCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, parameters, options) + if err != nil { + return ClustersCreateOrUpdatePollerResponse{}, err + } + result := ClustersCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ClustersCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ClustersCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, 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 *ClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header.Set("If-Match", *options.IfMatch) + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header.Set("If-None-Match", *options.IfNoneMatch) + } + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ClustersClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (ClustersDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersDeletePollerResponse{}, err + } + result := ClustersDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return ClustersDeletePollerResponse{}, err + } + result.Poller = &ClustersDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, 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 *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ClustersClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginDetachFollowerDatabases - Detaches all followers of a database owned by this cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginDetachFollowerDatabases(ctx context.Context, resourceGroupName string, clusterName string, followerDatabaseToRemove FollowerDatabaseDefinition, options *ClustersBeginDetachFollowerDatabasesOptions) (ClustersDetachFollowerDatabasesPollerResponse, error) { + resp, err := client.detachFollowerDatabases(ctx, resourceGroupName, clusterName, followerDatabaseToRemove, options) + if err != nil { + return ClustersDetachFollowerDatabasesPollerResponse{}, err + } + result := ClustersDetachFollowerDatabasesPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.DetachFollowerDatabases", "", resp, client.pl, client.detachFollowerDatabasesHandleError) + if err != nil { + return ClustersDetachFollowerDatabasesPollerResponse{}, err + } + result.Poller = &ClustersDetachFollowerDatabasesPoller{ + pt: pt, + } + return result, nil +} + +// DetachFollowerDatabases - Detaches all followers of a database owned by this cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) detachFollowerDatabases(ctx context.Context, resourceGroupName string, clusterName string, followerDatabaseToRemove FollowerDatabaseDefinition, options *ClustersBeginDetachFollowerDatabasesOptions) (*http.Response, error) { + req, err := client.detachFollowerDatabasesCreateRequest(ctx, resourceGroupName, clusterName, followerDatabaseToRemove, 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.detachFollowerDatabasesHandleError(resp) + } + return resp, nil +} + +// detachFollowerDatabasesCreateRequest creates the DetachFollowerDatabases request. +func (client *ClustersClient) detachFollowerDatabasesCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, followerDatabaseToRemove FollowerDatabaseDefinition, options *ClustersBeginDetachFollowerDatabasesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, followerDatabaseToRemove) +} + +// detachFollowerDatabasesHandleError handles the DetachFollowerDatabases error response. +func (client *ClustersClient) detachFollowerDatabasesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginDiagnoseVirtualNetwork - Diagnoses network connectivity status for external resources on which the service is dependent on. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginDiagnoseVirtualNetwork(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDiagnoseVirtualNetworkOptions) (ClustersDiagnoseVirtualNetworkPollerResponse, error) { + resp, err := client.diagnoseVirtualNetwork(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersDiagnoseVirtualNetworkPollerResponse{}, err + } + result := ClustersDiagnoseVirtualNetworkPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.DiagnoseVirtualNetwork", "location", resp, client.pl, client.diagnoseVirtualNetworkHandleError) + if err != nil { + return ClustersDiagnoseVirtualNetworkPollerResponse{}, err + } + result.Poller = &ClustersDiagnoseVirtualNetworkPoller{ + pt: pt, + } + return result, nil +} + +// DiagnoseVirtualNetwork - Diagnoses network connectivity status for external resources on which the service is dependent on. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) diagnoseVirtualNetwork(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDiagnoseVirtualNetworkOptions) (*http.Response, error) { + req, err := client.diagnoseVirtualNetworkCreateRequest(ctx, resourceGroupName, clusterName, 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.diagnoseVirtualNetworkHandleError(resp) + } + return resp, nil +} + +// diagnoseVirtualNetworkCreateRequest creates the DiagnoseVirtualNetwork request. +func (client *ClustersClient) diagnoseVirtualNetworkCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDiagnoseVirtualNetworkOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// diagnoseVirtualNetworkHandleError handles the DiagnoseVirtualNetwork error response. +func (client *ClustersClient) diagnoseVirtualNetworkHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (ClustersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ClustersClient) getHandleResponse(resp *http.Response) (ClustersGetResponse, error) { + result := ClustersGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Cluster); err != nil { + return ClustersGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ClustersClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Lists all Kusto clusters within a subscription. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) List(ctx context.Context, options *ClustersListOptions) (ClustersListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return ClustersListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *ClustersClient) listCreateRequest(ctx context.Context, options *ClustersListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters" + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ClustersClient) listHandleResponse(resp *http.Response) (ClustersListResponse, error) { + result := ClustersListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClusterListResult); err != nil { + return ClustersListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ClustersClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Lists all Kusto clusters within a resource group. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (ClustersListByResourceGroupResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return ClustersListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersListByResourceGroupResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters" + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ClustersListByResourceGroupResponse, error) { + result := ClustersListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClusterListResult); err != nil { + return ClustersListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ClustersClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListFollowerDatabases - Returns a list of databases that are owned by this cluster and were followed by another cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) ListFollowerDatabases(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListFollowerDatabasesOptions) (ClustersListFollowerDatabasesResponse, error) { + req, err := client.listFollowerDatabasesCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersListFollowerDatabasesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersListFollowerDatabasesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersListFollowerDatabasesResponse{}, client.listFollowerDatabasesHandleError(resp) + } + return client.listFollowerDatabasesHandleResponse(resp) +} + +// listFollowerDatabasesCreateRequest creates the ListFollowerDatabases request. +func (client *ClustersClient) listFollowerDatabasesCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListFollowerDatabasesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listFollowerDatabasesHandleResponse handles the ListFollowerDatabases response. +func (client *ClustersClient) listFollowerDatabasesHandleResponse(resp *http.Response) (ClustersListFollowerDatabasesResponse, error) { + result := ClustersListFollowerDatabasesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.FollowerDatabaseListResult); err != nil { + return ClustersListFollowerDatabasesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listFollowerDatabasesHandleError handles the ListFollowerDatabases error response. +func (client *ClustersClient) listFollowerDatabasesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListLanguageExtensions - Returns a list of language extensions that can run within KQL queries. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) ListLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListLanguageExtensionsOptions) (ClustersListLanguageExtensionsResponse, error) { + req, err := client.listLanguageExtensionsCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersListLanguageExtensionsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersListLanguageExtensionsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersListLanguageExtensionsResponse{}, client.listLanguageExtensionsHandleError(resp) + } + return client.listLanguageExtensionsHandleResponse(resp) +} + +// listLanguageExtensionsCreateRequest creates the ListLanguageExtensions request. +func (client *ClustersClient) listLanguageExtensionsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListLanguageExtensionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listLanguageExtensionsHandleResponse handles the ListLanguageExtensions response. +func (client *ClustersClient) listLanguageExtensionsHandleResponse(resp *http.Response) (ClustersListLanguageExtensionsResponse, error) { + result := ClustersListLanguageExtensionsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LanguageExtensionsList); err != nil { + return ClustersListLanguageExtensionsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listLanguageExtensionsHandleError handles the ListLanguageExtensions error response. +func (client *ClustersClient) listLanguageExtensionsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListOutboundNetworkDependenciesEndpoints - Gets the network endpoints of all outbound dependencies of a Kusto cluster +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) ListOutboundNetworkDependenciesEndpoints(resourceGroupName string, clusterName string, options *ClustersListOutboundNetworkDependenciesEndpointsOptions) *ClustersListOutboundNetworkDependenciesEndpointsPager { + return &ClustersListOutboundNetworkDependenciesEndpointsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listOutboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, clusterName, options) + }, + advancer: func(ctx context.Context, resp ClustersListOutboundNetworkDependenciesEndpointsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OutboundNetworkDependenciesEndpointListResult.NextLink) + }, + } +} + +// listOutboundNetworkDependenciesEndpointsCreateRequest creates the ListOutboundNetworkDependenciesEndpoints request. +func (client *ClustersClient) listOutboundNetworkDependenciesEndpointsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListOutboundNetworkDependenciesEndpointsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listOutboundNetworkDependenciesEndpointsHandleResponse handles the ListOutboundNetworkDependenciesEndpoints response. +func (client *ClustersClient) listOutboundNetworkDependenciesEndpointsHandleResponse(resp *http.Response) (ClustersListOutboundNetworkDependenciesEndpointsResponse, error) { + result := ClustersListOutboundNetworkDependenciesEndpointsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OutboundNetworkDependenciesEndpointListResult); err != nil { + return ClustersListOutboundNetworkDependenciesEndpointsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listOutboundNetworkDependenciesEndpointsHandleError handles the ListOutboundNetworkDependenciesEndpoints error response. +func (client *ClustersClient) listOutboundNetworkDependenciesEndpointsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListSKUs - Lists eligible SKUs for Kusto resource provider. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) ListSKUs(ctx context.Context, options *ClustersListSKUsOptions) (ClustersListSKUsResponse, error) { + req, err := client.listSKUsCreateRequest(ctx, options) + if err != nil { + return ClustersListSKUsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersListSKUsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersListSKUsResponse{}, client.listSKUsHandleError(resp) + } + return client.listSKUsHandleResponse(resp) +} + +// listSKUsCreateRequest creates the ListSKUs request. +func (client *ClustersClient) listSKUsCreateRequest(ctx context.Context, options *ClustersListSKUsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus" + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listSKUsHandleResponse handles the ListSKUs response. +func (client *ClustersClient) listSKUsHandleResponse(resp *http.Response) (ClustersListSKUsResponse, error) { + result := ClustersListSKUsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SKUDescriptionList); err != nil { + return ClustersListSKUsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listSKUsHandleError handles the ListSKUs error response. +func (client *ClustersClient) listSKUsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListSKUsByResource - Returns the SKUs available for the provided resource. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) ListSKUsByResource(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListSKUsByResourceOptions) (ClustersListSKUsByResourceResponse, error) { + req, err := client.listSKUsByResourceCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersListSKUsByResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersListSKUsByResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersListSKUsByResourceResponse{}, client.listSKUsByResourceHandleError(resp) + } + return client.listSKUsByResourceHandleResponse(resp) +} + +// listSKUsByResourceCreateRequest creates the ListSKUsByResource request. +func (client *ClustersClient) listSKUsByResourceCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersListSKUsByResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listSKUsByResourceHandleResponse handles the ListSKUsByResource response. +func (client *ClustersClient) listSKUsByResourceHandleResponse(resp *http.Response) (ClustersListSKUsByResourceResponse, error) { + result := ClustersListSKUsByResourceResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResourceSKUsResult); err != nil { + return ClustersListSKUsByResourceResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listSKUsByResourceHandleError handles the ListSKUsByResource error response. +func (client *ClustersClient) listSKUsByResourceHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginRemoveLanguageExtensions - Remove a list of language extensions that can run within KQL queries. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginRemoveLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToRemove LanguageExtensionsList, options *ClustersBeginRemoveLanguageExtensionsOptions) (ClustersRemoveLanguageExtensionsPollerResponse, error) { + resp, err := client.removeLanguageExtensions(ctx, resourceGroupName, clusterName, languageExtensionsToRemove, options) + if err != nil { + return ClustersRemoveLanguageExtensionsPollerResponse{}, err + } + result := ClustersRemoveLanguageExtensionsPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.RemoveLanguageExtensions", "", resp, client.pl, client.removeLanguageExtensionsHandleError) + if err != nil { + return ClustersRemoveLanguageExtensionsPollerResponse{}, err + } + result.Poller = &ClustersRemoveLanguageExtensionsPoller{ + pt: pt, + } + return result, nil +} + +// RemoveLanguageExtensions - Remove a list of language extensions that can run within KQL queries. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) removeLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToRemove LanguageExtensionsList, options *ClustersBeginRemoveLanguageExtensionsOptions) (*http.Response, error) { + req, err := client.removeLanguageExtensionsCreateRequest(ctx, resourceGroupName, clusterName, languageExtensionsToRemove, 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.removeLanguageExtensionsHandleError(resp) + } + return resp, nil +} + +// removeLanguageExtensionsCreateRequest creates the RemoveLanguageExtensions request. +func (client *ClustersClient) removeLanguageExtensionsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToRemove LanguageExtensionsList, options *ClustersBeginRemoveLanguageExtensionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, languageExtensionsToRemove) +} + +// removeLanguageExtensionsHandleError handles the RemoveLanguageExtensions error response. +func (client *ClustersClient) removeLanguageExtensionsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginStart - Starts a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginStart(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginStartOptions) (ClustersStartPollerResponse, error) { + resp, err := client.start(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersStartPollerResponse{}, err + } + result := ClustersStartPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.Start", "", resp, client.pl, client.startHandleError) + if err != nil { + return ClustersStartPollerResponse{}, err + } + result.Poller = &ClustersStartPoller{ + pt: pt, + } + return result, nil +} + +// Start - Starts a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) start(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginStartOptions) (*http.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, clusterName, 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.startHandleError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *ClustersClient) startCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// startHandleError handles the Start error response. +func (client *ClustersClient) startHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginStop - Stops a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginStop(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginStopOptions) (ClustersStopPollerResponse, error) { + resp, err := client.stop(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersStopPollerResponse{}, err + } + result := ClustersStopPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.Stop", "", resp, client.pl, client.stopHandleError) + if err != nil { + return ClustersStopPollerResponse{}, err + } + result.Poller = &ClustersStopPoller{ + pt: pt, + } + return result, nil +} + +// Stop - Stops a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) stop(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginStopOptions) (*http.Response, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, clusterName, 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.stopHandleError(resp) + } + return resp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *ClustersClient) stopCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginStopOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// stopHandleError handles the Stop error response. +func (client *ClustersClient) stopHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Update a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginUpdate(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdate, options *ClustersBeginUpdateOptions) (ClustersUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, clusterName, parameters, options) + if err != nil { + return ClustersUpdatePollerResponse{}, err + } + result := ClustersUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ClustersClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return ClustersUpdatePollerResponse{}, err + } + result.Poller = &ClustersUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Update a Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) update(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdate, options *ClustersBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, 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, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ClustersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdate, options *ClustersBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header.Set("If-Match", *options.IfMatch) + } + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleError handles the Update error response. +func (client *ClustersClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_constants.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_constants.go new file mode 100644 index 000000000000..0a53eedd8b11 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_constants.go @@ -0,0 +1,767 @@ +//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 armkusto + +const ( + module = "armkusto" + version = "v0.1.0" +) + +// AzureSKUName - SKU name. +type AzureSKUName string + +const ( + AzureSKUNameDevNoSLAStandardD11V2 AzureSKUName = "Dev(No SLA)_Standard_D11_v2" + AzureSKUNameDevNoSLAStandardE2AV4 AzureSKUName = "Dev(No SLA)_Standard_E2a_v4" + AzureSKUNameStandardD11V2 AzureSKUName = "Standard_D11_v2" + AzureSKUNameStandardD12V2 AzureSKUName = "Standard_D12_v2" + AzureSKUNameStandardD13V2 AzureSKUName = "Standard_D13_v2" + AzureSKUNameStandardD14V2 AzureSKUName = "Standard_D14_v2" + AzureSKUNameStandardDS13V21TBPS AzureSKUName = "Standard_DS13_v2+1TB_PS" + AzureSKUNameStandardDS13V22TBPS AzureSKUName = "Standard_DS13_v2+2TB_PS" + AzureSKUNameStandardDS14V23TBPS AzureSKUName = "Standard_DS14_v2+3TB_PS" + AzureSKUNameStandardDS14V24TBPS AzureSKUName = "Standard_DS14_v2+4TB_PS" + AzureSKUNameStandardE16AV4 AzureSKUName = "Standard_E16a_v4" + AzureSKUNameStandardE16AsV43TBPS AzureSKUName = "Standard_E16as_v4+3TB_PS" + AzureSKUNameStandardE16AsV44TBPS AzureSKUName = "Standard_E16as_v4+4TB_PS" + AzureSKUNameStandardE2AV4 AzureSKUName = "Standard_E2a_v4" + AzureSKUNameStandardE4AV4 AzureSKUName = "Standard_E4a_v4" + AzureSKUNameStandardE64IV3 AzureSKUName = "Standard_E64i_v3" + AzureSKUNameStandardE80IDsV4 AzureSKUName = "Standard_E80ids_v4" + AzureSKUNameStandardE8AV4 AzureSKUName = "Standard_E8a_v4" + AzureSKUNameStandardE8AsV41TBPS AzureSKUName = "Standard_E8as_v4+1TB_PS" + AzureSKUNameStandardE8AsV42TBPS AzureSKUName = "Standard_E8as_v4+2TB_PS" + AzureSKUNameStandardL16S AzureSKUName = "Standard_L16s" + AzureSKUNameStandardL16SV2 AzureSKUName = "Standard_L16s_v2" + AzureSKUNameStandardL4S AzureSKUName = "Standard_L4s" + AzureSKUNameStandardL8S AzureSKUName = "Standard_L8s" + AzureSKUNameStandardL8SV2 AzureSKUName = "Standard_L8s_v2" +) + +// PossibleAzureSKUNameValues returns the possible values for the AzureSKUName const type. +func PossibleAzureSKUNameValues() []AzureSKUName { + return []AzureSKUName{ + AzureSKUNameDevNoSLAStandardD11V2, + AzureSKUNameDevNoSLAStandardE2AV4, + AzureSKUNameStandardD11V2, + AzureSKUNameStandardD12V2, + AzureSKUNameStandardD13V2, + AzureSKUNameStandardD14V2, + AzureSKUNameStandardDS13V21TBPS, + AzureSKUNameStandardDS13V22TBPS, + AzureSKUNameStandardDS14V23TBPS, + AzureSKUNameStandardDS14V24TBPS, + AzureSKUNameStandardE16AV4, + AzureSKUNameStandardE16AsV43TBPS, + AzureSKUNameStandardE16AsV44TBPS, + AzureSKUNameStandardE2AV4, + AzureSKUNameStandardE4AV4, + AzureSKUNameStandardE64IV3, + AzureSKUNameStandardE80IDsV4, + AzureSKUNameStandardE8AV4, + AzureSKUNameStandardE8AsV41TBPS, + AzureSKUNameStandardE8AsV42TBPS, + AzureSKUNameStandardL16S, + AzureSKUNameStandardL16SV2, + AzureSKUNameStandardL4S, + AzureSKUNameStandardL8S, + AzureSKUNameStandardL8SV2, + } +} + +// ToPtr returns a *AzureSKUName pointing to the current value. +func (c AzureSKUName) ToPtr() *AzureSKUName { + return &c +} + +// AzureSKUTier - SKU tier. +type AzureSKUTier string + +const ( + AzureSKUTierBasic AzureSKUTier = "Basic" + AzureSKUTierStandard AzureSKUTier = "Standard" +) + +// PossibleAzureSKUTierValues returns the possible values for the AzureSKUTier const type. +func PossibleAzureSKUTierValues() []AzureSKUTier { + return []AzureSKUTier{ + AzureSKUTierBasic, + AzureSKUTierStandard, + } +} + +// ToPtr returns a *AzureSKUTier pointing to the current value. +func (c AzureSKUTier) ToPtr() *AzureSKUTier { + return &c +} + +// AzureScaleType - Scale type. +type AzureScaleType string + +const ( + AzureScaleTypeAutomatic AzureScaleType = "automatic" + AzureScaleTypeManual AzureScaleType = "manual" + AzureScaleTypeNone AzureScaleType = "none" +) + +// PossibleAzureScaleTypeValues returns the possible values for the AzureScaleType const type. +func PossibleAzureScaleTypeValues() []AzureScaleType { + return []AzureScaleType{ + AzureScaleTypeAutomatic, + AzureScaleTypeManual, + AzureScaleTypeNone, + } +} + +// ToPtr returns a *AzureScaleType pointing to the current value. +func (c AzureScaleType) ToPtr() *AzureScaleType { + return &c +} + +// BlobStorageEventType - The name of blob storage event type to process. +type BlobStorageEventType string + +const ( + BlobStorageEventTypeMicrosoftStorageBlobCreated BlobStorageEventType = "Microsoft.Storage.BlobCreated" + BlobStorageEventTypeMicrosoftStorageBlobRenamed BlobStorageEventType = "Microsoft.Storage.BlobRenamed" +) + +// PossibleBlobStorageEventTypeValues returns the possible values for the BlobStorageEventType const type. +func PossibleBlobStorageEventTypeValues() []BlobStorageEventType { + return []BlobStorageEventType{ + BlobStorageEventTypeMicrosoftStorageBlobCreated, + BlobStorageEventTypeMicrosoftStorageBlobRenamed, + } +} + +// ToPtr returns a *BlobStorageEventType pointing to the current value. +func (c BlobStorageEventType) ToPtr() *BlobStorageEventType { + return &c +} + +// ClusterNetworkAccessFlag - Whether or not to restrict outbound network access. Value is optional but if passed in, must be 'Enabled' or 'Disabled' +type ClusterNetworkAccessFlag string + +const ( + ClusterNetworkAccessFlagDisabled ClusterNetworkAccessFlag = "Disabled" + ClusterNetworkAccessFlagEnabled ClusterNetworkAccessFlag = "Enabled" +) + +// PossibleClusterNetworkAccessFlagValues returns the possible values for the ClusterNetworkAccessFlag const type. +func PossibleClusterNetworkAccessFlagValues() []ClusterNetworkAccessFlag { + return []ClusterNetworkAccessFlag{ + ClusterNetworkAccessFlagDisabled, + ClusterNetworkAccessFlagEnabled, + } +} + +// ToPtr returns a *ClusterNetworkAccessFlag pointing to the current value. +func (c ClusterNetworkAccessFlag) ToPtr() *ClusterNetworkAccessFlag { + return &c +} + +// ClusterPrincipalRole - Cluster principal role. +type ClusterPrincipalRole string + +const ( + ClusterPrincipalRoleAllDatabasesAdmin ClusterPrincipalRole = "AllDatabasesAdmin" + ClusterPrincipalRoleAllDatabasesViewer ClusterPrincipalRole = "AllDatabasesViewer" +) + +// PossibleClusterPrincipalRoleValues returns the possible values for the ClusterPrincipalRole const type. +func PossibleClusterPrincipalRoleValues() []ClusterPrincipalRole { + return []ClusterPrincipalRole{ + ClusterPrincipalRoleAllDatabasesAdmin, + ClusterPrincipalRoleAllDatabasesViewer, + } +} + +// ToPtr returns a *ClusterPrincipalRole pointing to the current value. +func (c ClusterPrincipalRole) ToPtr() *ClusterPrincipalRole { + return &c +} + +// Compression - The compression type +type Compression string + +const ( + CompressionGZip Compression = "GZip" + CompressionNone Compression = "None" +) + +// PossibleCompressionValues returns the possible values for the Compression const type. +func PossibleCompressionValues() []Compression { + return []Compression{ + CompressionGZip, + CompressionNone, + } +} + +// ToPtr returns a *Compression pointing to the current value. +func (c Compression) ToPtr() *Compression { + return &c +} + +// 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 +} + +// DataConnectionKind - Kind of the endpoint for the data connection +type DataConnectionKind string + +const ( + DataConnectionKindEventGrid DataConnectionKind = "EventGrid" + DataConnectionKindEventHub DataConnectionKind = "EventHub" + DataConnectionKindIotHub DataConnectionKind = "IotHub" +) + +// PossibleDataConnectionKindValues returns the possible values for the DataConnectionKind const type. +func PossibleDataConnectionKindValues() []DataConnectionKind { + return []DataConnectionKind{ + DataConnectionKindEventGrid, + DataConnectionKindEventHub, + DataConnectionKindIotHub, + } +} + +// ToPtr returns a *DataConnectionKind pointing to the current value. +func (c DataConnectionKind) ToPtr() *DataConnectionKind { + return &c +} + +// DatabasePrincipalRole - Database principal role. +type DatabasePrincipalRole string + +const ( + DatabasePrincipalRoleAdmin DatabasePrincipalRole = "Admin" + DatabasePrincipalRoleIngestor DatabasePrincipalRole = "Ingestor" + DatabasePrincipalRoleMonitor DatabasePrincipalRole = "Monitor" + DatabasePrincipalRoleUnrestrictedViewer DatabasePrincipalRole = "UnrestrictedViewer" + DatabasePrincipalRoleUser DatabasePrincipalRole = "User" + DatabasePrincipalRoleViewer DatabasePrincipalRole = "Viewer" +) + +// PossibleDatabasePrincipalRoleValues returns the possible values for the DatabasePrincipalRole const type. +func PossibleDatabasePrincipalRoleValues() []DatabasePrincipalRole { + return []DatabasePrincipalRole{ + DatabasePrincipalRoleAdmin, + DatabasePrincipalRoleIngestor, + DatabasePrincipalRoleMonitor, + DatabasePrincipalRoleUnrestrictedViewer, + DatabasePrincipalRoleUser, + DatabasePrincipalRoleViewer, + } +} + +// ToPtr returns a *DatabasePrincipalRole pointing to the current value. +func (c DatabasePrincipalRole) ToPtr() *DatabasePrincipalRole { + return &c +} + +// DatabasePrincipalType - Database principal type. +type DatabasePrincipalType string + +const ( + DatabasePrincipalTypeApp DatabasePrincipalType = "App" + DatabasePrincipalTypeGroup DatabasePrincipalType = "Group" + DatabasePrincipalTypeUser DatabasePrincipalType = "User" +) + +// PossibleDatabasePrincipalTypeValues returns the possible values for the DatabasePrincipalType const type. +func PossibleDatabasePrincipalTypeValues() []DatabasePrincipalType { + return []DatabasePrincipalType{ + DatabasePrincipalTypeApp, + DatabasePrincipalTypeGroup, + DatabasePrincipalTypeUser, + } +} + +// ToPtr returns a *DatabasePrincipalType pointing to the current value. +func (c DatabasePrincipalType) ToPtr() *DatabasePrincipalType { + return &c +} + +// DefaultPrincipalsModificationKind - The default principals modification kind +type DefaultPrincipalsModificationKind string + +const ( + DefaultPrincipalsModificationKindNone DefaultPrincipalsModificationKind = "None" + DefaultPrincipalsModificationKindReplace DefaultPrincipalsModificationKind = "Replace" + DefaultPrincipalsModificationKindUnion DefaultPrincipalsModificationKind = "Union" +) + +// PossibleDefaultPrincipalsModificationKindValues returns the possible values for the DefaultPrincipalsModificationKind const type. +func PossibleDefaultPrincipalsModificationKindValues() []DefaultPrincipalsModificationKind { + return []DefaultPrincipalsModificationKind{ + DefaultPrincipalsModificationKindNone, + DefaultPrincipalsModificationKindReplace, + DefaultPrincipalsModificationKindUnion, + } +} + +// ToPtr returns a *DefaultPrincipalsModificationKind pointing to the current value. +func (c DefaultPrincipalsModificationKind) ToPtr() *DefaultPrincipalsModificationKind { + return &c +} + +// EngineType - The engine type +type EngineType string + +const ( + EngineTypeV2 EngineType = "V2" + EngineTypeV3 EngineType = "V3" +) + +// PossibleEngineTypeValues returns the possible values for the EngineType const type. +func PossibleEngineTypeValues() []EngineType { + return []EngineType{ + EngineTypeV2, + EngineTypeV3, + } +} + +// ToPtr returns a *EngineType pointing to the current value. +func (c EngineType) ToPtr() *EngineType { + return &c +} + +// EventGridDataFormat - The data format of the message. Optionally the data format can be added to each message. +type EventGridDataFormat string + +const ( + EventGridDataFormatAPACHEAVRO EventGridDataFormat = "APACHEAVRO" + EventGridDataFormatAVRO EventGridDataFormat = "AVRO" + EventGridDataFormatCSV EventGridDataFormat = "CSV" + EventGridDataFormatJSON EventGridDataFormat = "JSON" + EventGridDataFormatMULTIJSON EventGridDataFormat = "MULTIJSON" + EventGridDataFormatORC EventGridDataFormat = "ORC" + EventGridDataFormatPARQUET EventGridDataFormat = "PARQUET" + EventGridDataFormatPSV EventGridDataFormat = "PSV" + EventGridDataFormatRAW EventGridDataFormat = "RAW" + EventGridDataFormatSCSV EventGridDataFormat = "SCSV" + EventGridDataFormatSINGLEJSON EventGridDataFormat = "SINGLEJSON" + EventGridDataFormatSOHSV EventGridDataFormat = "SOHSV" + EventGridDataFormatTSV EventGridDataFormat = "TSV" + EventGridDataFormatTSVE EventGridDataFormat = "TSVE" + EventGridDataFormatTXT EventGridDataFormat = "TXT" + EventGridDataFormatW3CLOGFILE EventGridDataFormat = "W3CLOGFILE" +) + +// PossibleEventGridDataFormatValues returns the possible values for the EventGridDataFormat const type. +func PossibleEventGridDataFormatValues() []EventGridDataFormat { + return []EventGridDataFormat{ + EventGridDataFormatAPACHEAVRO, + EventGridDataFormatAVRO, + EventGridDataFormatCSV, + EventGridDataFormatJSON, + EventGridDataFormatMULTIJSON, + EventGridDataFormatORC, + EventGridDataFormatPARQUET, + EventGridDataFormatPSV, + EventGridDataFormatRAW, + EventGridDataFormatSCSV, + EventGridDataFormatSINGLEJSON, + EventGridDataFormatSOHSV, + EventGridDataFormatTSV, + EventGridDataFormatTSVE, + EventGridDataFormatTXT, + EventGridDataFormatW3CLOGFILE, + } +} + +// ToPtr returns a *EventGridDataFormat pointing to the current value. +func (c EventGridDataFormat) ToPtr() *EventGridDataFormat { + return &c +} + +// EventHubDataFormat - The data format of the message. Optionally the data format can be added to each message. +type EventHubDataFormat string + +const ( + EventHubDataFormatAPACHEAVRO EventHubDataFormat = "APACHEAVRO" + EventHubDataFormatAVRO EventHubDataFormat = "AVRO" + EventHubDataFormatCSV EventHubDataFormat = "CSV" + EventHubDataFormatJSON EventHubDataFormat = "JSON" + EventHubDataFormatMULTIJSON EventHubDataFormat = "MULTIJSON" + EventHubDataFormatORC EventHubDataFormat = "ORC" + EventHubDataFormatPARQUET EventHubDataFormat = "PARQUET" + EventHubDataFormatPSV EventHubDataFormat = "PSV" + EventHubDataFormatRAW EventHubDataFormat = "RAW" + EventHubDataFormatSCSV EventHubDataFormat = "SCSV" + EventHubDataFormatSINGLEJSON EventHubDataFormat = "SINGLEJSON" + EventHubDataFormatSOHSV EventHubDataFormat = "SOHSV" + EventHubDataFormatTSV EventHubDataFormat = "TSV" + EventHubDataFormatTSVE EventHubDataFormat = "TSVE" + EventHubDataFormatTXT EventHubDataFormat = "TXT" + EventHubDataFormatW3CLOGFILE EventHubDataFormat = "W3CLOGFILE" +) + +// PossibleEventHubDataFormatValues returns the possible values for the EventHubDataFormat const type. +func PossibleEventHubDataFormatValues() []EventHubDataFormat { + return []EventHubDataFormat{ + EventHubDataFormatAPACHEAVRO, + EventHubDataFormatAVRO, + EventHubDataFormatCSV, + EventHubDataFormatJSON, + EventHubDataFormatMULTIJSON, + EventHubDataFormatORC, + EventHubDataFormatPARQUET, + EventHubDataFormatPSV, + EventHubDataFormatRAW, + EventHubDataFormatSCSV, + EventHubDataFormatSINGLEJSON, + EventHubDataFormatSOHSV, + EventHubDataFormatTSV, + EventHubDataFormatTSVE, + EventHubDataFormatTXT, + EventHubDataFormatW3CLOGFILE, + } +} + +// ToPtr returns a *EventHubDataFormat pointing to the current value. +func (c EventHubDataFormat) ToPtr() *EventHubDataFormat { + return &c +} + +// IdentityType - The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned +// identities. The type 'None' will remove all +// identities. +type IdentityType string + +const ( + IdentityTypeNone IdentityType = "None" + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + IdentityTypeSystemAssignedUserAssigned IdentityType = "SystemAssigned, UserAssigned" + IdentityTypeUserAssigned IdentityType = "UserAssigned" +) + +// PossibleIdentityTypeValues returns the possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{ + IdentityTypeNone, + IdentityTypeSystemAssigned, + IdentityTypeSystemAssignedUserAssigned, + IdentityTypeUserAssigned, + } +} + +// ToPtr returns a *IdentityType pointing to the current value. +func (c IdentityType) ToPtr() *IdentityType { + return &c +} + +// IotHubDataFormat - The data format of the message. Optionally the data format can be added to each message. +type IotHubDataFormat string + +const ( + IotHubDataFormatAPACHEAVRO IotHubDataFormat = "APACHEAVRO" + IotHubDataFormatAVRO IotHubDataFormat = "AVRO" + IotHubDataFormatCSV IotHubDataFormat = "CSV" + IotHubDataFormatJSON IotHubDataFormat = "JSON" + IotHubDataFormatMULTIJSON IotHubDataFormat = "MULTIJSON" + IotHubDataFormatORC IotHubDataFormat = "ORC" + IotHubDataFormatPARQUET IotHubDataFormat = "PARQUET" + IotHubDataFormatPSV IotHubDataFormat = "PSV" + IotHubDataFormatRAW IotHubDataFormat = "RAW" + IotHubDataFormatSCSV IotHubDataFormat = "SCSV" + IotHubDataFormatSINGLEJSON IotHubDataFormat = "SINGLEJSON" + IotHubDataFormatSOHSV IotHubDataFormat = "SOHSV" + IotHubDataFormatTSV IotHubDataFormat = "TSV" + IotHubDataFormatTSVE IotHubDataFormat = "TSVE" + IotHubDataFormatTXT IotHubDataFormat = "TXT" + IotHubDataFormatW3CLOGFILE IotHubDataFormat = "W3CLOGFILE" +) + +// PossibleIotHubDataFormatValues returns the possible values for the IotHubDataFormat const type. +func PossibleIotHubDataFormatValues() []IotHubDataFormat { + return []IotHubDataFormat{ + IotHubDataFormatAPACHEAVRO, + IotHubDataFormatAVRO, + IotHubDataFormatCSV, + IotHubDataFormatJSON, + IotHubDataFormatMULTIJSON, + IotHubDataFormatORC, + IotHubDataFormatPARQUET, + IotHubDataFormatPSV, + IotHubDataFormatRAW, + IotHubDataFormatSCSV, + IotHubDataFormatSINGLEJSON, + IotHubDataFormatSOHSV, + IotHubDataFormatTSV, + IotHubDataFormatTSVE, + IotHubDataFormatTXT, + IotHubDataFormatW3CLOGFILE, + } +} + +// ToPtr returns a *IotHubDataFormat pointing to the current value. +func (c IotHubDataFormat) ToPtr() *IotHubDataFormat { + return &c +} + +// Kind - Kind of the database +type Kind string + +const ( + KindReadOnlyFollowing Kind = "ReadOnlyFollowing" + KindReadWrite Kind = "ReadWrite" +) + +// PossibleKindValues returns the possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{ + KindReadOnlyFollowing, + KindReadWrite, + } +} + +// ToPtr returns a *Kind pointing to the current value. +func (c Kind) ToPtr() *Kind { + return &c +} + +// LanguageExtensionName - Language extension that can run within KQL query. +type LanguageExtensionName string + +const ( + LanguageExtensionNamePYTHON LanguageExtensionName = "PYTHON" + LanguageExtensionNameR LanguageExtensionName = "R" +) + +// PossibleLanguageExtensionNameValues returns the possible values for the LanguageExtensionName const type. +func PossibleLanguageExtensionNameValues() []LanguageExtensionName { + return []LanguageExtensionName{ + LanguageExtensionNamePYTHON, + LanguageExtensionNameR, + } +} + +// ToPtr returns a *LanguageExtensionName pointing to the current value. +func (c LanguageExtensionName) ToPtr() *LanguageExtensionName { + return &c +} + +// PrincipalType - Principal type. +type PrincipalType string + +const ( + PrincipalTypeApp PrincipalType = "App" + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeUser PrincipalType = "User" +) + +// PossiblePrincipalTypeValues returns the possible values for the PrincipalType const type. +func PossiblePrincipalTypeValues() []PrincipalType { + return []PrincipalType{ + PrincipalTypeApp, + PrincipalTypeGroup, + PrincipalTypeUser, + } +} + +// ToPtr returns a *PrincipalType pointing to the current value. +func (c PrincipalType) ToPtr() *PrincipalType { + return &c +} + +// PrincipalsModificationKind - The principals modification kind of the database +type PrincipalsModificationKind string + +const ( + PrincipalsModificationKindNone PrincipalsModificationKind = "None" + PrincipalsModificationKindReplace PrincipalsModificationKind = "Replace" + PrincipalsModificationKindUnion PrincipalsModificationKind = "Union" +) + +// PossiblePrincipalsModificationKindValues returns the possible values for the PrincipalsModificationKind const type. +func PossiblePrincipalsModificationKindValues() []PrincipalsModificationKind { + return []PrincipalsModificationKind{ + PrincipalsModificationKindNone, + PrincipalsModificationKindReplace, + PrincipalsModificationKindUnion, + } +} + +// ToPtr returns a *PrincipalsModificationKind pointing to the current value. +func (c PrincipalsModificationKind) ToPtr() *PrincipalsModificationKind { + return &c +} + +// ProvisioningState - The provisioned state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateMoving, + ProvisioningStateRunning, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// PublicNetworkAccess - Public network access to the cluster is enabled by default. When disabled, only private endpoint connection to the cluster is allowed +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 +} + +// Reason - Message providing the reason why the given name is invalid. +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +// PossibleReasonValues returns the possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonAlreadyExists, + ReasonInvalid, + } +} + +// ToPtr returns a *Reason pointing to the current value. +func (c Reason) ToPtr() *Reason { + return &c +} + +// State - The state of the resource. +type State string + +const ( + StateCreating State = "Creating" + StateDeleted State = "Deleted" + StateDeleting State = "Deleting" + StateRunning State = "Running" + StateStarting State = "Starting" + StateStopped State = "Stopped" + StateStopping State = "Stopping" + StateUnavailable State = "Unavailable" + StateUpdating State = "Updating" +) + +// PossibleStateValues returns the possible values for the State const type. +func PossibleStateValues() []State { + return []State{ + StateCreating, + StateDeleted, + StateDeleting, + StateRunning, + StateStarting, + StateStopped, + StateStopping, + StateUnavailable, + StateUpdating, + } +} + +// ToPtr returns a *State pointing to the current value. +func (c State) ToPtr() *State { + return &c +} + +// Status - The status of operation. +type Status string + +const ( + StatusCanceled Status = "Canceled" + StatusFailed Status = "Failed" + StatusRunning Status = "Running" + StatusSucceeded Status = "Succeeded" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusCanceled, + StatusFailed, + StatusRunning, + StatusSucceeded, + } +} + +// ToPtr returns a *Status pointing to the current value. +func (c Status) ToPtr() *Status { + return &c +} + +// Type - The type of resource, for instance Microsoft.Kusto/clusters/databases. +type Type string + +const ( + TypeMicrosoftKustoClustersDatabases Type = "Microsoft.Kusto/clusters/databases" + TypeMicrosoftKustoClustersAttachedDatabaseConfigurations Type = "Microsoft.Kusto/clusters/attachedDatabaseConfigurations" +) + +// PossibleTypeValues returns the possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ + TypeMicrosoftKustoClustersDatabases, + TypeMicrosoftKustoClustersAttachedDatabaseConfigurations, + } +} + +// ToPtr returns a *Type pointing to the current value. +func (c Type) ToPtr() *Type { + return &c +} diff --git a/sdk/resourcemanager/kusto/armkusto/zz_generated_databaseprincipalassignments_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_databaseprincipalassignments_client.go new file mode 100644 index 000000000000..1be794e25d84 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_databaseprincipalassignments_client.go @@ -0,0 +1,422 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// DatabasePrincipalAssignmentsClient contains the methods for the DatabasePrincipalAssignments group. +// Don't use this type directly, use NewDatabasePrincipalAssignmentsClient() instead. +type DatabasePrincipalAssignmentsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDatabasePrincipalAssignmentsClient creates a new instance of DatabasePrincipalAssignmentsClient with the specified values. +func NewDatabasePrincipalAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DatabasePrincipalAssignmentsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DatabasePrincipalAssignmentsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the database principal assignment is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName DatabasePrincipalAssignmentCheckNameRequest, options *DatabasePrincipalAssignmentsCheckNameAvailabilityOptions) (DatabasePrincipalAssignmentsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, databaseName, principalAssignmentName, options) + if err != nil { + return DatabasePrincipalAssignmentsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasePrincipalAssignmentsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasePrincipalAssignmentsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *DatabasePrincipalAssignmentsClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName DatabasePrincipalAssignmentCheckNameRequest, options *DatabasePrincipalAssignmentsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, principalAssignmentName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *DatabasePrincipalAssignmentsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (DatabasePrincipalAssignmentsCheckNameAvailabilityResponse, error) { + result := DatabasePrincipalAssignmentsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return DatabasePrincipalAssignmentsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *DatabasePrincipalAssignmentsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Creates a Kusto cluster database principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, parameters DatabasePrincipalAssignment, options *DatabasePrincipalAssignmentsBeginCreateOrUpdateOptions) (DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, databaseName, principalAssignmentName, parameters, options) + if err != nil { + return DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse{}, err + } + result := DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatabasePrincipalAssignmentsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &DatabasePrincipalAssignmentsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates a Kusto cluster database principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, parameters DatabasePrincipalAssignment, options *DatabasePrincipalAssignmentsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, principalAssignmentName, 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 *DatabasePrincipalAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, parameters DatabasePrincipalAssignment, options *DatabasePrincipalAssignmentsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if principalAssignmentName == "" { + return nil, errors.New("parameter principalAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{principalAssignmentName}", url.PathEscape(principalAssignmentName)) + 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-08-27") + 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 *DatabasePrincipalAssignmentsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsBeginDeleteOptions) (DatabasePrincipalAssignmentsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, databaseName, principalAssignmentName, options) + if err != nil { + return DatabasePrincipalAssignmentsDeletePollerResponse{}, err + } + result := DatabasePrincipalAssignmentsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatabasePrincipalAssignmentsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return DatabasePrincipalAssignmentsDeletePollerResponse{}, err + } + result.Poller = &DatabasePrincipalAssignmentsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a Kusto principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, databaseName, principalAssignmentName, 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 *DatabasePrincipalAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if principalAssignmentName == "" { + return nil, errors.New("parameter principalAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{principalAssignmentName}", url.PathEscape(principalAssignmentName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DatabasePrincipalAssignmentsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto cluster database principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsGetOptions) (DatabasePrincipalAssignmentsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, databaseName, principalAssignmentName, options) + if err != nil { + return DatabasePrincipalAssignmentsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasePrincipalAssignmentsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasePrincipalAssignmentsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DatabasePrincipalAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if principalAssignmentName == "" { + return nil, errors.New("parameter principalAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{principalAssignmentName}", url.PathEscape(principalAssignmentName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DatabasePrincipalAssignmentsClient) getHandleResponse(resp *http.Response) (DatabasePrincipalAssignmentsGetResponse, error) { + result := DatabasePrincipalAssignmentsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatabasePrincipalAssignment); err != nil { + return DatabasePrincipalAssignmentsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DatabasePrincipalAssignmentsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Lists all Kusto cluster database principalAssignments. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasePrincipalAssignmentsClient) List(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasePrincipalAssignmentsListOptions) (DatabasePrincipalAssignmentsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) + if err != nil { + return DatabasePrincipalAssignmentsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasePrincipalAssignmentsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasePrincipalAssignmentsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DatabasePrincipalAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasePrincipalAssignmentsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DatabasePrincipalAssignmentsClient) listHandleResponse(resp *http.Response) (DatabasePrincipalAssignmentsListResponse, error) { + result := DatabasePrincipalAssignmentsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatabasePrincipalAssignmentListResult); err != nil { + return DatabasePrincipalAssignmentsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DatabasePrincipalAssignmentsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_databases_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_databases_client.go new file mode 100644 index 000000000000..6972ed2ef671 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_databases_client.go @@ -0,0 +1,689 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// DatabasesClient contains the methods for the Databases group. +// Don't use this type directly, use NewDatabasesClient() instead. +type DatabasesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDatabasesClient creates a new instance of DatabasesClient with the specified values. +func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DatabasesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DatabasesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// AddPrincipals - Add Database principals permissions. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) AddPrincipals(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToAdd DatabasePrincipalListRequest, options *DatabasesAddPrincipalsOptions) (DatabasesAddPrincipalsResponse, error) { + req, err := client.addPrincipalsCreateRequest(ctx, resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, options) + if err != nil { + return DatabasesAddPrincipalsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasesAddPrincipalsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasesAddPrincipalsResponse{}, client.addPrincipalsHandleError(resp) + } + return client.addPrincipalsHandleResponse(resp) +} + +// addPrincipalsCreateRequest creates the AddPrincipals request. +func (client *DatabasesClient) addPrincipalsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToAdd DatabasePrincipalListRequest, options *DatabasesAddPrincipalsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, databasePrincipalsToAdd) +} + +// addPrincipalsHandleResponse handles the AddPrincipals response. +func (client *DatabasesClient) addPrincipalsHandleResponse(resp *http.Response) (DatabasesAddPrincipalsResponse, error) { + result := DatabasesAddPrincipalsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatabasePrincipalListResult); err != nil { + return DatabasesAddPrincipalsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// addPrincipalsHandleError handles the AddPrincipals error response. +func (client *DatabasesClient) addPrincipalsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// CheckNameAvailability - Checks that the databases resource name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName CheckNameRequest, options *DatabasesCheckNameAvailabilityOptions) (DatabasesCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, resourceName, options) + if err != nil { + return DatabasesCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasesCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasesCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *DatabasesClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, resourceName CheckNameRequest, options *DatabasesCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resourceName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *DatabasesClient) checkNameAvailabilityHandleResponse(resp *http.Response) (DatabasesCheckNameAvailabilityResponse, error) { + result := DatabasesCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return DatabasesCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *DatabasesClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Creates or updates a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesBeginCreateOrUpdateOptions) (DatabasesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, databaseName, parameters, options) + if err != nil { + return DatabasesCreateOrUpdatePollerResponse{}, err + } + result := DatabasesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatabasesClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return DatabasesCreateOrUpdatePollerResponse{}, err + } + result.Poller = &DatabasesCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + 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 *DatabasesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 database with the given name. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesBeginDeleteOptions) (DatabasesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, databaseName, options) + if err != nil { + return DatabasesDeletePollerResponse{}, err + } + result := DatabasesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatabasesClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return DatabasesDeletePollerResponse{}, err + } + result.Poller = &DatabasesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the database with the given name. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, databaseName, 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 *DatabasesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DatabasesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Returns a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesGetOptions) (DatabasesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) + if err != nil { + return DatabasesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DatabasesClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DatabasesClient) getHandleResponse(resp *http.Response) (DatabasesGetResponse, error) { + result := DatabasesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return DatabasesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DatabasesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListByCluster - Returns the list of databases of the given Kusto cluster. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) ListByCluster(ctx context.Context, resourceGroupName string, clusterName string, options *DatabasesListByClusterOptions) (DatabasesListByClusterResponse, error) { + req, err := client.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return DatabasesListByClusterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasesListByClusterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasesListByClusterResponse{}, client.listByClusterHandleError(resp) + } + return client.listByClusterHandleResponse(resp) +} + +// listByClusterCreateRequest creates the ListByCluster request. +func (client *DatabasesClient) listByClusterCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *DatabasesListByClusterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByClusterHandleResponse handles the ListByCluster response. +func (client *DatabasesClient) listByClusterHandleResponse(resp *http.Response) (DatabasesListByClusterResponse, error) { + result := DatabasesListByClusterResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatabaseListResult); err != nil { + return DatabasesListByClusterResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByClusterHandleError handles the ListByCluster error response. +func (client *DatabasesClient) listByClusterHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListPrincipals - Returns a list of database principals of the given Kusto cluster and database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) ListPrincipals(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesListPrincipalsOptions) (DatabasesListPrincipalsResponse, error) { + req, err := client.listPrincipalsCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) + if err != nil { + return DatabasesListPrincipalsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasesListPrincipalsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasesListPrincipalsResponse{}, client.listPrincipalsHandleError(resp) + } + return client.listPrincipalsHandleResponse(resp) +} + +// listPrincipalsCreateRequest creates the ListPrincipals request. +func (client *DatabasesClient) listPrincipalsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesListPrincipalsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listPrincipalsHandleResponse handles the ListPrincipals response. +func (client *DatabasesClient) listPrincipalsHandleResponse(resp *http.Response) (DatabasesListPrincipalsResponse, error) { + result := DatabasesListPrincipalsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatabasePrincipalListResult); err != nil { + return DatabasesListPrincipalsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listPrincipalsHandleError handles the ListPrincipals error response. +func (client *DatabasesClient) listPrincipalsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// RemovePrincipals - Remove Database principals permissions. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) RemovePrincipals(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToRemove DatabasePrincipalListRequest, options *DatabasesRemovePrincipalsOptions) (DatabasesRemovePrincipalsResponse, error) { + req, err := client.removePrincipalsCreateRequest(ctx, resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, options) + if err != nil { + return DatabasesRemovePrincipalsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatabasesRemovePrincipalsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatabasesRemovePrincipalsResponse{}, client.removePrincipalsHandleError(resp) + } + return client.removePrincipalsHandleResponse(resp) +} + +// removePrincipalsCreateRequest creates the RemovePrincipals request. +func (client *DatabasesClient) removePrincipalsCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToRemove DatabasePrincipalListRequest, options *DatabasesRemovePrincipalsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, databasePrincipalsToRemove) +} + +// removePrincipalsHandleResponse handles the RemovePrincipals response. +func (client *DatabasesClient) removePrincipalsHandleResponse(resp *http.Response) (DatabasesRemovePrincipalsResponse, error) { + result := DatabasesRemovePrincipalsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatabasePrincipalListResult); err != nil { + return DatabasesRemovePrincipalsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// removePrincipalsHandleError handles the RemovePrincipals error response. +func (client *DatabasesClient) removePrincipalsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) BeginUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesBeginUpdateOptions) (DatabasesUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, clusterName, databaseName, parameters, options) + if err != nil { + return DatabasesUpdatePollerResponse{}, err + } + result := DatabasesUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatabasesClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return DatabasesUpdatePollerResponse{}, err + } + result.Poller = &DatabasesUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates a database. +// If the operation fails it returns the *CloudError error type. +func (client *DatabasesClient) update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, 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, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DatabasesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + 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 *DatabasesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_dataconnections_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_dataconnections_client.go new file mode 100644 index 000000000000..d32444951f7f --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_dataconnections_client.go @@ -0,0 +1,586 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// DataConnectionsClient contains the methods for the DataConnections group. +// Don't use this type directly, use NewDataConnectionsClient() instead. +type DataConnectionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDataConnectionsClient creates a new instance of DataConnectionsClient with the specified values. +func NewDataConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DataConnectionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DataConnectionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the data connection name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName DataConnectionCheckNameRequest, options *DataConnectionsCheckNameAvailabilityOptions) (DataConnectionsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, options) + if err != nil { + return DataConnectionsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DataConnectionsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DataConnectionsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *DataConnectionsClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName DataConnectionCheckNameRequest, options *DataConnectionsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, dataConnectionName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *DataConnectionsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (DataConnectionsCheckNameAvailabilityResponse, error) { + result := DataConnectionsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return DataConnectionsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *DataConnectionsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Creates or updates a data connection. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsBeginCreateOrUpdateOptions) (DataConnectionsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, parameters, options) + if err != nil { + return DataConnectionsCreateOrUpdatePollerResponse{}, err + } + result := DataConnectionsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DataConnectionsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return DataConnectionsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &DataConnectionsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a data connection. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DataConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if dataConnectionName == "" { + return nil, errors.New("parameter dataConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) + 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-08-27") + 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 *DataConnectionsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginDataConnectionValidation - Checks that the data connection parameters are valid. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) BeginDataConnectionValidation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DataConnectionValidation, options *DataConnectionsBeginDataConnectionValidationOptions) (DataConnectionsDataConnectionValidationPollerResponse, error) { + resp, err := client.dataConnectionValidation(ctx, resourceGroupName, clusterName, databaseName, parameters, options) + if err != nil { + return DataConnectionsDataConnectionValidationPollerResponse{}, err + } + result := DataConnectionsDataConnectionValidationPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DataConnectionsClient.DataConnectionValidation", "location", resp, client.pl, client.dataConnectionValidationHandleError) + if err != nil { + return DataConnectionsDataConnectionValidationPollerResponse{}, err + } + result.Poller = &DataConnectionsDataConnectionValidationPoller{ + pt: pt, + } + return result, nil +} + +// DataConnectionValidation - Checks that the data connection parameters are valid. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) dataConnectionValidation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DataConnectionValidation, options *DataConnectionsBeginDataConnectionValidationOptions) (*http.Response, error) { + req, err := client.dataConnectionValidationCreateRequest(ctx, resourceGroupName, clusterName, databaseName, 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.dataConnectionValidationHandleError(resp) + } + return resp, nil +} + +// dataConnectionValidationCreateRequest creates the DataConnectionValidation request. +func (client *DataConnectionsClient) dataConnectionValidationCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DataConnectionValidation, options *DataConnectionsBeginDataConnectionValidationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// dataConnectionValidationHandleError handles the DataConnectionValidation error response. +func (client *DataConnectionsClient) dataConnectionValidationHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 data connection with the given name. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsBeginDeleteOptions) (DataConnectionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, options) + if err != nil { + return DataConnectionsDeletePollerResponse{}, err + } + result := DataConnectionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DataConnectionsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return DataConnectionsDeletePollerResponse{}, err + } + result.Poller = &DataConnectionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the data connection with the given name. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, 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 *DataConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if dataConnectionName == "" { + return nil, errors.New("parameter dataConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DataConnectionsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Returns a data connection. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsGetOptions) (DataConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, options) + if err != nil { + return DataConnectionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DataConnectionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DataConnectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DataConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if dataConnectionName == "" { + return nil, errors.New("parameter dataConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataConnectionsClient) getHandleResponse(resp *http.Response) (DataConnectionsGetResponse, error) { + result := DataConnectionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return DataConnectionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DataConnectionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListByDatabase - Returns the list of data connections of the given Kusto database. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) ListByDatabase(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DataConnectionsListByDatabaseOptions) (DataConnectionsListByDatabaseResponse, error) { + req, err := client.listByDatabaseCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) + if err != nil { + return DataConnectionsListByDatabaseResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DataConnectionsListByDatabaseResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DataConnectionsListByDatabaseResponse{}, client.listByDatabaseHandleError(resp) + } + return client.listByDatabaseHandleResponse(resp) +} + +// listByDatabaseCreateRequest creates the ListByDatabase request. +func (client *DataConnectionsClient) listByDatabaseCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DataConnectionsListByDatabaseOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByDatabaseHandleResponse handles the ListByDatabase response. +func (client *DataConnectionsClient) listByDatabaseHandleResponse(resp *http.Response) (DataConnectionsListByDatabaseResponse, error) { + result := DataConnectionsListByDatabaseResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DataConnectionListResult); err != nil { + return DataConnectionsListByDatabaseResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByDatabaseHandleError handles the ListByDatabase error response. +func (client *DataConnectionsClient) listByDatabaseHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 data connection. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsBeginUpdateOptions) (DataConnectionsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, parameters, options) + if err != nil { + return DataConnectionsUpdatePollerResponse{}, err + } + result := DataConnectionsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DataConnectionsClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return DataConnectionsUpdatePollerResponse{}, err + } + result.Poller = &DataConnectionsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates a data connection. +// If the operation fails it returns the *CloudError error type. +func (client *DataConnectionsClient) update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, dataConnectionName, 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, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DataConnectionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if dataConnectionName == "" { + return nil, errors.New("parameter dataConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) + 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-08-27") + 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 *DataConnectionsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_managedprivateendpoints_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_managedprivateendpoints_client.go new file mode 100644 index 000000000000..19db5ad26ada --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_managedprivateendpoints_client.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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// ManagedPrivateEndpointsClient contains the methods for the ManagedPrivateEndpoints group. +// Don't use this type directly, use NewManagedPrivateEndpointsClient() instead. +type ManagedPrivateEndpointsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewManagedPrivateEndpointsClient creates a new instance of ManagedPrivateEndpointsClient with the specified values. +func NewManagedPrivateEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ManagedPrivateEndpointsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ManagedPrivateEndpointsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the managed private endpoints resource name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName ManagedPrivateEndpointsCheckNameRequest, options *ManagedPrivateEndpointsCheckNameAvailabilityOptions) (ManagedPrivateEndpointsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, resourceName, options) + if err != nil { + return ManagedPrivateEndpointsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagedPrivateEndpointsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagedPrivateEndpointsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *ManagedPrivateEndpointsClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, resourceName ManagedPrivateEndpointsCheckNameRequest, options *ManagedPrivateEndpointsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resourceName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *ManagedPrivateEndpointsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (ManagedPrivateEndpointsCheckNameAvailabilityResponse, error) { + result := ManagedPrivateEndpointsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return ManagedPrivateEndpointsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *ManagedPrivateEndpointsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Creates a managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsBeginCreateOrUpdateOptions) (ManagedPrivateEndpointsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, parameters, options) + if err != nil { + return ManagedPrivateEndpointsCreateOrUpdatePollerResponse{}, err + } + result := ManagedPrivateEndpointsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ManagedPrivateEndpointsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ManagedPrivateEndpointsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ManagedPrivateEndpointsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates a managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ManagedPrivateEndpointsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if managedPrivateEndpointName == "" { + return nil, errors.New("parameter managedPrivateEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managedPrivateEndpointName}", url.PathEscape(managedPrivateEndpointName)) + 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-08-27") + 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 *ManagedPrivateEndpointsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsBeginDeleteOptions) (ManagedPrivateEndpointsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, options) + if err != nil { + return ManagedPrivateEndpointsDeletePollerResponse{}, err + } + result := ManagedPrivateEndpointsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ManagedPrivateEndpointsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return ManagedPrivateEndpointsDeletePollerResponse{}, err + } + result.Poller = &ManagedPrivateEndpointsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, 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 *ManagedPrivateEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if managedPrivateEndpointName == "" { + return nil, errors.New("parameter managedPrivateEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managedPrivateEndpointName}", url.PathEscape(managedPrivateEndpointName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ManagedPrivateEndpointsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsGetOptions) (ManagedPrivateEndpointsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, options) + if err != nil { + return ManagedPrivateEndpointsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagedPrivateEndpointsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagedPrivateEndpointsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ManagedPrivateEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if managedPrivateEndpointName == "" { + return nil, errors.New("parameter managedPrivateEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managedPrivateEndpointName}", url.PathEscape(managedPrivateEndpointName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ManagedPrivateEndpointsClient) getHandleResponse(resp *http.Response) (ManagedPrivateEndpointsGetResponse, error) { + result := ManagedPrivateEndpointsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedPrivateEndpoint); err != nil { + return ManagedPrivateEndpointsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ManagedPrivateEndpointsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Returns the list of managed private endpoints. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) List(ctx context.Context, resourceGroupName string, clusterName string, options *ManagedPrivateEndpointsListOptions) (ManagedPrivateEndpointsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ManagedPrivateEndpointsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagedPrivateEndpointsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagedPrivateEndpointsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *ManagedPrivateEndpointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ManagedPrivateEndpointsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ManagedPrivateEndpointsClient) listHandleResponse(resp *http.Response) (ManagedPrivateEndpointsListResponse, error) { + result := ManagedPrivateEndpointsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedPrivateEndpointListResult); err != nil { + return ManagedPrivateEndpointsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ManagedPrivateEndpointsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) BeginUpdate(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsBeginUpdateOptions) (ManagedPrivateEndpointsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, parameters, options) + if err != nil { + return ManagedPrivateEndpointsUpdatePollerResponse{}, err + } + result := ManagedPrivateEndpointsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ManagedPrivateEndpointsClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return ManagedPrivateEndpointsUpdatePollerResponse{}, err + } + result.Poller = &ManagedPrivateEndpointsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates a managed private endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *ManagedPrivateEndpointsClient) update(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, managedPrivateEndpointName, 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 *ManagedPrivateEndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if managedPrivateEndpointName == "" { + return nil, errors.New("parameter managedPrivateEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managedPrivateEndpointName}", url.PathEscape(managedPrivateEndpointName)) + 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-08-27") + 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 *ManagedPrivateEndpointsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_models.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_models.go new file mode 100644 index 000000000000..415430c3e06b --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_models.go @@ -0,0 +1,2709 @@ +//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 armkusto + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AcceptedAudiences - Represents an accepted audience trusted by the cluster. +type AcceptedAudiences struct { + // GUID or valid URL representing an accepted audience. + Value *string `json:"value,omitempty"` +} + +// AttachedDatabaseConfiguration - Class representing an attached database configuration. +type AttachedDatabaseConfiguration struct { + ProxyResource + // Resource location. + Location *string `json:"location,omitempty"` + + // The properties of the attached database configuration. + Properties *AttachedDatabaseConfigurationProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AttachedDatabaseConfiguration. +func (a AttachedDatabaseConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "location", a.Location) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AttachedDatabaseConfiguration. +func (a *AttachedDatabaseConfiguration) 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 "location": + err = unpopulate(val, &a.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := a.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// AttachedDatabaseConfigurationListResult - The list attached database configurations operation response. +type AttachedDatabaseConfigurationListResult struct { + // The list of attached database configurations. + Value []*AttachedDatabaseConfiguration `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AttachedDatabaseConfigurationListResult. +func (a AttachedDatabaseConfigurationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AttachedDatabaseConfigurationProperties - Class representing the an attached database configuration properties of kind specific. +type AttachedDatabaseConfigurationProperties struct { + // REQUIRED; The resource id of the cluster where the databases you would like to attach reside. + ClusterResourceID *string `json:"clusterResourceId,omitempty"` + + // REQUIRED; The name of the database which you would like to attach, use * if you want to follow all current and future databases. + DatabaseName *string `json:"databaseName,omitempty"` + + // REQUIRED; The default principals modification kind + DefaultPrincipalsModificationKind *DefaultPrincipalsModificationKind `json:"defaultPrincipalsModificationKind,omitempty"` + + // Table level sharing specifications + TableLevelSharingProperties *TableLevelSharingProperties `json:"tableLevelSharingProperties,omitempty"` + + // READ-ONLY; The list of databases from the clusterResourceId which are currently attached to the cluster. + AttachedDatabaseNames []*string `json:"attachedDatabaseNames,omitempty" azure:"ro"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AttachedDatabaseConfigurationProperties. +func (a AttachedDatabaseConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "attachedDatabaseNames", a.AttachedDatabaseNames) + populate(objectMap, "clusterResourceId", a.ClusterResourceID) + populate(objectMap, "databaseName", a.DatabaseName) + populate(objectMap, "defaultPrincipalsModificationKind", a.DefaultPrincipalsModificationKind) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "tableLevelSharingProperties", a.TableLevelSharingProperties) + return json.Marshal(objectMap) +} + +// AttachedDatabaseConfigurationsBeginCreateOrUpdateOptions contains the optional parameters for the AttachedDatabaseConfigurations.BeginCreateOrUpdate +// method. +type AttachedDatabaseConfigurationsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AttachedDatabaseConfigurationsBeginDeleteOptions contains the optional parameters for the AttachedDatabaseConfigurations.BeginDelete method. +type AttachedDatabaseConfigurationsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// AttachedDatabaseConfigurationsCheckNameAvailabilityOptions contains the optional parameters for the AttachedDatabaseConfigurations.CheckNameAvailability +// method. +type AttachedDatabaseConfigurationsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// AttachedDatabaseConfigurationsCheckNameRequest - The result returned from a AttachedDatabaseConfigurations check name availability request. +type AttachedDatabaseConfigurationsCheckNameRequest struct { + // REQUIRED; Attached database resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, for instance Microsoft.Kusto/clusters/attachedDatabaseConfigurations. + Type *string `json:"type,omitempty"` +} + +// AttachedDatabaseConfigurationsGetOptions contains the optional parameters for the AttachedDatabaseConfigurations.Get method. +type AttachedDatabaseConfigurationsGetOptions struct { + // placeholder for future optional parameters +} + +// AttachedDatabaseConfigurationsListByClusterOptions contains the optional parameters for the AttachedDatabaseConfigurations.ListByCluster method. +type AttachedDatabaseConfigurationsListByClusterOptions struct { + // placeholder for future optional parameters +} + +// AzureCapacity - Azure capacity definition. +type AzureCapacity struct { + // REQUIRED; The default capacity that would be used. + Default *int32 `json:"default,omitempty"` + + // REQUIRED; Maximum allowed capacity. + Maximum *int32 `json:"maximum,omitempty"` + + // REQUIRED; Minimum allowed capacity. + Minimum *int32 `json:"minimum,omitempty"` + + // REQUIRED; Scale type. + ScaleType *AzureScaleType `json:"scaleType,omitempty"` +} + +// AzureResourceSKU - Azure resource SKU definition. +type AzureResourceSKU struct { + // The number of instances of the cluster. + Capacity *AzureCapacity `json:"capacity,omitempty"` + + // Resource Namespace and Type. + ResourceType *string `json:"resourceType,omitempty"` + + // The SKU details. + SKU *AzureSKU `json:"sku,omitempty"` +} + +// AzureSKU - Azure SKU definition. +type AzureSKU struct { + // REQUIRED; SKU name. + Name *AzureSKUName `json:"name,omitempty"` + + // REQUIRED; SKU tier. + Tier *AzureSKUTier `json:"tier,omitempty"` + + // The number of instances of the cluster. + Capacity *int32 `json:"capacity,omitempty"` +} + +// CheckNameRequest - The result returned from a database check name availability request. +type CheckNameRequest struct { + // REQUIRED; Resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, for instance Microsoft.Kusto/clusters/databases. + Type *Type `json:"type,omitempty"` +} + +// CheckNameResult - The result returned from a check name availability request. +type CheckNameResult struct { + // Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. + Message *string `json:"message,omitempty"` + + // The name that was checked. + Name *string `json:"name,omitempty"` + + // Specifies a Boolean value that indicates if the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // Message providing the reason why the given name is invalid. + Reason *Reason `json:"reason,omitempty"` +} + +// CloudError - An error response from Kusto. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // An error response from Kusto. + InnerError *CloudErrorBody `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// CloudErrorBody - An error response from Kusto. +type CloudErrorBody struct { + // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBody `json:"details,omitempty"` + + // A message describing the error, intended to be suitable for displaying in a user interface. + Message *string `json:"message,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// Cluster - Class representing a Kusto cluster. +type Cluster struct { + TrackedResource + // REQUIRED; The SKU of the cluster. + SKU *AzureSKU `json:"sku,omitempty"` + + // The identity of the cluster, if configured. + Identity *Identity `json:"identity,omitempty"` + + // The cluster properties. + Properties *ClusterProperties `json:"properties,omitempty"` + + // The availability zones of the cluster. + Zones []*string `json:"zones,omitempty"` + + // READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "etag", c.Etag) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "zones", c.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Cluster. +func (c *Cluster) 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 "etag": + err = unpopulate(val, &c.Etag) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, &c.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &c.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, &c.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, &c.SystemData) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, &c.Zones) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := c.TrackedResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ClusterCheckNameRequest - The result returned from a cluster check name availability request. +type ClusterCheckNameRequest struct { + // REQUIRED; Cluster name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, Microsoft.Kusto/clusters. + Type *string `json:"type,omitempty"` +} + +// ClusterListResult - The list Kusto clusters operation response. +type ClusterListResult struct { + // The list of Kusto clusters. + Value []*Cluster `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterListResult. +func (c ClusterListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ClusterPrincipalAssignment - Class representing a cluster principal assignment. +type ClusterPrincipalAssignment struct { + ProxyResource + // The cluster principal. + Properties *ClusterPrincipalProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterPrincipalAssignment. +func (c ClusterPrincipalAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterPrincipalAssignment. +func (c *ClusterPrincipalAssignment) 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 "properties": + err = unpopulate(val, &c.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := c.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ClusterPrincipalAssignmentCheckNameRequest - A principal assignment check name availability request. +type ClusterPrincipalAssignmentCheckNameRequest struct { + // REQUIRED; Principal Assignment resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, Microsoft.Kusto/clusters/principalAssignments. + Type *string `json:"type,omitempty"` +} + +// ClusterPrincipalAssignmentListResult - The list Kusto cluster principal assignments operation response. +type ClusterPrincipalAssignmentListResult struct { + // The list of Kusto cluster principal assignments. + Value []*ClusterPrincipalAssignment `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterPrincipalAssignmentListResult. +func (c ClusterPrincipalAssignmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ClusterPrincipalAssignmentsBeginCreateOrUpdateOptions contains the optional parameters for the ClusterPrincipalAssignments.BeginCreateOrUpdate method. +type ClusterPrincipalAssignmentsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ClusterPrincipalAssignmentsBeginDeleteOptions contains the optional parameters for the ClusterPrincipalAssignments.BeginDelete method. +type ClusterPrincipalAssignmentsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClusterPrincipalAssignmentsCheckNameAvailabilityOptions contains the optional parameters for the ClusterPrincipalAssignments.CheckNameAvailability method. +type ClusterPrincipalAssignmentsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ClusterPrincipalAssignmentsGetOptions contains the optional parameters for the ClusterPrincipalAssignments.Get method. +type ClusterPrincipalAssignmentsGetOptions struct { + // placeholder for future optional parameters +} + +// ClusterPrincipalAssignmentsListOptions contains the optional parameters for the ClusterPrincipalAssignments.List method. +type ClusterPrincipalAssignmentsListOptions struct { + // placeholder for future optional parameters +} + +// ClusterPrincipalProperties - A class representing cluster principal property. +type ClusterPrincipalProperties struct { + // REQUIRED; The principal ID assigned to the cluster principal. It can be a user email, application ID, or security group name. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; Principal type. + PrincipalType *PrincipalType `json:"principalType,omitempty"` + + // REQUIRED; Cluster principal role. + Role *ClusterPrincipalRole `json:"role,omitempty"` + + // The tenant id of the principal + TenantID *string `json:"tenantId,omitempty"` + + // READ-ONLY; The principal name + PrincipalName *string `json:"principalName,omitempty" azure:"ro"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The tenant name of the principal + TenantName *string `json:"tenantName,omitempty" azure:"ro"` +} + +// ClusterProperties - Class representing the Kusto cluster properties. +type ClusterProperties struct { + // The cluster's accepted audiences. + AcceptedAudiences []*AcceptedAudiences `json:"acceptedAudiences,omitempty"` + + // List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. + AllowedFqdnList []*string `json:"allowedFqdnList,omitempty"` + + // The list of ips in the format of CIDR allowed to connect to the cluster. + AllowedIPRangeList []*string `json:"allowedIpRangeList,omitempty"` + + // A boolean value that indicates if the cluster could be automatically stopped (due to lack of data or no activity for many days). + EnableAutoStop *bool `json:"enableAutoStop,omitempty"` + + // A boolean value that indicates if the cluster's disks are encrypted. + EnableDiskEncryption *bool `json:"enableDiskEncryption,omitempty"` + + // A boolean value that indicates if double encryption is enabled. + EnableDoubleEncryption *bool `json:"enableDoubleEncryption,omitempty"` + + // A boolean value that indicates if the purge operations are enabled. + EnablePurge *bool `json:"enablePurge,omitempty"` + + // A boolean value that indicates if the streaming ingest is enabled. + EnableStreamingIngest *bool `json:"enableStreamingIngest,omitempty"` + + // The engine type + EngineType *EngineType `json:"engineType,omitempty"` + + // KeyVault properties for the cluster encryption. + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + + // Optimized auto scale definition. + OptimizedAutoscale *OptimizedAutoscale `json:"optimizedAutoscale,omitempty"` + + // Public network access to the cluster is enabled by default. When disabled, only private endpoint connection to the cluster is allowed + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // Whether or not to restrict outbound network access. Value is optional but if passed in, must be 'Enabled' or 'Disabled' + RestrictOutboundNetworkAccess *ClusterNetworkAccessFlag `json:"restrictOutboundNetworkAccess,omitempty"` + + // The cluster's external tenants. + TrustedExternalTenants []*TrustedExternalTenant `json:"trustedExternalTenants,omitempty"` + + // Virtual network definition. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + + // READ-ONLY; The cluster data ingestion URI. + DataIngestionURI *string `json:"dataIngestionUri,omitempty" azure:"ro"` + + // READ-ONLY; List of the cluster's language extensions. + LanguageExtensions *LanguageExtensionsList `json:"languageExtensions,omitempty" azure:"ro"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The state of the resource. + State *State `json:"state,omitempty" azure:"ro"` + + // READ-ONLY; The reason for the cluster's current state. + StateReason *string `json:"stateReason,omitempty" azure:"ro"` + + // READ-ONLY; The cluster URI. + URI *string `json:"uri,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterProperties. +func (c ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "acceptedAudiences", c.AcceptedAudiences) + populate(objectMap, "allowedFqdnList", c.AllowedFqdnList) + populate(objectMap, "allowedIpRangeList", c.AllowedIPRangeList) + populate(objectMap, "dataIngestionUri", c.DataIngestionURI) + populate(objectMap, "enableAutoStop", c.EnableAutoStop) + populate(objectMap, "enableDiskEncryption", c.EnableDiskEncryption) + populate(objectMap, "enableDoubleEncryption", c.EnableDoubleEncryption) + populate(objectMap, "enablePurge", c.EnablePurge) + populate(objectMap, "enableStreamingIngest", c.EnableStreamingIngest) + populate(objectMap, "engineType", c.EngineType) + populate(objectMap, "keyVaultProperties", c.KeyVaultProperties) + populate(objectMap, "languageExtensions", c.LanguageExtensions) + populate(objectMap, "optimizedAutoscale", c.OptimizedAutoscale) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "publicNetworkAccess", c.PublicNetworkAccess) + populate(objectMap, "restrictOutboundNetworkAccess", c.RestrictOutboundNetworkAccess) + populate(objectMap, "state", c.State) + populate(objectMap, "stateReason", c.StateReason) + populate(objectMap, "trustedExternalTenants", c.TrustedExternalTenants) + populate(objectMap, "uri", c.URI) + populate(objectMap, "virtualNetworkConfiguration", c.VirtualNetworkConfiguration) + return json.Marshal(objectMap) +} + +// ClusterUpdate - Class representing an update to a Kusto cluster. +type ClusterUpdate struct { + Resource + // The identity of the cluster, if configured. + Identity *Identity `json:"identity,omitempty"` + + // Resource location. + Location *string `json:"location,omitempty"` + + // The cluster properties. + Properties *ClusterProperties `json:"properties,omitempty"` + + // The SKU of the cluster. + SKU *AzureSKU `json:"sku,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterUpdate. +func (c ClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "location", c.Location) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterUpdate. +func (c *ClusterUpdate) 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 "identity": + err = unpopulate(val, &c.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, &c.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &c.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, &c.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := c.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ClustersBeginAddLanguageExtensionsOptions contains the optional parameters for the Clusters.BeginAddLanguageExtensions method. +type ClustersBeginAddLanguageExtensionsOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginCreateOrUpdateOptions contains the optional parameters for the Clusters.BeginCreateOrUpdate method. +type ClustersBeginCreateOrUpdateOptions struct { + // The ETag of the cluster. Omit this value to always overwrite the current cluster. Specify the last-seen ETag value to prevent accidentally overwriting + // concurrent changes. + IfMatch *string + // Set to '*' to allow a new cluster to be created, but to prevent updating an existing cluster. Other values will result in a 412 Pre-condition Failed + // response. + IfNoneMatch *string +} + +// ClustersBeginDeleteOptions contains the optional parameters for the Clusters.BeginDelete method. +type ClustersBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginDetachFollowerDatabasesOptions contains the optional parameters for the Clusters.BeginDetachFollowerDatabases method. +type ClustersBeginDetachFollowerDatabasesOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginDiagnoseVirtualNetworkOptions contains the optional parameters for the Clusters.BeginDiagnoseVirtualNetwork method. +type ClustersBeginDiagnoseVirtualNetworkOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginRemoveLanguageExtensionsOptions contains the optional parameters for the Clusters.BeginRemoveLanguageExtensions method. +type ClustersBeginRemoveLanguageExtensionsOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginStartOptions contains the optional parameters for the Clusters.BeginStart method. +type ClustersBeginStartOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginStopOptions contains the optional parameters for the Clusters.BeginStop method. +type ClustersBeginStopOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginUpdateOptions contains the optional parameters for the Clusters.BeginUpdate method. +type ClustersBeginUpdateOptions struct { + // The ETag of the cluster. Omit this value to always overwrite the current cluster. Specify the last-seen ETag value to prevent accidentally overwriting + // concurrent changes. + IfMatch *string +} + +// ClustersCheckNameAvailabilityOptions contains the optional parameters for the Clusters.CheckNameAvailability method. +type ClustersCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ClustersGetOptions contains the optional parameters for the Clusters.Get method. +type ClustersGetOptions struct { + // placeholder for future optional parameters +} + +// ClustersListByResourceGroupOptions contains the optional parameters for the Clusters.ListByResourceGroup method. +type ClustersListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClustersListFollowerDatabasesOptions contains the optional parameters for the Clusters.ListFollowerDatabases method. +type ClustersListFollowerDatabasesOptions struct { + // placeholder for future optional parameters +} + +// ClustersListLanguageExtensionsOptions contains the optional parameters for the Clusters.ListLanguageExtensions method. +type ClustersListLanguageExtensionsOptions struct { + // placeholder for future optional parameters +} + +// ClustersListOptions contains the optional parameters for the Clusters.List method. +type ClustersListOptions struct { + // placeholder for future optional parameters +} + +// ClustersListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the Clusters.ListOutboundNetworkDependenciesEndpoints method. +type ClustersListOutboundNetworkDependenciesEndpointsOptions struct { + // placeholder for future optional parameters +} + +// ClustersListSKUsByResourceOptions contains the optional parameters for the Clusters.ListSKUsByResource method. +type ClustersListSKUsByResourceOptions struct { + // placeholder for future optional parameters +} + +// ClustersListSKUsOptions contains the optional parameters for the Clusters.ListSKUs method. +type ClustersListSKUsOptions struct { + // placeholder for future optional parameters +} + +type ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// DataConnectionClassification provides polymorphic access to related types. +// Call the interface's GetDataConnection() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DataConnection, *EventGridDataConnection, *EventHubDataConnection, *IotHubDataConnection +type DataConnectionClassification interface { + // GetDataConnection returns the DataConnection content of the underlying type. + GetDataConnection() *DataConnection +} + +// DataConnection - Class representing an data connection. +type DataConnection struct { + ProxyResource + // REQUIRED; Kind of the endpoint for the data connection + Kind *DataConnectionKind `json:"kind,omitempty"` + + // Resource location. + Location *string `json:"location,omitempty"` +} + +// GetDataConnection implements the DataConnectionClassification interface for type DataConnection. +func (d *DataConnection) GetDataConnection() *DataConnection { return d } + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnection. +func (d *DataConnection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return d.unmarshalInternal(rawMsg) +} + +func (d DataConnection) marshalInternal(objectMap map[string]interface{}, discValue DataConnectionKind) { + d.ProxyResource.marshalInternal(objectMap) + d.Kind = &discValue + objectMap["kind"] = d.Kind + populate(objectMap, "location", d.Location) +} + +func (d *DataConnection) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, &d.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, &d.Location) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := d.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// DataConnectionCheckNameRequest - A data connection check name availability request. +type DataConnectionCheckNameRequest struct { + // REQUIRED; Data Connection name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, Microsoft.Kusto/clusters/databases/dataConnections. + Type *string `json:"type,omitempty"` +} + +// DataConnectionListResult - The list Kusto data connections operation response. +type DataConnectionListResult struct { + // The list of Kusto data connections. + Value []DataConnectionClassification `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataConnectionListResult. +func (d DataConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionListResult. +func (d *DataConnectionListResult) 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 "value": + d.Value, err = unmarshalDataConnectionClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// DataConnectionValidation - Class representing an data connection validation. +type DataConnectionValidation struct { + // The name of the data connection. + DataConnectionName *string `json:"dataConnectionName,omitempty"` + + // The data connection properties to validate. + Properties DataConnectionClassification `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataConnectionValidation. +func (d DataConnectionValidation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataConnectionName", d.DataConnectionName) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionValidation. +func (d *DataConnectionValidation) 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 "dataConnectionName": + err = unpopulate(val, &d.DataConnectionName) + delete(rawMsg, key) + case "properties": + d.Properties, err = unmarshalDataConnectionClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// DataConnectionValidationListResult - The list Kusto data connection validation result. +type DataConnectionValidationListResult struct { + // The list of Kusto data connection validation errors. + Value []*DataConnectionValidationResult `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataConnectionValidationListResult. +func (d DataConnectionValidationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DataConnectionValidationResult - The result returned from a data connection validation request. +type DataConnectionValidationResult struct { + // A message which indicates a problem in data connection validation. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// DataConnectionsBeginCreateOrUpdateOptions contains the optional parameters for the DataConnections.BeginCreateOrUpdate method. +type DataConnectionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DataConnectionsBeginDataConnectionValidationOptions contains the optional parameters for the DataConnections.BeginDataConnectionValidation method. +type DataConnectionsBeginDataConnectionValidationOptions struct { + // placeholder for future optional parameters +} + +// DataConnectionsBeginDeleteOptions contains the optional parameters for the DataConnections.BeginDelete method. +type DataConnectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DataConnectionsBeginUpdateOptions contains the optional parameters for the DataConnections.BeginUpdate method. +type DataConnectionsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// DataConnectionsCheckNameAvailabilityOptions contains the optional parameters for the DataConnections.CheckNameAvailability method. +type DataConnectionsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// DataConnectionsGetOptions contains the optional parameters for the DataConnections.Get method. +type DataConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// DataConnectionsListByDatabaseOptions contains the optional parameters for the DataConnections.ListByDatabase method. +type DataConnectionsListByDatabaseOptions struct { + // placeholder for future optional parameters +} + +// DatabaseClassification provides polymorphic access to related types. +// Call the interface's GetDatabase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *Database, *ReadOnlyFollowingDatabase, *ReadWriteDatabase +type DatabaseClassification interface { + // GetDatabase returns the Database content of the underlying type. + GetDatabase() *Database +} + +// Database - Class representing a Kusto database. +type Database struct { + ProxyResource + // REQUIRED; Kind of the database + Kind *Kind `json:"kind,omitempty"` + + // Resource location. + Location *string `json:"location,omitempty"` +} + +// GetDatabase implements the DatabaseClassification interface for type Database. +func (d *Database) GetDatabase() *Database { return d } + +// UnmarshalJSON implements the json.Unmarshaller interface for type Database. +func (d *Database) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return d.unmarshalInternal(rawMsg) +} + +func (d Database) marshalInternal(objectMap map[string]interface{}, discValue Kind) { + d.ProxyResource.marshalInternal(objectMap) + d.Kind = &discValue + objectMap["kind"] = d.Kind + populate(objectMap, "location", d.Location) +} + +func (d *Database) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, &d.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, &d.Location) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := d.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// DatabaseListResult - The list Kusto databases operation response. +type DatabaseListResult struct { + // The list of Kusto databases. + Value []DatabaseClassification `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatabaseListResult. +func (d DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabaseListResult. +func (d *DatabaseListResult) 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 "value": + d.Value, err = unmarshalDatabaseClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// DatabasePrincipal - A class representing database principal entity. +type DatabasePrincipal struct { + // REQUIRED; Database principal name. + Name *string `json:"name,omitempty"` + + // REQUIRED; Database principal role. + Role *DatabasePrincipalRole `json:"role,omitempty"` + + // REQUIRED; Database principal type. + Type *DatabasePrincipalType `json:"type,omitempty"` + + // Application id - relevant only for application principal type. + AppID *string `json:"appId,omitempty"` + + // Database principal email if exists. + Email *string `json:"email,omitempty"` + + // Database principal fully qualified name. + Fqn *string `json:"fqn,omitempty"` + + // READ-ONLY; The tenant name of the principal + TenantName *string `json:"tenantName,omitempty" azure:"ro"` +} + +// DatabasePrincipalAssignment - Class representing a database principal assignment. +type DatabasePrincipalAssignment struct { + ProxyResource + // The database principal. + Properties *DatabasePrincipalProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatabasePrincipalAssignment. +func (d DatabasePrincipalAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + d.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabasePrincipalAssignment. +func (d *DatabasePrincipalAssignment) 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 "properties": + err = unpopulate(val, &d.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := d.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// DatabasePrincipalAssignmentCheckNameRequest - A principal assignment check name availability request. +type DatabasePrincipalAssignmentCheckNameRequest struct { + // REQUIRED; Principal Assignment resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, Microsoft.Kusto/clusters/databases/principalAssignments. + Type *string `json:"type,omitempty"` +} + +// DatabasePrincipalAssignmentListResult - The list Kusto database principal assignments operation response. +type DatabasePrincipalAssignmentListResult struct { + // The list of Kusto database principal assignments. + Value []*DatabasePrincipalAssignment `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatabasePrincipalAssignmentListResult. +func (d DatabasePrincipalAssignmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DatabasePrincipalAssignmentsBeginCreateOrUpdateOptions contains the optional parameters for the DatabasePrincipalAssignments.BeginCreateOrUpdate method. +type DatabasePrincipalAssignmentsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DatabasePrincipalAssignmentsBeginDeleteOptions contains the optional parameters for the DatabasePrincipalAssignments.BeginDelete method. +type DatabasePrincipalAssignmentsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DatabasePrincipalAssignmentsCheckNameAvailabilityOptions contains the optional parameters for the DatabasePrincipalAssignments.CheckNameAvailability +// method. +type DatabasePrincipalAssignmentsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// DatabasePrincipalAssignmentsGetOptions contains the optional parameters for the DatabasePrincipalAssignments.Get method. +type DatabasePrincipalAssignmentsGetOptions struct { + // placeholder for future optional parameters +} + +// DatabasePrincipalAssignmentsListOptions contains the optional parameters for the DatabasePrincipalAssignments.List method. +type DatabasePrincipalAssignmentsListOptions struct { + // placeholder for future optional parameters +} + +// DatabasePrincipalListRequest - The list Kusto database principals operation request. +type DatabasePrincipalListRequest struct { + // The list of Kusto database principals. + Value []*DatabasePrincipal `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatabasePrincipalListRequest. +func (d DatabasePrincipalListRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DatabasePrincipalListResult - The list Kusto database principals operation response. +type DatabasePrincipalListResult struct { + // The list of Kusto database principals. + Value []*DatabasePrincipal `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatabasePrincipalListResult. +func (d DatabasePrincipalListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DatabasePrincipalProperties - A class representing database principal property. +type DatabasePrincipalProperties struct { + // REQUIRED; The principal ID assigned to the database principal. It can be a user email, application ID, or security group name. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; Principal type. + PrincipalType *PrincipalType `json:"principalType,omitempty"` + + // REQUIRED; Database principal role. + Role *DatabasePrincipalRole `json:"role,omitempty"` + + // The tenant id of the principal + TenantID *string `json:"tenantId,omitempty"` + + // READ-ONLY; The principal name + PrincipalName *string `json:"principalName,omitempty" azure:"ro"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The tenant name of the principal + TenantName *string `json:"tenantName,omitempty" azure:"ro"` +} + +// DatabaseStatistics - A class that contains database statistics information. +type DatabaseStatistics struct { + // The database size - the total size of compressed data and index in bytes. + Size *float32 `json:"size,omitempty"` +} + +// DatabasesAddPrincipalsOptions contains the optional parameters for the Databases.AddPrincipals method. +type DatabasesAddPrincipalsOptions struct { + // placeholder for future optional parameters +} + +// DatabasesBeginCreateOrUpdateOptions contains the optional parameters for the Databases.BeginCreateOrUpdate method. +type DatabasesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DatabasesBeginDeleteOptions contains the optional parameters for the Databases.BeginDelete method. +type DatabasesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DatabasesBeginUpdateOptions contains the optional parameters for the Databases.BeginUpdate method. +type DatabasesBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// DatabasesCheckNameAvailabilityOptions contains the optional parameters for the Databases.CheckNameAvailability method. +type DatabasesCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// DatabasesGetOptions contains the optional parameters for the Databases.Get method. +type DatabasesGetOptions struct { + // placeholder for future optional parameters +} + +// DatabasesListByClusterOptions contains the optional parameters for the Databases.ListByCluster method. +type DatabasesListByClusterOptions struct { + // placeholder for future optional parameters +} + +// DatabasesListPrincipalsOptions contains the optional parameters for the Databases.ListPrincipals method. +type DatabasesListPrincipalsOptions struct { + // placeholder for future optional parameters +} + +// DatabasesRemovePrincipalsOptions contains the optional parameters for the Databases.RemovePrincipals method. +type DatabasesRemovePrincipalsOptions struct { + // placeholder for future optional parameters +} + +type DiagnoseVirtualNetworkResult struct { + // The list of network connectivity diagnostic finding + Findings []*string `json:"findings,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnoseVirtualNetworkResult. +func (d DiagnoseVirtualNetworkResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "findings", d.Findings) + return json.Marshal(objectMap) +} + +// EndpointDependency - A domain name that a service is reached at, including details of the current connection status. +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 - Current TCP connectivity information from the Kusto cluster to a single endpoint. +type EndpointDetail struct { + // The port an endpoint is connected to. + Port *int32 `json:"port,omitempty"` +} + +// EventGridConnectionProperties - Class representing the Kusto event grid connection properties. +type EventGridConnectionProperties struct { + // REQUIRED; The event hub consumer group. + ConsumerGroup *string `json:"consumerGroup,omitempty"` + + // REQUIRED; The resource ID where the event grid is configured to send events. + EventHubResourceID *string `json:"eventHubResourceId,omitempty"` + + // REQUIRED; The resource ID of the storage account where the data resides. + StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty"` + + // The name of blob storage event type to process. + BlobStorageEventType *BlobStorageEventType `json:"blobStorageEventType,omitempty"` + + // The data format of the message. Optionally the data format can be added to each message. + DataFormat *EventGridDataFormat `json:"dataFormat,omitempty"` + + // A Boolean value that, if set to true, indicates that ingestion should ignore the first record of every file + IgnoreFirstRecord *bool `json:"ignoreFirstRecord,omitempty"` + + // The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each message. + MappingRuleName *string `json:"mappingRuleName,omitempty"` + + // The table where the data should be ingested. Optionally the table information can be added to each message. + TableName *string `json:"tableName,omitempty"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// EventGridDataConnection - Class representing an Event Grid data connection. +type EventGridDataConnection struct { + DataConnection + // The properties of the Event Grid data connection. + Properties *EventGridConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventGridDataConnection. +func (e EventGridDataConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.DataConnection.marshalInternal(objectMap, DataConnectionKindEventGrid) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGridDataConnection. +func (e *EventGridDataConnection) 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 "properties": + err = unpopulate(val, &e.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.DataConnection.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// EventHubConnectionProperties - Class representing the Kusto event hub connection properties. +type EventHubConnectionProperties struct { + // REQUIRED; The event hub consumer group. + ConsumerGroup *string `json:"consumerGroup,omitempty"` + + // REQUIRED; The resource ID of the event hub to be used to create a data connection. + EventHubResourceID *string `json:"eventHubResourceId,omitempty"` + + // The event hub messages compression type + Compression *Compression `json:"compression,omitempty"` + + // The data format of the message. Optionally the data format can be added to each message. + DataFormat *EventHubDataFormat `json:"dataFormat,omitempty"` + + // System properties of the event hub + EventSystemProperties []*string `json:"eventSystemProperties,omitempty"` + + // The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub. + ManagedIdentityResourceID *string `json:"managedIdentityResourceId,omitempty"` + + // The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each message. + MappingRuleName *string `json:"mappingRuleName,omitempty"` + + // The table where the data should be ingested. Optionally the table information can be added to each message. + TableName *string `json:"tableName,omitempty"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventHubConnectionProperties. +func (e EventHubConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "compression", e.Compression) + populate(objectMap, "consumerGroup", e.ConsumerGroup) + populate(objectMap, "dataFormat", e.DataFormat) + populate(objectMap, "eventHubResourceId", e.EventHubResourceID) + populate(objectMap, "eventSystemProperties", e.EventSystemProperties) + populate(objectMap, "managedIdentityResourceId", e.ManagedIdentityResourceID) + populate(objectMap, "mappingRuleName", e.MappingRuleName) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "tableName", e.TableName) + return json.Marshal(objectMap) +} + +// EventHubDataConnection - Class representing an event hub data connection. +type EventHubDataConnection struct { + DataConnection + // The Event Hub data connection properties to validate. + Properties *EventHubConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventHubDataConnection. +func (e EventHubDataConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.DataConnection.marshalInternal(objectMap, DataConnectionKindEventHub) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubDataConnection. +func (e *EventHubDataConnection) 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 "properties": + err = unpopulate(val, &e.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.DataConnection.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// FollowerDatabaseDefinition - A class representing follower database request. +type FollowerDatabaseDefinition struct { + // REQUIRED; Resource name of the attached database configuration in the follower cluster. + AttachedDatabaseConfigurationName *string `json:"attachedDatabaseConfigurationName,omitempty"` + + // REQUIRED; Resource id of the cluster that follows a database owned by this cluster. + ClusterResourceID *string `json:"clusterResourceId,omitempty"` + + // READ-ONLY; The database name owned by this cluster that was followed. * in case following all databases. + DatabaseName *string `json:"databaseName,omitempty" azure:"ro"` +} + +// FollowerDatabaseListResult - The list Kusto database principals operation response. +type FollowerDatabaseListResult struct { + // The list of follower database result. + Value []*FollowerDatabaseDefinition `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type FollowerDatabaseListResult. +func (f FollowerDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// Identity for the resource. +type Identity struct { + // REQUIRED; The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned + // identities. The type 'None' will remove all + // identities. + Type *IdentityType `json:"type,omitempty"` + + // The list of user identities associated with the Kusto cluster. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// IotHubConnectionProperties - Class representing the Kusto Iot hub connection properties. +type IotHubConnectionProperties struct { + // REQUIRED; The iot hub consumer group. + ConsumerGroup *string `json:"consumerGroup,omitempty"` + + // REQUIRED; The resource ID of the Iot hub to be used to create a data connection. + IotHubResourceID *string `json:"iotHubResourceId,omitempty"` + + // REQUIRED; The name of the share access policy + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + + // The data format of the message. Optionally the data format can be added to each message. + DataFormat *IotHubDataFormat `json:"dataFormat,omitempty"` + + // System properties of the iot hub + EventSystemProperties []*string `json:"eventSystemProperties,omitempty"` + + // The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each message. + MappingRuleName *string `json:"mappingRuleName,omitempty"` + + // The table where the data should be ingested. Optionally the table information can be added to each message. + TableName *string `json:"tableName,omitempty"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubConnectionProperties. +func (i IotHubConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "consumerGroup", i.ConsumerGroup) + populate(objectMap, "dataFormat", i.DataFormat) + populate(objectMap, "eventSystemProperties", i.EventSystemProperties) + populate(objectMap, "iotHubResourceId", i.IotHubResourceID) + populate(objectMap, "mappingRuleName", i.MappingRuleName) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "sharedAccessPolicyName", i.SharedAccessPolicyName) + populate(objectMap, "tableName", i.TableName) + return json.Marshal(objectMap) +} + +// IotHubDataConnection - Class representing an iot hub data connection. +type IotHubDataConnection struct { + DataConnection + // The Iot Hub data connection properties. + Properties *IotHubConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IotHubDataConnection. +func (i IotHubDataConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + i.DataConnection.marshalInternal(objectMap, DataConnectionKindIotHub) + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IotHubDataConnection. +func (i *IotHubDataConnection) 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 "properties": + err = unpopulate(val, &i.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := i.DataConnection.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// KeyVaultProperties - Properties of the key vault. +type KeyVaultProperties struct { + // The name of the key vault key. + KeyName *string `json:"keyName,omitempty"` + + // The Uri of the key vault. + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + + // The version of the key vault key. + KeyVersion *string `json:"keyVersion,omitempty"` + + // The user assigned identity (ARM resource id) that has access to the key. + UserIdentity *string `json:"userIdentity,omitempty"` +} + +// LanguageExtension - The language extension object. +type LanguageExtension struct { + // The language extension name. + LanguageExtensionName *LanguageExtensionName `json:"languageExtensionName,omitempty"` +} + +// LanguageExtensionsList - The list of language extension objects. +type LanguageExtensionsList struct { + // The list of language extensions. + Value []*LanguageExtension `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LanguageExtensionsList. +func (l LanguageExtensionsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// ListResourceSKUsResult - List of available SKUs for a Kusto Cluster. +type ListResourceSKUsResult struct { + // The collection of available SKUs for an existing resource. + Value []*AzureResourceSKU `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ListResourceSKUsResult. +func (l ListResourceSKUsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// ManagedPrivateEndpoint - Class representing a managed private endpoint. +type ManagedPrivateEndpoint struct { + ProxyResource + // A managed private endpoint. + Properties *ManagedPrivateEndpointProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedPrivateEndpoint. +func (m ManagedPrivateEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + m.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "systemData", m.SystemData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedPrivateEndpoint. +func (m *ManagedPrivateEndpoint) 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 "properties": + err = unpopulate(val, &m.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, &m.SystemData) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := m.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ManagedPrivateEndpointListResult - The list managed private endpoints operation response. +type ManagedPrivateEndpointListResult struct { + // The list of managed private endpoints. + Value []*ManagedPrivateEndpoint `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedPrivateEndpointListResult. +func (m ManagedPrivateEndpointListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// ManagedPrivateEndpointProperties - A class representing the properties of a managed private endpoint object. +type ManagedPrivateEndpointProperties struct { + // REQUIRED; The groupId in which the managed private endpoint is created. + GroupID *string `json:"groupId,omitempty"` + + // REQUIRED; The ARM resource ID of the resource for which the managed private endpoint is created. + PrivateLinkResourceID *string `json:"privateLinkResourceId,omitempty"` + + // The region of the resource to which the managed private endpoint is created. + PrivateLinkResourceRegion *string `json:"privateLinkResourceRegion,omitempty"` + + // The user request message. + RequestMessage *string `json:"requestMessage,omitempty"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// ManagedPrivateEndpointsBeginCreateOrUpdateOptions contains the optional parameters for the ManagedPrivateEndpoints.BeginCreateOrUpdate method. +type ManagedPrivateEndpointsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ManagedPrivateEndpointsBeginDeleteOptions contains the optional parameters for the ManagedPrivateEndpoints.BeginDelete method. +type ManagedPrivateEndpointsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ManagedPrivateEndpointsBeginUpdateOptions contains the optional parameters for the ManagedPrivateEndpoints.BeginUpdate method. +type ManagedPrivateEndpointsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ManagedPrivateEndpointsCheckNameAvailabilityOptions contains the optional parameters for the ManagedPrivateEndpoints.CheckNameAvailability method. +type ManagedPrivateEndpointsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ManagedPrivateEndpointsCheckNameRequest - The result returned from a managedPrivateEndpoints check name availability request. +type ManagedPrivateEndpointsCheckNameRequest struct { + // REQUIRED; Managed private endpoint resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, for instance Microsoft.Kusto/clusters/managedPrivateEndpoints. + Type *string `json:"type,omitempty"` +} + +// ManagedPrivateEndpointsGetOptions contains the optional parameters for the ManagedPrivateEndpoints.Get method. +type ManagedPrivateEndpointsGetOptions struct { + // placeholder for future optional parameters +} + +// ManagedPrivateEndpointsListOptions contains the optional parameters for the ManagedPrivateEndpoints.List method. +type ManagedPrivateEndpointsListOptions struct { + // placeholder for future optional parameters +} + +// Operation - A REST API operation +type Operation struct { + // The object that describes the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // This is of the format {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + + // The intended executor of the operation. + Origin *string `json:"origin,omitempty"` + + // Any object + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// OperationDisplay - The object that describes the operation. +type OperationDisplay struct { + // The friendly name of the operation. + Description *string `json:"description,omitempty"` + + // For example: read, write, delete. + Operation *string `json:"operation,omitempty"` + + // Friendly name of the resource provider. + Provider *string `json:"provider,omitempty"` + + // The resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. +type OperationListResult struct { + // The URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // The list of operations supported by the 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) +} + +// OperationResult - Operation Result Entity. +type OperationResult struct { + // The operation end time + EndTime *time.Time `json:"endTime,omitempty"` + + // Object that contains the error code and message if the operation failed. + Error *OperationResultErrorProperties `json:"error,omitempty"` + + // Percentage completed. + PercentComplete *float64 `json:"percentComplete,omitempty"` + + // Properties of the operation results + Properties *OperationResultProperties `json:"properties,omitempty"` + + // The operation start time + StartTime *time.Time `json:"startTime,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; status of the Operation result. + Status *Status `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationResult. +func (o OperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "percentComplete", o.PercentComplete) + populate(objectMap, "properties", o.Properties) + populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. +func (o *OperationResult) 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 "endTime": + err = unpopulateTimeRFC3339(val, &o.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &o.Name) + delete(rawMsg, key) + case "percentComplete": + err = unpopulate(val, &o.PercentComplete) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &o.Properties) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &o.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// OperationResultErrorProperties - Operation result error properties +type OperationResultErrorProperties struct { + // The code of the error. + Code *string `json:"code,omitempty"` + + // The error message. + Message *string `json:"message,omitempty"` +} + +// OperationResultProperties - Operation result properties +type OperationResultProperties struct { + // The kind of the operation. + OperationKind *string `json:"operationKind,omitempty"` + + // The state of the operation. + OperationState *string `json:"operationState,omitempty"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// OperationsResultsGetOptions contains the optional parameters for the OperationsResults.Get method. +type OperationsResultsGetOptions struct { + // placeholder for future optional parameters +} + +// OptimizedAutoscale - A class that contains the optimized auto scale definition. +type OptimizedAutoscale struct { + // REQUIRED; A boolean value that indicate if the optimized autoscale feature is enabled or not. + IsEnabled *bool `json:"isEnabled,omitempty"` + + // REQUIRED; Maximum allowed instances count. + Maximum *int32 `json:"maximum,omitempty"` + + // REQUIRED; Minimum allowed instances count. + Minimum *int32 `json:"minimum,omitempty"` + + // REQUIRED; The version of the template defined, for instance 1. + Version *int32 `json:"version,omitempty"` +} + +// OutboundNetworkDependenciesEndpoint - Endpoints accessed for a common purpose that the Kusto Service Environment requires outbound network access to. +type OutboundNetworkDependenciesEndpoint struct { + ProxyResource + // The outbound environment endpoint properties. + Properties *OutboundNetworkDependenciesEndpointProperties `json:"properties,omitempty"` + + // READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OutboundNetworkDependenciesEndpoint. +func (o OutboundNetworkDependenciesEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + o.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "etag", o.Etag) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutboundNetworkDependenciesEndpoint. +func (o *OutboundNetworkDependenciesEndpoint) 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 "etag": + err = unpopulate(val, &o.Etag) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := o.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// OutboundNetworkDependenciesEndpointListResult - Collection of Outbound Environment Endpoints +type OutboundNetworkDependenciesEndpointListResult struct { + // REQUIRED; Collection of resources. + Value []*OutboundNetworkDependenciesEndpoint `json:"value,omitempty"` + + // READ-ONLY; Link to next page of resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OutboundNetworkDependenciesEndpointListResult. +func (o OutboundNetworkDependenciesEndpointListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OutboundNetworkDependenciesEndpointProperties - Endpoints accessed for a common purpose that the Kusto Service Environment requires outbound network +// access to. +type OutboundNetworkDependenciesEndpointProperties struct { + // The type of service accessed by the Kusto Service Environment, e.g., Azure Storage, Azure SQL Database, and Azure Active Directory. + Category *string `json:"category,omitempty"` + + // The endpoints that the Kusto Service Environment reaches the service at. + Endpoints []*EndpointDependency `json:"endpoints,omitempty"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OutboundNetworkDependenciesEndpointProperties. +func (o OutboundNetworkDependenciesEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", o.Category) + populate(objectMap, "endpoints", o.Endpoints) + populate(objectMap, "provisioningState", o.ProvisioningState) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection - A private endpoint connection +type PrivateEndpointConnection struct { + ProxyResource + // Resource properties. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnection. +func (p *PrivateEndpointConnection) 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 "properties": + err = unpopulate(val, &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, &p.SystemData) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// PrivateEndpointConnectionListResult - A list of private endpoint connections +type PrivateEndpointConnectionListResult struct { + // Array of private endpoint connections + Value []*PrivateEndpointConnection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties - Properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // REQUIRED; Connection State of the Private Endpoint Connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + + // READ-ONLY; Group id of the private endpoint. + GroupID *string `json:"groupId,omitempty" azure:"ro"` + + // READ-ONLY; Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the private endpoint. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionsBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnections.BeginCreateOrUpdate method. +type PrivateEndpointConnectionsBeginCreateOrUpdateOptions 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 +} + +// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. +type PrivateEndpointConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointProperty - Private endpoint which the connection belongs to. +type PrivateEndpointProperty struct { + // READ-ONLY; Resource id of the private endpoint. + ID *string `json:"id,omitempty" azure:"ro"` +} + +// PrivateLinkResource - A private link resource +type PrivateLinkResource struct { + Resource + // Resource properties. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. +func (p *PrivateLinkResource) 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 "properties": + err = unpopulate(val, &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, &p.SystemData) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// PrivateLinkResourceListResult - A list of private link resources +type PrivateLinkResourceListResult struct { + // Array of private link resources + Value []*PrivateLinkResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceProperties - Properties of a private link resource. +type PrivateLinkResourceProperties struct { + // READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty" azure:"ro"` + + // READ-ONLY; The private link resource required member names. + RequiredMembers []*string `json:"requiredMembers,omitempty" azure:"ro"` + + // READ-ONLY; The private link resource required zone names. + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// PrivateLinkResourcesGetOptions contains the optional parameters for the PrivateLinkResources.Get method. +type PrivateLinkResourcesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesListOptions contains the optional parameters for the PrivateLinkResources.List method. +type PrivateLinkResourcesListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkServiceConnectionStateProperty - Connection State of the Private Endpoint Connection. +type PrivateLinkServiceConnectionStateProperty struct { + // The private link service connection description. + Description *string `json:"description,omitempty"` + + // The private link service connection status. + Status *string `json:"status,omitempty"` + + // READ-ONLY; Any action that is required beyond basic workflow (approve/ reject/ disconnect) + ActionsRequired *string `json:"actionsRequired,omitempty" azure:"ro"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal(objectMap map[string]interface{}) { + p.Resource.marshalInternal(objectMap) +} + +func (p *ProxyResource) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + if err := p.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ReadOnlyFollowingDatabase - Class representing a read only following database. +type ReadOnlyFollowingDatabase struct { + Database + // The database properties. + Properties *ReadOnlyFollowingDatabaseProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReadOnlyFollowingDatabase. +func (r ReadOnlyFollowingDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.Database.marshalInternal(objectMap, KindReadOnlyFollowing) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReadOnlyFollowingDatabase. +func (r *ReadOnlyFollowingDatabase) 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 "properties": + err = unpopulate(val, &r.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := r.Database.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ReadOnlyFollowingDatabaseProperties - Class representing the Kusto database properties. +type ReadOnlyFollowingDatabaseProperties struct { + // The time the data should be kept in cache for fast queries in TimeSpan. + HotCachePeriod *string `json:"hotCachePeriod,omitempty"` + + // READ-ONLY; The name of the attached database configuration cluster + AttachedDatabaseConfigurationName *string `json:"attachedDatabaseConfigurationName,omitempty" azure:"ro"` + + // READ-ONLY; The name of the leader cluster + LeaderClusterResourceID *string `json:"leaderClusterResourceId,omitempty" azure:"ro"` + + // READ-ONLY; The principals modification kind of the database + PrincipalsModificationKind *PrincipalsModificationKind `json:"principalsModificationKind,omitempty" azure:"ro"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The time the data should be kept before it stops being accessible to queries in TimeSpan. + SoftDeletePeriod *string `json:"softDeletePeriod,omitempty" azure:"ro"` + + // READ-ONLY; The statistics of the database. + Statistics *DatabaseStatistics `json:"statistics,omitempty" azure:"ro"` +} + +// ReadWriteDatabase - Class representing a read write database. +type ReadWriteDatabase struct { + Database + // The database properties. + Properties *ReadWriteDatabaseProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReadWriteDatabase. +func (r ReadWriteDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.Database.marshalInternal(objectMap, KindReadWrite) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReadWriteDatabase. +func (r *ReadWriteDatabase) 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 "properties": + err = unpopulate(val, &r.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := r.Database.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ReadWriteDatabaseProperties - Class representing the Kusto database properties. +type ReadWriteDatabaseProperties struct { + // The time the data should be kept in cache for fast queries in TimeSpan. + HotCachePeriod *string `json:"hotCachePeriod,omitempty"` + + // The time the data should be kept before it stops being accessible to queries in TimeSpan. + SoftDeletePeriod *string `json:"softDeletePeriod,omitempty"` + + // READ-ONLY; Indicates whether the database is followed. + IsFollowed *bool `json:"isFollowed,omitempty" azure:"ro"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The statistics of the database. + Statistics *DatabaseStatistics `json:"statistics,omitempty" azure:"ro"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager 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. E.g. "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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return r.unmarshalInternal(rawMsg) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +func (r *Resource) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &r.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SKUDescription - The Kusto SKU description of given resource type +type SKUDescription struct { + // READ-ONLY; Locations and zones + LocationInfo []*SKULocationInfoItem `json:"locationInfo,omitempty" azure:"ro"` + + // READ-ONLY; The set of locations that the SKU is available + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; The name of the SKU + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The resource type + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; The restrictions because of which SKU cannot be used + Restrictions []map[string]interface{} `json:"restrictions,omitempty" azure:"ro"` + + // READ-ONLY; The tier of the SKU + Tier *string `json:"tier,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SKUDescription. +func (s SKUDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "locationInfo", s.LocationInfo) + populate(objectMap, "locations", s.Locations) + populate(objectMap, "name", s.Name) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "restrictions", s.Restrictions) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// SKUDescriptionList - The list of the EngagementFabric SKU descriptions +type SKUDescriptionList struct { + // READ-ONLY; SKU descriptions + Value []*SKUDescription `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SKUDescriptionList. +func (s SKUDescriptionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SKULocationInfoItem - The locations and zones info for SKU. +type SKULocationInfoItem struct { + // REQUIRED; The available location of the SKU. + Location *string `json:"location,omitempty"` + + // The available zone of the SKU. + Zones []*string `json:"zones,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SKULocationInfoItem. +func (s SKULocationInfoItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", s.Location) + populate(objectMap, "zones", s.Zones) + return json.Marshal(objectMap) +} + +// Script - Class representing a database script. +type Script struct { + ProxyResource + // The database script. + Properties *ScriptProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Script. +func (s Script) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Script. +func (s *Script) 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 "properties": + err = unpopulate(val, &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, &s.SystemData) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ScriptCheckNameRequest - A script name availability request. +type ScriptCheckNameRequest struct { + // REQUIRED; Script name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, Microsoft.Kusto/clusters/databases/scripts. + Type *string `json:"type,omitempty"` +} + +// ScriptListResult - The list Kusto database script operation response. +type ScriptListResult struct { + // The list of Kusto scripts. + Value []*Script `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptListResult. +func (s ScriptListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ScriptProperties - A class representing database script property. +type ScriptProperties struct { + // REQUIRED; The url to the KQL script blob file. + ScriptURL *string `json:"scriptUrl,omitempty"` + + // REQUIRED; The SaS token. + ScriptURLSasToken *string `json:"scriptUrlSasToken,omitempty"` + + // Flag that indicates whether to continue if one of the command fails. + ContinueOnErrors *bool `json:"continueOnErrors,omitempty"` + + // A unique string. If changed the script will be applied again. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + + // READ-ONLY; The provisioned state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// ScriptsBeginCreateOrUpdateOptions contains the optional parameters for the Scripts.BeginCreateOrUpdate method. +type ScriptsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScriptsBeginDeleteOptions contains the optional parameters for the Scripts.BeginDelete method. +type ScriptsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ScriptsBeginUpdateOptions contains the optional parameters for the Scripts.BeginUpdate method. +type ScriptsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScriptsCheckNameAvailabilityOptions contains the optional parameters for the Scripts.CheckNameAvailability method. +type ScriptsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ScriptsGetOptions contains the optional parameters for the Scripts.Get method. +type ScriptsGetOptions struct { + // placeholder for future optional parameters +} + +// ScriptsListByDatabaseOptions contains the optional parameters for the Scripts.ListByDatabase method. +type ScriptsListByDatabaseOptions struct { + // placeholder for future optional parameters +} + +// 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{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", 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": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + 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": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + 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 +} + +// TableLevelSharingProperties - Tables that will be included and excluded in the follower database +type TableLevelSharingProperties struct { + // List of external tables exclude from the follower database + ExternalTablesToExclude []*string `json:"externalTablesToExclude,omitempty"` + + // List of external tables to include in the follower database + ExternalTablesToInclude []*string `json:"externalTablesToInclude,omitempty"` + + // List of materialized views exclude from the follower database + MaterializedViewsToExclude []*string `json:"materializedViewsToExclude,omitempty"` + + // List of materialized views to include in the follower database + MaterializedViewsToInclude []*string `json:"materializedViewsToInclude,omitempty"` + + // List of tables to exclude from the follower database + TablesToExclude []*string `json:"tablesToExclude,omitempty"` + + // List of tables to include in the follower database + TablesToInclude []*string `json:"tablesToInclude,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TableLevelSharingProperties. +func (t TableLevelSharingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "externalTablesToExclude", t.ExternalTablesToExclude) + populate(objectMap, "externalTablesToInclude", t.ExternalTablesToInclude) + populate(objectMap, "materializedViewsToExclude", t.MaterializedViewsToExclude) + populate(objectMap, "materializedViewsToInclude", t.MaterializedViewsToInclude) + populate(objectMap, "tablesToExclude", t.TablesToExclude) + populate(objectMap, "tablesToInclude", t.TablesToInclude) + return json.Marshal(objectMap) +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return t.unmarshalInternal(rawMsg) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +func (t *TrackedResource) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, &t.Location) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := t.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// TrustedExternalTenant - Represents a tenant ID that is trusted by the cluster. +type TrustedExternalTenant struct { + // GUID representing an external tenant. + Value *string `json:"value,omitempty"` +} + +// VirtualNetworkConfiguration - A class that contains virtual network definition. +type VirtualNetworkConfiguration struct { + // REQUIRED; Data management's service public IP address resource id. + DataManagementPublicIPID *string `json:"dataManagementPublicIpId,omitempty"` + + // REQUIRED; Engine service's public IP address resource id. + EnginePublicIPID *string `json:"enginePublicIpId,omitempty"` + + // REQUIRED; The subnet resource id. + SubnetID *string `json:"subnetId,omitempty"` +} + +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/kusto/armkusto/zz_generated_operations_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_operations_client.go new file mode 100644 index 000000000000..61379b6f3f72 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//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 armkusto + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" +) + +// 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(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists available operations for the Microsoft.Kusto provider. +// If the operation fails it returns the *CloudError 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.Kusto/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-08-27") + 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{}, runtime.NewResponseError(err, resp) + } + 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 := CloudError{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/kusto/armkusto/zz_generated_operationsresults_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_operationsresults_client.go new file mode 100644 index 000000000000..00c1aed4c76c --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_operationsresults_client.go @@ -0,0 +1,108 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// OperationsResultsClient contains the methods for the OperationsResults group. +// Don't use this type directly, use NewOperationsResultsClient() instead. +type OperationsResultsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewOperationsResultsClient creates a new instance of OperationsResultsClient with the specified values. +func NewOperationsResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsResultsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsResultsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Returns operation results. +// If the operation fails it returns the *CloudError error type. +func (client *OperationsResultsClient) Get(ctx context.Context, location string, operationID string, options *OperationsResultsGetOptions) (OperationsResultsGetResponse, error) { + req, err := client.getCreateRequest(ctx, location, operationID, options) + if err != nil { + return OperationsResultsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsResultsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsResultsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OperationsResultsClient) getCreateRequest(ctx context.Context, location string, operationID string, options *OperationsResultsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationresults/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationsResultsClient) getHandleResponse(resp *http.Response) (OperationsResultsGetResponse, error) { + result := OperationsResultsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationResult); err != nil { + return OperationsResultsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OperationsResultsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_pagers.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_pagers.go new file mode 100644 index 000000000000..4a4bf12af20f --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_pagers.go @@ -0,0 +1,125 @@ +//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 armkusto + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// ClustersListOutboundNetworkDependenciesEndpointsPager provides operations for iterating over paged responses. +type ClustersListOutboundNetworkDependenciesEndpointsPager struct { + client *ClustersClient + current ClustersListOutboundNetworkDependenciesEndpointsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ClustersListOutboundNetworkDependenciesEndpointsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ClustersListOutboundNetworkDependenciesEndpointsPager) 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 *ClustersListOutboundNetworkDependenciesEndpointsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OutboundNetworkDependenciesEndpointListResult.NextLink == nil || len(*p.current.OutboundNetworkDependenciesEndpointListResult.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.listOutboundNetworkDependenciesEndpointsHandleError(resp) + return false + } + result, err := p.client.listOutboundNetworkDependenciesEndpointsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ClustersListOutboundNetworkDependenciesEndpointsResponse page. +func (p *ClustersListOutboundNetworkDependenciesEndpointsPager) PageResponse() ClustersListOutboundNetworkDependenciesEndpointsResponse { + return p.current +} + +// 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 +} diff --git a/sdk/resourcemanager/kusto/armkusto/zz_generated_pollers.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_pollers.go new file mode 100644 index 000000000000..37c01b9d6458 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_pollers.go @@ -0,0 +1,1305 @@ +//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 armkusto + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// AttachedDatabaseConfigurationsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type AttachedDatabaseConfigurationsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *AttachedDatabaseConfigurationsCreateOrUpdatePoller) 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 *AttachedDatabaseConfigurationsCreateOrUpdatePoller) 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 AttachedDatabaseConfigurationsCreateOrUpdateResponse will be returned. +func (p *AttachedDatabaseConfigurationsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (AttachedDatabaseConfigurationsCreateOrUpdateResponse, error) { + respType := AttachedDatabaseConfigurationsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.AttachedDatabaseConfiguration) + if err != nil { + return AttachedDatabaseConfigurationsCreateOrUpdateResponse{}, 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 *AttachedDatabaseConfigurationsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// AttachedDatabaseConfigurationsDeletePoller provides polling facilities until the operation reaches a terminal state. +type AttachedDatabaseConfigurationsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *AttachedDatabaseConfigurationsDeletePoller) 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 *AttachedDatabaseConfigurationsDeletePoller) 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 AttachedDatabaseConfigurationsDeleteResponse will be returned. +func (p *AttachedDatabaseConfigurationsDeletePoller) FinalResponse(ctx context.Context) (AttachedDatabaseConfigurationsDeleteResponse, error) { + respType := AttachedDatabaseConfigurationsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return AttachedDatabaseConfigurationsDeleteResponse{}, 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 *AttachedDatabaseConfigurationsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClusterPrincipalAssignmentsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ClusterPrincipalAssignmentsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClusterPrincipalAssignmentsCreateOrUpdatePoller) 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 *ClusterPrincipalAssignmentsCreateOrUpdatePoller) 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 ClusterPrincipalAssignmentsCreateOrUpdateResponse will be returned. +func (p *ClusterPrincipalAssignmentsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ClusterPrincipalAssignmentsCreateOrUpdateResponse, error) { + respType := ClusterPrincipalAssignmentsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ClusterPrincipalAssignment) + if err != nil { + return ClusterPrincipalAssignmentsCreateOrUpdateResponse{}, 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 *ClusterPrincipalAssignmentsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClusterPrincipalAssignmentsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ClusterPrincipalAssignmentsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClusterPrincipalAssignmentsDeletePoller) 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 *ClusterPrincipalAssignmentsDeletePoller) 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 ClusterPrincipalAssignmentsDeleteResponse will be returned. +func (p *ClusterPrincipalAssignmentsDeletePoller) FinalResponse(ctx context.Context) (ClusterPrincipalAssignmentsDeleteResponse, error) { + respType := ClusterPrincipalAssignmentsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClusterPrincipalAssignmentsDeleteResponse{}, 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 *ClusterPrincipalAssignmentsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersAddLanguageExtensionsPoller provides polling facilities until the operation reaches a terminal state. +type ClustersAddLanguageExtensionsPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersAddLanguageExtensionsPoller) 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 *ClustersAddLanguageExtensionsPoller) 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 ClustersAddLanguageExtensionsResponse will be returned. +func (p *ClustersAddLanguageExtensionsPoller) FinalResponse(ctx context.Context) (ClustersAddLanguageExtensionsResponse, error) { + respType := ClustersAddLanguageExtensionsResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersAddLanguageExtensionsResponse{}, 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 *ClustersAddLanguageExtensionsPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ClustersCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersCreateOrUpdatePoller) 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 *ClustersCreateOrUpdatePoller) 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 ClustersCreateOrUpdateResponse will be returned. +func (p *ClustersCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ClustersCreateOrUpdateResponse, error) { + respType := ClustersCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Cluster) + if err != nil { + return ClustersCreateOrUpdateResponse{}, 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 *ClustersCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersDeletePoller provides polling facilities until the operation reaches a terminal state. +type ClustersDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersDeletePoller) 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 *ClustersDeletePoller) 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 ClustersDeleteResponse will be returned. +func (p *ClustersDeletePoller) FinalResponse(ctx context.Context) (ClustersDeleteResponse, error) { + respType := ClustersDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersDeleteResponse{}, 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 *ClustersDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersDetachFollowerDatabasesPoller provides polling facilities until the operation reaches a terminal state. +type ClustersDetachFollowerDatabasesPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersDetachFollowerDatabasesPoller) 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 *ClustersDetachFollowerDatabasesPoller) 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 ClustersDetachFollowerDatabasesResponse will be returned. +func (p *ClustersDetachFollowerDatabasesPoller) FinalResponse(ctx context.Context) (ClustersDetachFollowerDatabasesResponse, error) { + respType := ClustersDetachFollowerDatabasesResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersDetachFollowerDatabasesResponse{}, 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 *ClustersDetachFollowerDatabasesPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersDiagnoseVirtualNetworkPoller provides polling facilities until the operation reaches a terminal state. +type ClustersDiagnoseVirtualNetworkPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersDiagnoseVirtualNetworkPoller) 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 *ClustersDiagnoseVirtualNetworkPoller) 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 ClustersDiagnoseVirtualNetworkResponse will be returned. +func (p *ClustersDiagnoseVirtualNetworkPoller) FinalResponse(ctx context.Context) (ClustersDiagnoseVirtualNetworkResponse, error) { + respType := ClustersDiagnoseVirtualNetworkResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DiagnoseVirtualNetworkResult) + if err != nil { + return ClustersDiagnoseVirtualNetworkResponse{}, 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 *ClustersDiagnoseVirtualNetworkPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersRemoveLanguageExtensionsPoller provides polling facilities until the operation reaches a terminal state. +type ClustersRemoveLanguageExtensionsPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersRemoveLanguageExtensionsPoller) 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 *ClustersRemoveLanguageExtensionsPoller) 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 ClustersRemoveLanguageExtensionsResponse will be returned. +func (p *ClustersRemoveLanguageExtensionsPoller) FinalResponse(ctx context.Context) (ClustersRemoveLanguageExtensionsResponse, error) { + respType := ClustersRemoveLanguageExtensionsResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersRemoveLanguageExtensionsResponse{}, 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 *ClustersRemoveLanguageExtensionsPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersStartPoller provides polling facilities until the operation reaches a terminal state. +type ClustersStartPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersStartPoller) 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 *ClustersStartPoller) 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 ClustersStartResponse will be returned. +func (p *ClustersStartPoller) FinalResponse(ctx context.Context) (ClustersStartResponse, error) { + respType := ClustersStartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersStartResponse{}, 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 *ClustersStartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersStopPoller provides polling facilities until the operation reaches a terminal state. +type ClustersStopPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersStopPoller) 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 *ClustersStopPoller) 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 ClustersStopResponse will be returned. +func (p *ClustersStopPoller) FinalResponse(ctx context.Context) (ClustersStopResponse, error) { + respType := ClustersStopResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersStopResponse{}, 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 *ClustersStopPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ClustersUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ClustersUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ClustersUpdatePoller) 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 *ClustersUpdatePoller) 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 ClustersUpdateResponse will be returned. +func (p *ClustersUpdatePoller) FinalResponse(ctx context.Context) (ClustersUpdateResponse, error) { + respType := ClustersUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Cluster) + if err != nil { + return ClustersUpdateResponse{}, 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 *ClustersUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DataConnectionsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DataConnectionsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DataConnectionsCreateOrUpdatePoller) 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 *DataConnectionsCreateOrUpdatePoller) 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 DataConnectionsCreateOrUpdateResponse will be returned. +func (p *DataConnectionsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (DataConnectionsCreateOrUpdateResponse, error) { + respType := DataConnectionsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DataConnectionClassification) + if err != nil { + return DataConnectionsCreateOrUpdateResponse{}, 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 *DataConnectionsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DataConnectionsDataConnectionValidationPoller provides polling facilities until the operation reaches a terminal state. +type DataConnectionsDataConnectionValidationPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DataConnectionsDataConnectionValidationPoller) 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 *DataConnectionsDataConnectionValidationPoller) 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 DataConnectionsDataConnectionValidationResponse will be returned. +func (p *DataConnectionsDataConnectionValidationPoller) FinalResponse(ctx context.Context) (DataConnectionsDataConnectionValidationResponse, error) { + respType := DataConnectionsDataConnectionValidationResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DataConnectionValidationListResult) + if err != nil { + return DataConnectionsDataConnectionValidationResponse{}, 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 *DataConnectionsDataConnectionValidationPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DataConnectionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type DataConnectionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DataConnectionsDeletePoller) 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 *DataConnectionsDeletePoller) 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 DataConnectionsDeleteResponse will be returned. +func (p *DataConnectionsDeletePoller) FinalResponse(ctx context.Context) (DataConnectionsDeleteResponse, error) { + respType := DataConnectionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return DataConnectionsDeleteResponse{}, 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 *DataConnectionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DataConnectionsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DataConnectionsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DataConnectionsUpdatePoller) 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 *DataConnectionsUpdatePoller) 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 DataConnectionsUpdateResponse will be returned. +func (p *DataConnectionsUpdatePoller) FinalResponse(ctx context.Context) (DataConnectionsUpdateResponse, error) { + respType := DataConnectionsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DataConnectionClassification) + if err != nil { + return DataConnectionsUpdateResponse{}, 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 *DataConnectionsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DatabasePrincipalAssignmentsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DatabasePrincipalAssignmentsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatabasePrincipalAssignmentsCreateOrUpdatePoller) 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 *DatabasePrincipalAssignmentsCreateOrUpdatePoller) 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 DatabasePrincipalAssignmentsCreateOrUpdateResponse will be returned. +func (p *DatabasePrincipalAssignmentsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (DatabasePrincipalAssignmentsCreateOrUpdateResponse, error) { + respType := DatabasePrincipalAssignmentsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DatabasePrincipalAssignment) + if err != nil { + return DatabasePrincipalAssignmentsCreateOrUpdateResponse{}, 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 *DatabasePrincipalAssignmentsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DatabasePrincipalAssignmentsDeletePoller provides polling facilities until the operation reaches a terminal state. +type DatabasePrincipalAssignmentsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatabasePrincipalAssignmentsDeletePoller) 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 *DatabasePrincipalAssignmentsDeletePoller) 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 DatabasePrincipalAssignmentsDeleteResponse will be returned. +func (p *DatabasePrincipalAssignmentsDeletePoller) FinalResponse(ctx context.Context) (DatabasePrincipalAssignmentsDeleteResponse, error) { + respType := DatabasePrincipalAssignmentsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return DatabasePrincipalAssignmentsDeleteResponse{}, 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 *DatabasePrincipalAssignmentsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DatabasesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DatabasesCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatabasesCreateOrUpdatePoller) 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 *DatabasesCreateOrUpdatePoller) 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 DatabasesCreateOrUpdateResponse will be returned. +func (p *DatabasesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (DatabasesCreateOrUpdateResponse, error) { + respType := DatabasesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DatabaseClassification) + if err != nil { + return DatabasesCreateOrUpdateResponse{}, 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 *DatabasesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DatabasesDeletePoller provides polling facilities until the operation reaches a terminal state. +type DatabasesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatabasesDeletePoller) 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 *DatabasesDeletePoller) 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 DatabasesDeleteResponse will be returned. +func (p *DatabasesDeletePoller) FinalResponse(ctx context.Context) (DatabasesDeleteResponse, error) { + respType := DatabasesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return DatabasesDeleteResponse{}, 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 *DatabasesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DatabasesUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DatabasesUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatabasesUpdatePoller) 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 *DatabasesUpdatePoller) 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 DatabasesUpdateResponse will be returned. +func (p *DatabasesUpdatePoller) FinalResponse(ctx context.Context) (DatabasesUpdateResponse, error) { + respType := DatabasesUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DatabaseClassification) + if err != nil { + return DatabasesUpdateResponse{}, 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 *DatabasesUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ManagedPrivateEndpointsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ManagedPrivateEndpointsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ManagedPrivateEndpointsCreateOrUpdatePoller) 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 *ManagedPrivateEndpointsCreateOrUpdatePoller) 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 ManagedPrivateEndpointsCreateOrUpdateResponse will be returned. +func (p *ManagedPrivateEndpointsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ManagedPrivateEndpointsCreateOrUpdateResponse, error) { + respType := ManagedPrivateEndpointsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ManagedPrivateEndpoint) + if err != nil { + return ManagedPrivateEndpointsCreateOrUpdateResponse{}, 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 *ManagedPrivateEndpointsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ManagedPrivateEndpointsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ManagedPrivateEndpointsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ManagedPrivateEndpointsDeletePoller) 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 *ManagedPrivateEndpointsDeletePoller) 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 ManagedPrivateEndpointsDeleteResponse will be returned. +func (p *ManagedPrivateEndpointsDeletePoller) FinalResponse(ctx context.Context) (ManagedPrivateEndpointsDeleteResponse, error) { + respType := ManagedPrivateEndpointsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ManagedPrivateEndpointsDeleteResponse{}, 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 *ManagedPrivateEndpointsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ManagedPrivateEndpointsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ManagedPrivateEndpointsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ManagedPrivateEndpointsUpdatePoller) 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 *ManagedPrivateEndpointsUpdatePoller) 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 ManagedPrivateEndpointsUpdateResponse will be returned. +func (p *ManagedPrivateEndpointsUpdatePoller) FinalResponse(ctx context.Context) (ManagedPrivateEndpointsUpdateResponse, error) { + respType := ManagedPrivateEndpointsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ManagedPrivateEndpoint) + if err != nil { + return ManagedPrivateEndpointsUpdateResponse{}, 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 *ManagedPrivateEndpointsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateEndpointConnectionsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateEndpointConnectionsCreateOrUpdatePoller) 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 *PrivateEndpointConnectionsCreateOrUpdatePoller) 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 PrivateEndpointConnectionsCreateOrUpdateResponse will be returned. +func (p *PrivateEndpointConnectionsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionsCreateOrUpdateResponse, error) { + respType := PrivateEndpointConnectionsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, 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 *PrivateEndpointConnectionsCreateOrUpdatePoller) 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() +} + +// ScriptsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ScriptsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ScriptsCreateOrUpdatePoller) 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 *ScriptsCreateOrUpdatePoller) 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 ScriptsCreateOrUpdateResponse will be returned. +func (p *ScriptsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ScriptsCreateOrUpdateResponse, error) { + respType := ScriptsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Script) + if err != nil { + return ScriptsCreateOrUpdateResponse{}, 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 *ScriptsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ScriptsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ScriptsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ScriptsDeletePoller) 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 *ScriptsDeletePoller) 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 ScriptsDeleteResponse will be returned. +func (p *ScriptsDeletePoller) FinalResponse(ctx context.Context) (ScriptsDeleteResponse, error) { + respType := ScriptsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ScriptsDeleteResponse{}, 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 *ScriptsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ScriptsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ScriptsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ScriptsUpdatePoller) 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 *ScriptsUpdatePoller) 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 ScriptsUpdateResponse will be returned. +func (p *ScriptsUpdatePoller) FinalResponse(ctx context.Context) (ScriptsUpdateResponse, error) { + respType := ScriptsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Script) + if err != nil { + return ScriptsUpdateResponse{}, 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 *ScriptsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/kusto/armkusto/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..275b3e26be6c --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_polymorphic_helpers.go @@ -0,0 +1,129 @@ +//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 armkusto + +import "encoding/json" + +func unmarshalDataConnectionClassification(rawMsg json.RawMessage) (DataConnectionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DataConnectionClassification + switch m["kind"] { + case string(DataConnectionKindEventGrid): + b = &EventGridDataConnection{} + case string(DataConnectionKindEventHub): + b = &EventHubDataConnection{} + case string(DataConnectionKindIotHub): + b = &IotHubDataConnection{} + default: + b = &DataConnection{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalDataConnectionClassificationArray(rawMsg json.RawMessage) ([]DataConnectionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]DataConnectionClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalDataConnectionClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalDataConnectionClassificationMap(rawMsg json.RawMessage) (map[string]DataConnectionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]DataConnectionClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalDataConnectionClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalDatabaseClassification(rawMsg json.RawMessage) (DatabaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DatabaseClassification + switch m["kind"] { + case string(KindReadOnlyFollowing): + b = &ReadOnlyFollowingDatabase{} + case string(KindReadWrite): + b = &ReadWriteDatabase{} + default: + b = &Database{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalDatabaseClassificationArray(rawMsg json.RawMessage) ([]DatabaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]DatabaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalDatabaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalDatabaseClassificationMap(rawMsg json.RawMessage) (map[string]DatabaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]DatabaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalDatabaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/zz_generated_privateendpointconnections_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..8cb62c81db7a --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,337 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// 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(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateEndpointConnectionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateEndpointConnectionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (PrivateEndpointConnectionsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, privateEndpointConnectionName, parameters, options) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdatePollerResponse{}, err + } + result := PrivateEndpointConnectionsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateEndpointConnectionsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &PrivateEndpointConnectionsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, privateEndpointConnectionName, 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 *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + 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 *PrivateEndpointConnectionsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a private endpoint connection with a given name. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (PrivateEndpointConnectionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, 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 - Deletes a private endpoint connection with a given name. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, 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, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + 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 := CloudError{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 a private endpoint connection. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, 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, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + 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{}, runtime.NewResponseError(err, resp) + } + 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 := CloudError{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 - Returns the list of private endpoint connections. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, clusterName string, options *PrivateEndpointConnectionsListOptions) (PrivateEndpointConnectionsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateEndpointConnectionsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *PrivateEndpointConnectionsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + 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.PrivateEndpointConnectionListResult); err != nil { + return PrivateEndpointConnectionsListResponse{}, runtime.NewResponseError(err, resp) + } + 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 := CloudError{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/kusto/armkusto/zz_generated_privatelinkresources_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_privatelinkresources_client.go new file mode 100644 index 000000000000..5d942d0ac9d5 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_privatelinkresources_client.go @@ -0,0 +1,177 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// 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(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateLinkResourcesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateLinkResourcesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Gets a private link resource. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, privateLinkResourceName string, options *PrivateLinkResourcesGetOptions) (PrivateLinkResourcesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, privateLinkResourceName, 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, clusterName string, privateLinkResourceName string, options *PrivateLinkResourcesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if privateLinkResourceName == "" { + return nil, errors.New("parameter privateLinkResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateLinkResourceName}", url.PathEscape(privateLinkResourceName)) + 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-08-27") + 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.PrivateLinkResource); err != nil { + return PrivateLinkResourcesGetResponse{}, runtime.NewResponseError(err, resp) + } + 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 := CloudError{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 - Returns the list of private link resources. +// If the operation fails it returns the *CloudError error type. +func (client *PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, clusterName string, options *PrivateLinkResourcesListOptions) (PrivateLinkResourcesListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return PrivateLinkResourcesListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateLinkResourcesListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateLinkResourcesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *PrivateLinkResourcesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-08-27") + 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.PrivateLinkResourceListResult); err != nil { + return PrivateLinkResourcesListResponse{}, runtime.NewResponseError(err, resp) + } + 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 := CloudError{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/kusto/armkusto/zz_generated_response_types.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_response_types.go new file mode 100644 index 000000000000..028d4a91e8d0 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_response_types.go @@ -0,0 +1,2020 @@ +//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 armkusto + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// AttachedDatabaseConfigurationsCheckNameAvailabilityResponse contains the response from method AttachedDatabaseConfigurations.CheckNameAvailability. +type AttachedDatabaseConfigurationsCheckNameAvailabilityResponse struct { + AttachedDatabaseConfigurationsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AttachedDatabaseConfigurationsCheckNameAvailabilityResult contains the result from method AttachedDatabaseConfigurations.CheckNameAvailability. +type AttachedDatabaseConfigurationsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse contains the response from method AttachedDatabaseConfigurations.CreateOrUpdate. +type AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *AttachedDatabaseConfigurationsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AttachedDatabaseConfigurationsCreateOrUpdateResponse, error) { + respType := AttachedDatabaseConfigurationsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.AttachedDatabaseConfiguration) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *AttachedDatabaseConfigurationsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *AttachedDatabaseConfigurationsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("AttachedDatabaseConfigurationsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &AttachedDatabaseConfigurationsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// AttachedDatabaseConfigurationsCreateOrUpdateResponse contains the response from method AttachedDatabaseConfigurations.CreateOrUpdate. +type AttachedDatabaseConfigurationsCreateOrUpdateResponse struct { + AttachedDatabaseConfigurationsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AttachedDatabaseConfigurationsCreateOrUpdateResult contains the result from method AttachedDatabaseConfigurations.CreateOrUpdate. +type AttachedDatabaseConfigurationsCreateOrUpdateResult struct { + AttachedDatabaseConfiguration +} + +// AttachedDatabaseConfigurationsDeletePollerResponse contains the response from method AttachedDatabaseConfigurations.Delete. +type AttachedDatabaseConfigurationsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *AttachedDatabaseConfigurationsDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l AttachedDatabaseConfigurationsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AttachedDatabaseConfigurationsDeleteResponse, error) { + respType := AttachedDatabaseConfigurationsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a AttachedDatabaseConfigurationsDeletePollerResponse from the provided client and resume token. +func (l *AttachedDatabaseConfigurationsDeletePollerResponse) Resume(ctx context.Context, client *AttachedDatabaseConfigurationsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("AttachedDatabaseConfigurationsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &AttachedDatabaseConfigurationsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// AttachedDatabaseConfigurationsDeleteResponse contains the response from method AttachedDatabaseConfigurations.Delete. +type AttachedDatabaseConfigurationsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AttachedDatabaseConfigurationsGetResponse contains the response from method AttachedDatabaseConfigurations.Get. +type AttachedDatabaseConfigurationsGetResponse struct { + AttachedDatabaseConfigurationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AttachedDatabaseConfigurationsGetResult contains the result from method AttachedDatabaseConfigurations.Get. +type AttachedDatabaseConfigurationsGetResult struct { + AttachedDatabaseConfiguration +} + +// AttachedDatabaseConfigurationsListByClusterResponse contains the response from method AttachedDatabaseConfigurations.ListByCluster. +type AttachedDatabaseConfigurationsListByClusterResponse struct { + AttachedDatabaseConfigurationsListByClusterResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AttachedDatabaseConfigurationsListByClusterResult contains the result from method AttachedDatabaseConfigurations.ListByCluster. +type AttachedDatabaseConfigurationsListByClusterResult struct { + AttachedDatabaseConfigurationListResult +} + +// ClusterPrincipalAssignmentsCheckNameAvailabilityResponse contains the response from method ClusterPrincipalAssignments.CheckNameAvailability. +type ClusterPrincipalAssignmentsCheckNameAvailabilityResponse struct { + ClusterPrincipalAssignmentsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClusterPrincipalAssignmentsCheckNameAvailabilityResult contains the result from method ClusterPrincipalAssignments.CheckNameAvailability. +type ClusterPrincipalAssignmentsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse contains the response from method ClusterPrincipalAssignments.CreateOrUpdate. +type ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ClusterPrincipalAssignmentsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClusterPrincipalAssignmentsCreateOrUpdateResponse, error) { + respType := ClusterPrincipalAssignmentsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ClusterPrincipalAssignment) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ClusterPrincipalAssignmentsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ClusterPrincipalAssignmentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClusterPrincipalAssignmentsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ClusterPrincipalAssignmentsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClusterPrincipalAssignmentsCreateOrUpdateResponse contains the response from method ClusterPrincipalAssignments.CreateOrUpdate. +type ClusterPrincipalAssignmentsCreateOrUpdateResponse struct { + ClusterPrincipalAssignmentsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClusterPrincipalAssignmentsCreateOrUpdateResult contains the result from method ClusterPrincipalAssignments.CreateOrUpdate. +type ClusterPrincipalAssignmentsCreateOrUpdateResult struct { + ClusterPrincipalAssignment +} + +// ClusterPrincipalAssignmentsDeletePollerResponse contains the response from method ClusterPrincipalAssignments.Delete. +type ClusterPrincipalAssignmentsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ClusterPrincipalAssignmentsDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClusterPrincipalAssignmentsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClusterPrincipalAssignmentsDeleteResponse, error) { + respType := ClusterPrincipalAssignmentsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClusterPrincipalAssignmentsDeletePollerResponse from the provided client and resume token. +func (l *ClusterPrincipalAssignmentsDeletePollerResponse) Resume(ctx context.Context, client *ClusterPrincipalAssignmentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClusterPrincipalAssignmentsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ClusterPrincipalAssignmentsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClusterPrincipalAssignmentsDeleteResponse contains the response from method ClusterPrincipalAssignments.Delete. +type ClusterPrincipalAssignmentsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClusterPrincipalAssignmentsGetResponse contains the response from method ClusterPrincipalAssignments.Get. +type ClusterPrincipalAssignmentsGetResponse struct { + ClusterPrincipalAssignmentsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClusterPrincipalAssignmentsGetResult contains the result from method ClusterPrincipalAssignments.Get. +type ClusterPrincipalAssignmentsGetResult struct { + ClusterPrincipalAssignment +} + +// ClusterPrincipalAssignmentsListResponse contains the response from method ClusterPrincipalAssignments.List. +type ClusterPrincipalAssignmentsListResponse struct { + ClusterPrincipalAssignmentsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClusterPrincipalAssignmentsListResult contains the result from method ClusterPrincipalAssignments.List. +type ClusterPrincipalAssignmentsListResult struct { + ClusterPrincipalAssignmentListResult +} + +// ClustersAddLanguageExtensionsPollerResponse contains the response from method Clusters.AddLanguageExtensions. +type ClustersAddLanguageExtensionsPollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersAddLanguageExtensionsPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersAddLanguageExtensionsPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersAddLanguageExtensionsResponse, error) { + respType := ClustersAddLanguageExtensionsResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersAddLanguageExtensionsPollerResponse from the provided client and resume token. +func (l *ClustersAddLanguageExtensionsPollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.AddLanguageExtensions", token, client.pl, client.addLanguageExtensionsHandleError) + if err != nil { + return err + } + poller := &ClustersAddLanguageExtensionsPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersAddLanguageExtensionsResponse contains the response from method Clusters.AddLanguageExtensions. +type ClustersAddLanguageExtensionsResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersCheckNameAvailabilityResponse contains the response from method Clusters.CheckNameAvailability. +type ClustersCheckNameAvailabilityResponse struct { + ClustersCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersCheckNameAvailabilityResult contains the result from method Clusters.CheckNameAvailability. +type ClustersCheckNameAvailabilityResult struct { + CheckNameResult +} + +// ClustersCreateOrUpdatePollerResponse contains the response from method Clusters.CreateOrUpdate. +type ClustersCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersCreateOrUpdateResponse, error) { + respType := ClustersCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Cluster) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ClustersCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ClustersCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersCreateOrUpdateResponse contains the response from method Clusters.CreateOrUpdate. +type ClustersCreateOrUpdateResponse struct { + ClustersCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersCreateOrUpdateResult contains the result from method Clusters.CreateOrUpdate. +type ClustersCreateOrUpdateResult struct { + Cluster +} + +// ClustersDeletePollerResponse contains the response from method Clusters.Delete. +type ClustersDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersDeleteResponse, error) { + respType := ClustersDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersDeletePollerResponse from the provided client and resume token. +func (l *ClustersDeletePollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ClustersDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersDeleteResponse contains the response from method Clusters.Delete. +type ClustersDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersDetachFollowerDatabasesPollerResponse contains the response from method Clusters.DetachFollowerDatabases. +type ClustersDetachFollowerDatabasesPollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersDetachFollowerDatabasesPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersDetachFollowerDatabasesPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersDetachFollowerDatabasesResponse, error) { + respType := ClustersDetachFollowerDatabasesResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersDetachFollowerDatabasesPollerResponse from the provided client and resume token. +func (l *ClustersDetachFollowerDatabasesPollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.DetachFollowerDatabases", token, client.pl, client.detachFollowerDatabasesHandleError) + if err != nil { + return err + } + poller := &ClustersDetachFollowerDatabasesPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersDetachFollowerDatabasesResponse contains the response from method Clusters.DetachFollowerDatabases. +type ClustersDetachFollowerDatabasesResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersDiagnoseVirtualNetworkPollerResponse contains the response from method Clusters.DiagnoseVirtualNetwork. +type ClustersDiagnoseVirtualNetworkPollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersDiagnoseVirtualNetworkPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersDiagnoseVirtualNetworkPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersDiagnoseVirtualNetworkResponse, error) { + respType := ClustersDiagnoseVirtualNetworkResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DiagnoseVirtualNetworkResult) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersDiagnoseVirtualNetworkPollerResponse from the provided client and resume token. +func (l *ClustersDiagnoseVirtualNetworkPollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.DiagnoseVirtualNetwork", token, client.pl, client.diagnoseVirtualNetworkHandleError) + if err != nil { + return err + } + poller := &ClustersDiagnoseVirtualNetworkPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersDiagnoseVirtualNetworkResponse contains the response from method Clusters.DiagnoseVirtualNetwork. +type ClustersDiagnoseVirtualNetworkResponse struct { + ClustersDiagnoseVirtualNetworkResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersDiagnoseVirtualNetworkResult contains the result from method Clusters.DiagnoseVirtualNetwork. +type ClustersDiagnoseVirtualNetworkResult struct { + DiagnoseVirtualNetworkResult +} + +// ClustersGetResponse contains the response from method Clusters.Get. +type ClustersGetResponse struct { + ClustersGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersGetResult contains the result from method Clusters.Get. +type ClustersGetResult struct { + Cluster +} + +// ClustersListByResourceGroupResponse contains the response from method Clusters.ListByResourceGroup. +type ClustersListByResourceGroupResponse struct { + ClustersListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListByResourceGroupResult contains the result from method Clusters.ListByResourceGroup. +type ClustersListByResourceGroupResult struct { + ClusterListResult +} + +// ClustersListFollowerDatabasesResponse contains the response from method Clusters.ListFollowerDatabases. +type ClustersListFollowerDatabasesResponse struct { + ClustersListFollowerDatabasesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListFollowerDatabasesResult contains the result from method Clusters.ListFollowerDatabases. +type ClustersListFollowerDatabasesResult struct { + FollowerDatabaseListResult +} + +// ClustersListLanguageExtensionsResponse contains the response from method Clusters.ListLanguageExtensions. +type ClustersListLanguageExtensionsResponse struct { + ClustersListLanguageExtensionsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListLanguageExtensionsResult contains the result from method Clusters.ListLanguageExtensions. +type ClustersListLanguageExtensionsResult struct { + LanguageExtensionsList +} + +// ClustersListOutboundNetworkDependenciesEndpointsResponse contains the response from method Clusters.ListOutboundNetworkDependenciesEndpoints. +type ClustersListOutboundNetworkDependenciesEndpointsResponse struct { + ClustersListOutboundNetworkDependenciesEndpointsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListOutboundNetworkDependenciesEndpointsResult contains the result from method Clusters.ListOutboundNetworkDependenciesEndpoints. +type ClustersListOutboundNetworkDependenciesEndpointsResult struct { + OutboundNetworkDependenciesEndpointListResult +} + +// ClustersListResponse contains the response from method Clusters.List. +type ClustersListResponse struct { + ClustersListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListResult contains the result from method Clusters.List. +type ClustersListResult struct { + ClusterListResult +} + +// ClustersListSKUsByResourceResponse contains the response from method Clusters.ListSKUsByResource. +type ClustersListSKUsByResourceResponse struct { + ClustersListSKUsByResourceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListSKUsByResourceResult contains the result from method Clusters.ListSKUsByResource. +type ClustersListSKUsByResourceResult struct { + ListResourceSKUsResult +} + +// ClustersListSKUsResponse contains the response from method Clusters.ListSKUs. +type ClustersListSKUsResponse struct { + ClustersListSKUsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListSKUsResult contains the result from method Clusters.ListSKUs. +type ClustersListSKUsResult struct { + SKUDescriptionList +} + +// ClustersRemoveLanguageExtensionsPollerResponse contains the response from method Clusters.RemoveLanguageExtensions. +type ClustersRemoveLanguageExtensionsPollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersRemoveLanguageExtensionsPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersRemoveLanguageExtensionsPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersRemoveLanguageExtensionsResponse, error) { + respType := ClustersRemoveLanguageExtensionsResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersRemoveLanguageExtensionsPollerResponse from the provided client and resume token. +func (l *ClustersRemoveLanguageExtensionsPollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.RemoveLanguageExtensions", token, client.pl, client.removeLanguageExtensionsHandleError) + if err != nil { + return err + } + poller := &ClustersRemoveLanguageExtensionsPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersRemoveLanguageExtensionsResponse contains the response from method Clusters.RemoveLanguageExtensions. +type ClustersRemoveLanguageExtensionsResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersStartPollerResponse contains the response from method Clusters.Start. +type ClustersStartPollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersStartPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersStartPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersStartResponse, error) { + respType := ClustersStartResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersStartPollerResponse from the provided client and resume token. +func (l *ClustersStartPollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.Start", token, client.pl, client.startHandleError) + if err != nil { + return err + } + poller := &ClustersStartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersStartResponse contains the response from method Clusters.Start. +type ClustersStartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersStopPollerResponse contains the response from method Clusters.Stop. +type ClustersStopPollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersStopPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersStopPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersStopResponse, error) { + respType := ClustersStopResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersStopPollerResponse from the provided client and resume token. +func (l *ClustersStopPollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.Stop", token, client.pl, client.stopHandleError) + if err != nil { + return err + } + poller := &ClustersStopPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersStopResponse contains the response from method Clusters.Stop. +type ClustersStopResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersUpdatePollerResponse contains the response from method Clusters.Update. +type ClustersUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ClustersUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ClustersUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClustersUpdateResponse, error) { + respType := ClustersUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Cluster) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ClustersUpdatePollerResponse from the provided client and resume token. +func (l *ClustersUpdatePollerResponse) Resume(ctx context.Context, client *ClustersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ClustersClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &ClustersUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ClustersUpdateResponse contains the response from method Clusters.Update. +type ClustersUpdateResponse struct { + ClustersUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersUpdateResult contains the result from method Clusters.Update. +type ClustersUpdateResult struct { + Cluster +} + +// DataConnectionsCheckNameAvailabilityResponse contains the response from method DataConnections.CheckNameAvailability. +type DataConnectionsCheckNameAvailabilityResponse struct { + DataConnectionsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsCheckNameAvailabilityResult contains the result from method DataConnections.CheckNameAvailability. +type DataConnectionsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// DataConnectionsCreateOrUpdatePollerResponse contains the response from method DataConnections.CreateOrUpdate. +type DataConnectionsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DataConnectionsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DataConnectionsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DataConnectionsCreateOrUpdateResponse, error) { + respType := DataConnectionsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DataConnectionClassification) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DataConnectionsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *DataConnectionsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *DataConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DataConnectionsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &DataConnectionsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DataConnectionsCreateOrUpdateResponse contains the response from method DataConnections.CreateOrUpdate. +type DataConnectionsCreateOrUpdateResponse struct { + DataConnectionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsCreateOrUpdateResult contains the result from method DataConnections.CreateOrUpdate. +type DataConnectionsCreateOrUpdateResult struct { + DataConnectionClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionsCreateOrUpdateResult. +func (d *DataConnectionsCreateOrUpdateResult) UnmarshalJSON(data []byte) error { + res, err := unmarshalDataConnectionClassification(data) + if err != nil { + return err + } + d.DataConnectionClassification = res + return nil +} + +// DataConnectionsDataConnectionValidationPollerResponse contains the response from method DataConnections.DataConnectionValidation. +type DataConnectionsDataConnectionValidationPollerResponse struct { + // Poller contains an initialized poller. + Poller *DataConnectionsDataConnectionValidationPoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DataConnectionsDataConnectionValidationPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DataConnectionsDataConnectionValidationResponse, error) { + respType := DataConnectionsDataConnectionValidationResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DataConnectionValidationListResult) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DataConnectionsDataConnectionValidationPollerResponse from the provided client and resume token. +func (l *DataConnectionsDataConnectionValidationPollerResponse) Resume(ctx context.Context, client *DataConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DataConnectionsClient.DataConnectionValidation", token, client.pl, client.dataConnectionValidationHandleError) + if err != nil { + return err + } + poller := &DataConnectionsDataConnectionValidationPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DataConnectionsDataConnectionValidationResponse contains the response from method DataConnections.DataConnectionValidation. +type DataConnectionsDataConnectionValidationResponse struct { + DataConnectionsDataConnectionValidationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsDataConnectionValidationResult contains the result from method DataConnections.DataConnectionValidation. +type DataConnectionsDataConnectionValidationResult struct { + DataConnectionValidationListResult +} + +// DataConnectionsDeletePollerResponse contains the response from method DataConnections.Delete. +type DataConnectionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *DataConnectionsDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DataConnectionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DataConnectionsDeleteResponse, error) { + respType := DataConnectionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DataConnectionsDeletePollerResponse from the provided client and resume token. +func (l *DataConnectionsDeletePollerResponse) Resume(ctx context.Context, client *DataConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DataConnectionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &DataConnectionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DataConnectionsDeleteResponse contains the response from method DataConnections.Delete. +type DataConnectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsGetResponse contains the response from method DataConnections.Get. +type DataConnectionsGetResponse struct { + DataConnectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsGetResult contains the result from method DataConnections.Get. +type DataConnectionsGetResult struct { + DataConnectionClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionsGetResult. +func (d *DataConnectionsGetResult) UnmarshalJSON(data []byte) error { + res, err := unmarshalDataConnectionClassification(data) + if err != nil { + return err + } + d.DataConnectionClassification = res + return nil +} + +// DataConnectionsListByDatabaseResponse contains the response from method DataConnections.ListByDatabase. +type DataConnectionsListByDatabaseResponse struct { + DataConnectionsListByDatabaseResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsListByDatabaseResult contains the result from method DataConnections.ListByDatabase. +type DataConnectionsListByDatabaseResult struct { + DataConnectionListResult +} + +// DataConnectionsUpdatePollerResponse contains the response from method DataConnections.Update. +type DataConnectionsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DataConnectionsUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DataConnectionsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DataConnectionsUpdateResponse, error) { + respType := DataConnectionsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DataConnectionClassification) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DataConnectionsUpdatePollerResponse from the provided client and resume token. +func (l *DataConnectionsUpdatePollerResponse) Resume(ctx context.Context, client *DataConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DataConnectionsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &DataConnectionsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DataConnectionsUpdateResponse contains the response from method DataConnections.Update. +type DataConnectionsUpdateResponse struct { + DataConnectionsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataConnectionsUpdateResult contains the result from method DataConnections.Update. +type DataConnectionsUpdateResult struct { + DataConnectionClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionsUpdateResult. +func (d *DataConnectionsUpdateResult) UnmarshalJSON(data []byte) error { + res, err := unmarshalDataConnectionClassification(data) + if err != nil { + return err + } + d.DataConnectionClassification = res + return nil +} + +// DatabasePrincipalAssignmentsCheckNameAvailabilityResponse contains the response from method DatabasePrincipalAssignments.CheckNameAvailability. +type DatabasePrincipalAssignmentsCheckNameAvailabilityResponse struct { + DatabasePrincipalAssignmentsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasePrincipalAssignmentsCheckNameAvailabilityResult contains the result from method DatabasePrincipalAssignments.CheckNameAvailability. +type DatabasePrincipalAssignmentsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse contains the response from method DatabasePrincipalAssignments.CreateOrUpdate. +type DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatabasePrincipalAssignmentsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatabasePrincipalAssignmentsCreateOrUpdateResponse, error) { + respType := DatabasePrincipalAssignmentsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DatabasePrincipalAssignment) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *DatabasePrincipalAssignmentsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *DatabasePrincipalAssignmentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatabasePrincipalAssignmentsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &DatabasePrincipalAssignmentsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatabasePrincipalAssignmentsCreateOrUpdateResponse contains the response from method DatabasePrincipalAssignments.CreateOrUpdate. +type DatabasePrincipalAssignmentsCreateOrUpdateResponse struct { + DatabasePrincipalAssignmentsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasePrincipalAssignmentsCreateOrUpdateResult contains the result from method DatabasePrincipalAssignments.CreateOrUpdate. +type DatabasePrincipalAssignmentsCreateOrUpdateResult struct { + DatabasePrincipalAssignment +} + +// DatabasePrincipalAssignmentsDeletePollerResponse contains the response from method DatabasePrincipalAssignments.Delete. +type DatabasePrincipalAssignmentsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatabasePrincipalAssignmentsDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DatabasePrincipalAssignmentsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatabasePrincipalAssignmentsDeleteResponse, error) { + respType := DatabasePrincipalAssignmentsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatabasePrincipalAssignmentsDeletePollerResponse from the provided client and resume token. +func (l *DatabasePrincipalAssignmentsDeletePollerResponse) Resume(ctx context.Context, client *DatabasePrincipalAssignmentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatabasePrincipalAssignmentsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &DatabasePrincipalAssignmentsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatabasePrincipalAssignmentsDeleteResponse contains the response from method DatabasePrincipalAssignments.Delete. +type DatabasePrincipalAssignmentsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasePrincipalAssignmentsGetResponse contains the response from method DatabasePrincipalAssignments.Get. +type DatabasePrincipalAssignmentsGetResponse struct { + DatabasePrincipalAssignmentsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasePrincipalAssignmentsGetResult contains the result from method DatabasePrincipalAssignments.Get. +type DatabasePrincipalAssignmentsGetResult struct { + DatabasePrincipalAssignment +} + +// DatabasePrincipalAssignmentsListResponse contains the response from method DatabasePrincipalAssignments.List. +type DatabasePrincipalAssignmentsListResponse struct { + DatabasePrincipalAssignmentsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasePrincipalAssignmentsListResult contains the result from method DatabasePrincipalAssignments.List. +type DatabasePrincipalAssignmentsListResult struct { + DatabasePrincipalAssignmentListResult +} + +// DatabasesAddPrincipalsResponse contains the response from method Databases.AddPrincipals. +type DatabasesAddPrincipalsResponse struct { + DatabasesAddPrincipalsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesAddPrincipalsResult contains the result from method Databases.AddPrincipals. +type DatabasesAddPrincipalsResult struct { + DatabasePrincipalListResult +} + +// DatabasesCheckNameAvailabilityResponse contains the response from method Databases.CheckNameAvailability. +type DatabasesCheckNameAvailabilityResponse struct { + DatabasesCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesCheckNameAvailabilityResult contains the result from method Databases.CheckNameAvailability. +type DatabasesCheckNameAvailabilityResult struct { + CheckNameResult +} + +// DatabasesCreateOrUpdatePollerResponse contains the response from method Databases.CreateOrUpdate. +type DatabasesCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatabasesCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DatabasesCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatabasesCreateOrUpdateResponse, error) { + respType := DatabasesCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DatabaseClassification) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatabasesCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *DatabasesCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *DatabasesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatabasesClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &DatabasesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatabasesCreateOrUpdateResponse contains the response from method Databases.CreateOrUpdate. +type DatabasesCreateOrUpdateResponse struct { + DatabasesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesCreateOrUpdateResult contains the result from method Databases.CreateOrUpdate. +type DatabasesCreateOrUpdateResult struct { + DatabaseClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabasesCreateOrUpdateResult. +func (d *DatabasesCreateOrUpdateResult) UnmarshalJSON(data []byte) error { + res, err := unmarshalDatabaseClassification(data) + if err != nil { + return err + } + d.DatabaseClassification = res + return nil +} + +// DatabasesDeletePollerResponse contains the response from method Databases.Delete. +type DatabasesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatabasesDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DatabasesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatabasesDeleteResponse, error) { + respType := DatabasesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatabasesDeletePollerResponse from the provided client and resume token. +func (l *DatabasesDeletePollerResponse) Resume(ctx context.Context, client *DatabasesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatabasesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &DatabasesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatabasesDeleteResponse contains the response from method Databases.Delete. +type DatabasesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesGetResponse contains the response from method Databases.Get. +type DatabasesGetResponse struct { + DatabasesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesGetResult contains the result from method Databases.Get. +type DatabasesGetResult struct { + DatabaseClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabasesGetResult. +func (d *DatabasesGetResult) UnmarshalJSON(data []byte) error { + res, err := unmarshalDatabaseClassification(data) + if err != nil { + return err + } + d.DatabaseClassification = res + return nil +} + +// DatabasesListByClusterResponse contains the response from method Databases.ListByCluster. +type DatabasesListByClusterResponse struct { + DatabasesListByClusterResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesListByClusterResult contains the result from method Databases.ListByCluster. +type DatabasesListByClusterResult struct { + DatabaseListResult +} + +// DatabasesListPrincipalsResponse contains the response from method Databases.ListPrincipals. +type DatabasesListPrincipalsResponse struct { + DatabasesListPrincipalsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesListPrincipalsResult contains the result from method Databases.ListPrincipals. +type DatabasesListPrincipalsResult struct { + DatabasePrincipalListResult +} + +// DatabasesRemovePrincipalsResponse contains the response from method Databases.RemovePrincipals. +type DatabasesRemovePrincipalsResponse struct { + DatabasesRemovePrincipalsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesRemovePrincipalsResult contains the result from method Databases.RemovePrincipals. +type DatabasesRemovePrincipalsResult struct { + DatabasePrincipalListResult +} + +// DatabasesUpdatePollerResponse contains the response from method Databases.Update. +type DatabasesUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatabasesUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DatabasesUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatabasesUpdateResponse, error) { + respType := DatabasesUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DatabaseClassification) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatabasesUpdatePollerResponse from the provided client and resume token. +func (l *DatabasesUpdatePollerResponse) Resume(ctx context.Context, client *DatabasesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatabasesClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &DatabasesUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatabasesUpdateResponse contains the response from method Databases.Update. +type DatabasesUpdateResponse struct { + DatabasesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatabasesUpdateResult contains the result from method Databases.Update. +type DatabasesUpdateResult struct { + DatabaseClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DatabasesUpdateResult. +func (d *DatabasesUpdateResult) UnmarshalJSON(data []byte) error { + res, err := unmarshalDatabaseClassification(data) + if err != nil { + return err + } + d.DatabaseClassification = res + return nil +} + +// ManagedPrivateEndpointsCheckNameAvailabilityResponse contains the response from method ManagedPrivateEndpoints.CheckNameAvailability. +type ManagedPrivateEndpointsCheckNameAvailabilityResponse struct { + ManagedPrivateEndpointsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagedPrivateEndpointsCheckNameAvailabilityResult contains the result from method ManagedPrivateEndpoints.CheckNameAvailability. +type ManagedPrivateEndpointsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// ManagedPrivateEndpointsCreateOrUpdatePollerResponse contains the response from method ManagedPrivateEndpoints.CreateOrUpdate. +type ManagedPrivateEndpointsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ManagedPrivateEndpointsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ManagedPrivateEndpointsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ManagedPrivateEndpointsCreateOrUpdateResponse, error) { + respType := ManagedPrivateEndpointsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ManagedPrivateEndpoint) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ManagedPrivateEndpointsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ManagedPrivateEndpointsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ManagedPrivateEndpointsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ManagedPrivateEndpointsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ManagedPrivateEndpointsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ManagedPrivateEndpointsCreateOrUpdateResponse contains the response from method ManagedPrivateEndpoints.CreateOrUpdate. +type ManagedPrivateEndpointsCreateOrUpdateResponse struct { + ManagedPrivateEndpointsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagedPrivateEndpointsCreateOrUpdateResult contains the result from method ManagedPrivateEndpoints.CreateOrUpdate. +type ManagedPrivateEndpointsCreateOrUpdateResult struct { + ManagedPrivateEndpoint +} + +// ManagedPrivateEndpointsDeletePollerResponse contains the response from method ManagedPrivateEndpoints.Delete. +type ManagedPrivateEndpointsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ManagedPrivateEndpointsDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ManagedPrivateEndpointsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ManagedPrivateEndpointsDeleteResponse, error) { + respType := ManagedPrivateEndpointsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ManagedPrivateEndpointsDeletePollerResponse from the provided client and resume token. +func (l *ManagedPrivateEndpointsDeletePollerResponse) Resume(ctx context.Context, client *ManagedPrivateEndpointsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ManagedPrivateEndpointsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ManagedPrivateEndpointsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ManagedPrivateEndpointsDeleteResponse contains the response from method ManagedPrivateEndpoints.Delete. +type ManagedPrivateEndpointsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagedPrivateEndpointsGetResponse contains the response from method ManagedPrivateEndpoints.Get. +type ManagedPrivateEndpointsGetResponse struct { + ManagedPrivateEndpointsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagedPrivateEndpointsGetResult contains the result from method ManagedPrivateEndpoints.Get. +type ManagedPrivateEndpointsGetResult struct { + ManagedPrivateEndpoint +} + +// ManagedPrivateEndpointsListResponse contains the response from method ManagedPrivateEndpoints.List. +type ManagedPrivateEndpointsListResponse struct { + ManagedPrivateEndpointsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagedPrivateEndpointsListResult contains the result from method ManagedPrivateEndpoints.List. +type ManagedPrivateEndpointsListResult struct { + ManagedPrivateEndpointListResult +} + +// ManagedPrivateEndpointsUpdatePollerResponse contains the response from method ManagedPrivateEndpoints.Update. +type ManagedPrivateEndpointsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ManagedPrivateEndpointsUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ManagedPrivateEndpointsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ManagedPrivateEndpointsUpdateResponse, error) { + respType := ManagedPrivateEndpointsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ManagedPrivateEndpoint) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ManagedPrivateEndpointsUpdatePollerResponse from the provided client and resume token. +func (l *ManagedPrivateEndpointsUpdatePollerResponse) Resume(ctx context.Context, client *ManagedPrivateEndpointsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ManagedPrivateEndpointsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &ManagedPrivateEndpointsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ManagedPrivateEndpointsUpdateResponse contains the response from method ManagedPrivateEndpoints.Update. +type ManagedPrivateEndpointsUpdateResponse struct { + ManagedPrivateEndpointsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagedPrivateEndpointsUpdateResult contains the result from method ManagedPrivateEndpoints.Update. +type ManagedPrivateEndpointsUpdateResult struct { + ManagedPrivateEndpoint +} + +// 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 +} + +// OperationsResultsGetResponse contains the response from method OperationsResults.Get. +type OperationsResultsGetResponse struct { + OperationsResultsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsResultsGetResult contains the result from method OperationsResults.Get. +type OperationsResultsGetResult struct { + OperationResult +} + +// PrivateEndpointConnectionsCreateOrUpdatePollerResponse contains the response from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateEndpointConnectionsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l PrivateEndpointConnectionsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionsCreateOrUpdateResponse, error) { + respType := PrivateEndpointConnectionsCreateOrUpdateResponse{} + 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 PrivateEndpointConnectionsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *PrivateEndpointConnectionsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *PrivateEndpointConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateEndpointConnectionsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &PrivateEndpointConnectionsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateEndpointConnectionsCreateOrUpdateResponse contains the response from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdateResponse struct { + PrivateEndpointConnectionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsCreateOrUpdateResult contains the result from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdateResult 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +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 { + PrivateEndpointConnectionListResult +} + +// 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 { + PrivateLinkResource +} + +// 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 { + PrivateLinkResourceListResult +} + +// ScriptsCheckNameAvailabilityResponse contains the response from method Scripts.CheckNameAvailability. +type ScriptsCheckNameAvailabilityResponse struct { + ScriptsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptsCheckNameAvailabilityResult contains the result from method Scripts.CheckNameAvailability. +type ScriptsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// ScriptsCreateOrUpdatePollerResponse contains the response from method Scripts.CreateOrUpdate. +type ScriptsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ScriptsCreateOrUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ScriptsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ScriptsCreateOrUpdateResponse, error) { + respType := ScriptsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Script) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ScriptsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ScriptsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ScriptsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ScriptsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ScriptsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ScriptsCreateOrUpdateResponse contains the response from method Scripts.CreateOrUpdate. +type ScriptsCreateOrUpdateResponse struct { + ScriptsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptsCreateOrUpdateResult contains the result from method Scripts.CreateOrUpdate. +type ScriptsCreateOrUpdateResult struct { + Script +} + +// ScriptsDeletePollerResponse contains the response from method Scripts.Delete. +type ScriptsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ScriptsDeletePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ScriptsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ScriptsDeleteResponse, error) { + respType := ScriptsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ScriptsDeletePollerResponse from the provided client and resume token. +func (l *ScriptsDeletePollerResponse) Resume(ctx context.Context, client *ScriptsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ScriptsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ScriptsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ScriptsDeleteResponse contains the response from method Scripts.Delete. +type ScriptsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptsGetResponse contains the response from method Scripts.Get. +type ScriptsGetResponse struct { + ScriptsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptsGetResult contains the result from method Scripts.Get. +type ScriptsGetResult struct { + Script +} + +// ScriptsListByDatabaseResponse contains the response from method Scripts.ListByDatabase. +type ScriptsListByDatabaseResponse struct { + ScriptsListByDatabaseResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptsListByDatabaseResult contains the result from method Scripts.ListByDatabase. +type ScriptsListByDatabaseResult struct { + ScriptListResult +} + +// ScriptsUpdatePollerResponse contains the response from method Scripts.Update. +type ScriptsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ScriptsUpdatePoller + + // 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. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ScriptsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ScriptsUpdateResponse, error) { + respType := ScriptsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Script) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ScriptsUpdatePollerResponse from the provided client and resume token. +func (l *ScriptsUpdatePollerResponse) Resume(ctx context.Context, client *ScriptsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ScriptsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &ScriptsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ScriptsUpdateResponse contains the response from method Scripts.Update. +type ScriptsUpdateResponse struct { + ScriptsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptsUpdateResult contains the result from method Scripts.Update. +type ScriptsUpdateResult struct { + Script +} diff --git a/sdk/resourcemanager/kusto/armkusto/zz_generated_scripts_client.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_scripts_client.go new file mode 100644 index 000000000000..586a0c1e16bb --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_scripts_client.go @@ -0,0 +1,506 @@ +//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 armkusto + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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" + "net/http" + "net/url" + "strings" +) + +// ScriptsClient contains the methods for the Scripts group. +// Don't use this type directly, use NewScriptsClient() instead. +type ScriptsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewScriptsClient creates a new instance of ScriptsClient with the specified values. +func NewScriptsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ScriptsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ScriptsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the script name is valid and is not already in use. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName ScriptCheckNameRequest, options *ScriptsCheckNameAvailabilityOptions) (ScriptsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, clusterName, databaseName, scriptName, options) + if err != nil { + return ScriptsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *ScriptsClient) checkNameAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName ScriptCheckNameRequest, options *ScriptsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, scriptName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *ScriptsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (ScriptsCheckNameAvailabilityResponse, error) { + result := ScriptsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return ScriptsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *ScriptsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginCreateOrUpdate - Creates a Kusto database script. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsBeginCreateOrUpdateOptions) (ScriptsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, databaseName, scriptName, parameters, options) + if err != nil { + return ScriptsCreateOrUpdatePollerResponse{}, err + } + result := ScriptsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ScriptsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ScriptsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ScriptsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates a Kusto database script. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, scriptName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ScriptsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + 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-08-27") + 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 *ScriptsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsBeginDeleteOptions) (ScriptsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, databaseName, scriptName, options) + if err != nil { + return ScriptsDeletePollerResponse{}, err + } + result := ScriptsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ScriptsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return ScriptsDeletePollerResponse{}, err + } + result.Poller = &ScriptsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes a Kusto principalAssignment. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, databaseName, scriptName, 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 *ScriptsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ScriptsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Kusto cluster database script. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsGetOptions) (ScriptsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, databaseName, scriptName, options) + if err != nil { + return ScriptsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ScriptsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScriptsClient) getHandleResponse(resp *http.Response) (ScriptsGetResponse, error) { + result := ScriptsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Script); err != nil { + return ScriptsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ScriptsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListByDatabase - Returns the list of database scripts for given database. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) ListByDatabase(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *ScriptsListByDatabaseOptions) (ScriptsListByDatabaseResponse, error) { + req, err := client.listByDatabaseCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) + if err != nil { + return ScriptsListByDatabaseResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptsListByDatabaseResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptsListByDatabaseResponse{}, client.listByDatabaseHandleError(resp) + } + return client.listByDatabaseHandleResponse(resp) +} + +// listByDatabaseCreateRequest creates the ListByDatabase request. +func (client *ScriptsClient) listByDatabaseCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *ScriptsListByDatabaseOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + 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-08-27") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByDatabaseHandleResponse handles the ListByDatabase response. +func (client *ScriptsClient) listByDatabaseHandleResponse(resp *http.Response) (ScriptsListByDatabaseResponse, error) { + result := ScriptsListByDatabaseResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptListResult); err != nil { + return ScriptsListByDatabaseResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByDatabaseHandleError handles the ListByDatabase error response. +func (client *ScriptsClient) listByDatabaseHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 database script. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) BeginUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsBeginUpdateOptions) (ScriptsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, clusterName, databaseName, scriptName, parameters, options) + if err != nil { + return ScriptsUpdatePollerResponse{}, err + } + result := ScriptsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ScriptsClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return ScriptsUpdatePollerResponse{}, err + } + result.Poller = &ScriptsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates a database script. +// If the operation fails it returns the *CloudError error type. +func (client *ScriptsClient) update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, databaseName, scriptName, 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 *ScriptsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if databaseName == "" { + return nil, errors.New("parameter databaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + 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-08-27") + 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 *ScriptsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/kusto/armkusto/zz_generated_time_rfc3339.go b/sdk/resourcemanager/kusto/armkusto/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..4aaec884edb0 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//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 armkusto + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "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 +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + *t = (*time.Time)(&aux) + return nil +}