From b165d7249c7d39a7fd00cbcd1e3b79cf531205d8 Mon Sep 17 00:00:00 2001 From: Jiahui Peng <46921893+Alancere@users.noreply.github.com> Date: Thu, 23 Dec 2021 14:44:47 +0800 Subject: [PATCH] Release sdk/resourcemanager/avs/armavs/0.1.0 (#16631) * Release sdk/resourcemanager/avs/armavs/0.1.0 * Update CHANGELOG.md Co-authored-by: Dapeng Zhang --- sdk/resourcemanager/avs/armavs/CHANGELOG.md | 5 + sdk/resourcemanager/avs/armavs/LICENSE.txt | 21 + sdk/resourcemanager/avs/armavs/README.md | 75 + sdk/resourcemanager/avs/armavs/autorest.md | 12 + sdk/resourcemanager/avs/armavs/build.go | 7 + sdk/resourcemanager/avs/armavs/ci.yml | 27 + sdk/resourcemanager/avs/armavs/go.mod | 9 + sdk/resourcemanager/avs/armavs/go.sum | 45 + .../avs/armavs/go_mod_tidy_hack.go | 13 + ...ze_generated_example_addons_client_test.go | 113 + ...ated_example_authorizations_client_test.go | 105 + ...enerated_example_cloudlinks_client_test.go | 110 + ..._generated_example_clusters_client_test.go | 143 + ...enerated_example_datastores_client_test.go | 116 + ...mple_globalreachconnections_client_test.go | 111 + ..._example_hcxenterprisesites_client_test.go | 95 + ...generated_example_locations_client_test.go | 49 + ...enerated_example_operations_client_test.go | 33 + ...d_example_placementpolicies_client_test.go | 160 + ...rated_example_privateclouds_client_test.go | 243 ++ ...rated_example_scriptcmdlets_client_test.go | 59 + ...ed_example_scriptexecutions_client_test.go | 159 + ...ated_example_scriptpackages_client_test.go | 57 + ...ted_example_virtualmachines_client_test.go | 87 + ...ed_example_workloadnetworks_client_test.go | 957 +++++ .../avs/armavs/zz_generated_addons_client.go | 334 ++ .../zz_generated_authorizations_client.go | 334 ++ .../armavs/zz_generated_cloudlinks_client.go | 334 ++ .../armavs/zz_generated_clusters_client.go | 414 ++ .../avs/armavs/zz_generated_constants.go | 1147 ++++++ .../armavs/zz_generated_datastores_client.go | 350 ++ ...generated_globalreachconnections_client.go | 334 ++ .../zz_generated_hcxenterprisesites_client.go | 303 ++ .../armavs/zz_generated_locations_client.go | 165 + .../avs/armavs/zz_generated_models.go | 3648 +++++++++++++++++ .../armavs/zz_generated_operations_client.go | 89 + .../avs/armavs/zz_generated_pagers.go | 1313 ++++++ .../zz_generated_placementpolicies_client.go | 434 ++ .../avs/armavs/zz_generated_pollers.go | 1907 +++++++++ .../zz_generated_polymorphic_helpers.go | 247 ++ .../zz_generated_privateclouds_client.go | 665 +++ .../avs/armavs/zz_generated_response_types.go | 2808 +++++++++++++ .../zz_generated_scriptcmdlets_client.go | 182 + .../zz_generated_scriptexecutions_client.go | 406 ++ .../zz_generated_scriptpackages_client.go | 174 + .../avs/armavs/zz_generated_time_rfc3339.go | 85 + .../zz_generated_virtualmachines_client.go | 266 ++ .../zz_generated_workloadnetworks_client.go | 2822 +++++++++++++ 48 files changed, 21572 insertions(+) create mode 100644 sdk/resourcemanager/avs/armavs/CHANGELOG.md create mode 100644 sdk/resourcemanager/avs/armavs/LICENSE.txt create mode 100644 sdk/resourcemanager/avs/armavs/README.md create mode 100644 sdk/resourcemanager/avs/armavs/autorest.md create mode 100644 sdk/resourcemanager/avs/armavs/build.go create mode 100644 sdk/resourcemanager/avs/armavs/ci.yml create mode 100644 sdk/resourcemanager/avs/armavs/go.mod create mode 100644 sdk/resourcemanager/avs/armavs/go.sum create mode 100644 sdk/resourcemanager/avs/armavs/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_addons_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_authorizations_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_cloudlinks_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_clusters_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_datastores_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_globalreachconnections_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_hcxenterprisesites_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_locations_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_operations_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_placementpolicies_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_privateclouds_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_scriptcmdlets_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_scriptexecutions_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_scriptpackages_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_virtualmachines_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/ze_generated_example_workloadnetworks_client_test.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_addons_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_authorizations_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_cloudlinks_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_clusters_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_constants.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_datastores_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_globalreachconnections_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_hcxenterprisesites_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_locations_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_models.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_placementpolicies_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_polymorphic_helpers.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_privateclouds_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_scriptcmdlets_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_scriptexecutions_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_scriptpackages_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_time_rfc3339.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_virtualmachines_client.go create mode 100644 sdk/resourcemanager/avs/armavs/zz_generated_workloadnetworks_client.go diff --git a/sdk/resourcemanager/avs/armavs/CHANGELOG.md b/sdk/resourcemanager/avs/armavs/CHANGELOG.md new file mode 100644 index 000000000000..1dea10904247 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-23) + +- Init release. diff --git a/sdk/resourcemanager/avs/armavs/LICENSE.txt b/sdk/resourcemanager/avs/armavs/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/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/avs/armavs/README.md b/sdk/resourcemanager/avs/armavs/README.md new file mode 100644 index 000000000000..be73a87834ea --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/README.md @@ -0,0 +1,75 @@ +# Azure VMware Solution Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs) + +The `armavs` module provides operations for working with Azure VMware Solution. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/avs/armavs) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.16 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 VMware Solution module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure VMware Solution. 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 VMware Solution 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 := armavs.NewVirtualMachinesClient(, 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 := armavs.NewVirtualMachinesClient(, 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 `VMware Solution` 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/avs/armavs/autorest.md b/sdk/resourcemanager/avs/armavs/autorest.md new file mode 100644 index 000000000000..fd8c192fbb74 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/c09b26d4aaa40fb37380aae01b7019b75cff3e34/specification/vmware/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/c09b26d4aaa40fb37380aae01b7019b75cff3e34/specification/vmware/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/avs/armavs/build.go b/sdk/resourcemanager/avs/armavs/build.go new file mode 100644 index 000000000000..7a434f5714da --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/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/avs/armavs + +package armavs diff --git a/sdk/resourcemanager/avs/armavs/ci.yml b/sdk/resourcemanager/avs/armavs/ci.yml new file mode 100644 index 000000000000..4ef80f46d5cb --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/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/avs/armavs/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/avs/armavs/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/avs/armavs' diff --git a/sdk/resourcemanager/avs/armavs/go.mod b/sdk/resourcemanager/avs/armavs/go.mod new file mode 100644 index 000000000000..69fb03fe3fca --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 +) diff --git a/sdk/resourcemanager/avs/armavs/go.sum b/sdk/resourcemanager/avs/armavs/go.sum new file mode 100644 index 000000000000..35739a609db5 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible h1:j6y8ddurcaiyLfwBwPmJFaunp6BDzyQTuAgMrm1r++o= +github.com/Azure/azure-sdk-for-go v60.1.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/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS9cgjHVYSH6DDa0XJMyrblsI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0/go.mod h1:GJzjM4SR9T0KyX5gKCVyz1ytD8FeWeUPCwtFCt1AyfE= +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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +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/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/avs/armavs/go_mod_tidy_hack.go b/sdk/resourcemanager/avs/armavs/go_mod_tidy_hack.go new file mode 100644 index 000000000000..518900867934 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/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 armavs + +// 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/avs/armavs/ze_generated_example_addons_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_addons_client_test.go new file mode 100644 index 000000000000..c6f76c95492b --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_addons_client_test.go @@ -0,0 +1,113 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Addons_List.json +func ExampleAddonsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAddonsClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("Addon.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Addons_Get_HCX.json +func ExampleAddonsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAddonsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Addon.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Addons_CreateOrUpdate_HCX.json +func ExampleAddonsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAddonsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + armavs.Addon{ + Properties: &armavs.AddonHcxProperties{ + AddonProperties: armavs.AddonProperties{ + AddonType: armavs.AddonTypeHCX.ToPtr(), + }, + Offer: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Addon.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Addons_Delete.json +func ExampleAddonsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAddonsClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_authorizations_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_authorizations_client_test.go new file mode 100644 index 000000000000..dfea53783304 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_authorizations_client_test.go @@ -0,0 +1,105 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Authorizations_List.json +func ExampleAuthorizationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAuthorizationsClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ExpressRouteAuthorization.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Authorizations_Get.json +func ExampleAuthorizationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAuthorizationsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ExpressRouteAuthorization.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Authorizations_CreateOrUpdate.json +func ExampleAuthorizationsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAuthorizationsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + armavs.ExpressRouteAuthorization{}, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("ExpressRouteAuthorization.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Authorizations_Delete.json +func ExampleAuthorizationsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewAuthorizationsClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_cloudlinks_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_cloudlinks_client_test.go new file mode 100644 index 000000000000..e6395cedb7eb --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_cloudlinks_client_test.go @@ -0,0 +1,110 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/CloudLinks_List.json +func ExampleCloudLinksClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewCloudLinksClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("CloudLink.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/CloudLinks_Get.json +func ExampleCloudLinksClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewCloudLinksClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("CloudLink.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/CloudLinks_CreateOrUpdate.json +func ExampleCloudLinksClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewCloudLinksClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + armavs.CloudLink{ + Properties: &armavs.CloudLinkProperties{ + LinkedCloud: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("CloudLink.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/CloudLinks_Delete.json +func ExampleCloudLinksClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewCloudLinksClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_clusters_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_clusters_client_test.go new file mode 100644 index 000000000000..fdad2fae49cc --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_clusters_client_test.go @@ -0,0 +1,143 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Clusters_List.json +func ExampleClustersClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewClustersClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("Cluster.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Clusters_Get.json +func ExampleClustersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewClustersClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Cluster.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Clusters_CreateOrUpdate.json +func ExampleClustersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewClustersClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + armavs.Cluster{ + Properties: &armavs.ClusterProperties{ + CommonClusterProperties: armavs.CommonClusterProperties{ + ClusterSize: to.Int32Ptr(3), + }, + }, + SKU: &armavs.SKU{ + Name: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Cluster.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Clusters_Update.json +func ExampleClustersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewClustersClient("", cred, nil) + poller, err := client.BeginUpdate(ctx, + "", + "", + "", + armavs.ClusterUpdate{ + Properties: &armavs.ClusterUpdateProperties{ + ClusterSize: to.Int32Ptr(4), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Cluster.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Clusters_Delete.json +func ExampleClustersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewClustersClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_datastores_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_datastores_client_test.go new file mode 100644 index 000000000000..fcf3d5ae00ed --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_datastores_client_test.go @@ -0,0 +1,116 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Datastores_List.json +func ExampleDatastoresClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewDatastoresClient("", cred, nil) + pager := client.List("", + "", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("Datastore.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Datastores_Get.json +func ExampleDatastoresClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewDatastoresClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Datastore.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Datastores_CreateOrUpdate.json +func ExampleDatastoresClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewDatastoresClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + "", + armavs.Datastore{ + Properties: &armavs.DatastoreProperties{ + NetAppVolume: &armavs.NetAppVolume{ + ID: to.StringPtr(""), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Datastore.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Datastores_Delete.json +func ExampleDatastoresClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewDatastoresClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_globalreachconnections_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_globalreachconnections_client_test.go new file mode 100644 index 000000000000..6ffe39f0eae3 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_globalreachconnections_client_test.go @@ -0,0 +1,111 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/GlobalReachConnections_List.json +func ExampleGlobalReachConnectionsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewGlobalReachConnectionsClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("GlobalReachConnection.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/GlobalReachConnections_Get.json +func ExampleGlobalReachConnectionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewGlobalReachConnectionsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("GlobalReachConnection.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/GlobalReachConnections_CreateOrUpdate.json +func ExampleGlobalReachConnectionsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewGlobalReachConnectionsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + armavs.GlobalReachConnection{ + Properties: &armavs.GlobalReachConnectionProperties{ + AuthorizationKey: to.StringPtr(""), + PeerExpressRouteCircuit: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("GlobalReachConnection.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/GlobalReachConnections_Delete.json +func ExampleGlobalReachConnectionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewGlobalReachConnectionsClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_hcxenterprisesites_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_hcxenterprisesites_client_test.go new file mode 100644 index 000000000000..683e73b76dbe --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_hcxenterprisesites_client_test.go @@ -0,0 +1,95 @@ +//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 armavs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/HcxEnterpriseSites_List.json +func ExampleHcxEnterpriseSitesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewHcxEnterpriseSitesClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("HcxEnterpriseSite.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/HcxEnterpriseSites_Get.json +func ExampleHcxEnterpriseSitesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewHcxEnterpriseSitesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("HcxEnterpriseSite.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/HcxEnterpriseSites_CreateOrUpdate.json +func ExampleHcxEnterpriseSitesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewHcxEnterpriseSitesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armavs.HcxEnterpriseSite{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("HcxEnterpriseSite.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/HcxEnterpriseSites_Delete.json +func ExampleHcxEnterpriseSitesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewHcxEnterpriseSitesClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_locations_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_locations_client_test.go new file mode 100644 index 000000000000..5434c91041b3 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_locations_client_test.go @@ -0,0 +1,49 @@ +//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 armavs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Locations_CheckTrialAvailability.json +func ExampleLocationsClient_CheckTrialAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewLocationsClient("", cred, nil) + _, err = client.CheckTrialAvailability(ctx, + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Locations_CheckQuotaAvailability.json +func ExampleLocationsClient_CheckQuotaAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewLocationsClient("", cred, nil) + _, err = client.CheckQuotaAvailability(ctx, + "", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_operations_client_test.go new file mode 100644 index 000000000000..c63d3375e63c --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_operations_client_test.go @@ -0,0 +1,33 @@ +//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 armavs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/Operations_List.json +func ExampleOperationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewOperationsClient(cred, nil) + pager := client.List(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_placementpolicies_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_placementpolicies_client_test.go new file mode 100644 index 000000000000..e9908e839ecc --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_placementpolicies_client_test.go @@ -0,0 +1,160 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PlacementPolicies_List.json +func ExamplePlacementPoliciesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPlacementPoliciesClient("", cred, nil) + pager := client.List("", + "", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("PlacementPolicy.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PlacementPolicies_Get.json +func ExamplePlacementPoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPlacementPoliciesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PlacementPolicy.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PlacementPolicies_CreateOrUpdate.json +func ExamplePlacementPoliciesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPlacementPoliciesClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + "", + armavs.PlacementPolicy{ + Properties: &armavs.VMHostPlacementPolicyProperties{ + PlacementPolicyProperties: armavs.PlacementPolicyProperties{ + Type: armavs.PlacementPolicyTypeVMHost.ToPtr(), + }, + AffinityType: armavs.AffinityTypeAntiAffinity.ToPtr(), + HostMembers: []*string{ + to.StringPtr("fakehost22.nyc1.kubernetes.center"), + to.StringPtr("fakehost23.nyc1.kubernetes.center"), + to.StringPtr("fakehost24.nyc1.kubernetes.center")}, + VMMembers: []*string{ + to.StringPtr("/subscriptions/{subscription-id}/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-128"), + to.StringPtr("/subscriptions/{subscription-id}/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-256")}, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("PlacementPolicy.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PlacementPolicies_Update.json +func ExamplePlacementPoliciesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPlacementPoliciesClient("", cred, nil) + poller, err := client.BeginUpdate(ctx, + "", + "", + "", + "", + armavs.PlacementPolicyUpdate{ + Properties: &armavs.PlacementPolicyUpdateProperties{ + HostMembers: []*string{ + to.StringPtr("fakehost22.nyc1.kubernetes.center"), + to.StringPtr("fakehost23.nyc1.kubernetes.center"), + to.StringPtr("fakehost24.nyc1.kubernetes.center")}, + State: armavs.PlacementPolicyStateDisabled.ToPtr(), + VMMembers: []*string{ + to.StringPtr("/subscriptions/{subscription-id}/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-128"), + to.StringPtr("/subscriptions/{subscription-id}/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-256")}, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("PlacementPolicy.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PlacementPolicies_Delete.json +func ExamplePlacementPoliciesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPlacementPoliciesClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_privateclouds_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_privateclouds_client_test.go new file mode 100644 index 000000000000..6088a7da2d75 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_privateclouds_client_test.go @@ -0,0 +1,243 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_List.json +func ExamplePrivateCloudsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + pager := client.List("", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("PrivateCloud.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_ListInSubscription.json +func ExamplePrivateCloudsClient_ListInSubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + pager := client.ListInSubscription(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("PrivateCloud.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_Get.json +func ExamplePrivateCloudsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateCloud.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_CreateOrUpdate.json +func ExamplePrivateCloudsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armavs.PrivateCloud{ + TrackedResource: armavs.TrackedResource{ + Location: to.StringPtr(""), + Tags: map[string]*string{}, + }, + Identity: &armavs.PrivateCloudIdentity{ + Type: armavs.ResourceIdentityTypeSystemAssigned.ToPtr(), + }, + Properties: &armavs.PrivateCloudProperties{ + PrivateCloudUpdateProperties: armavs.PrivateCloudUpdateProperties{ + ManagementCluster: &armavs.ManagementCluster{ + CommonClusterProperties: armavs.CommonClusterProperties{ + ClusterSize: to.Int32Ptr(4), + }, + }, + }, + NetworkBlock: to.StringPtr(""), + }, + SKU: &armavs.SKU{ + Name: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateCloud.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_Update.json +func ExamplePrivateCloudsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + poller, err := client.BeginUpdate(ctx, + "", + "", + armavs.PrivateCloudUpdate{ + Identity: &armavs.PrivateCloudIdentity{ + Type: armavs.ResourceIdentityTypeNone.ToPtr(), + }, + Properties: &armavs.PrivateCloudUpdateProperties{ + Encryption: &armavs.Encryption{ + KeyVaultProperties: &armavs.EncryptionKeyVaultProperties{ + KeyName: to.StringPtr(""), + KeyVaultURL: to.StringPtr(""), + KeyVersion: to.StringPtr(""), + }, + Status: armavs.EncryptionStateEnabled.ToPtr(), + }, + ManagementCluster: &armavs.ManagementCluster{ + CommonClusterProperties: armavs.CommonClusterProperties{ + ClusterSize: to.Int32Ptr(4), + }, + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateCloud.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_Delete.json +func ExamplePrivateCloudsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_RotateVcenterPassword.json +func ExamplePrivateCloudsClient_BeginRotateVcenterPassword() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + poller, err := client.BeginRotateVcenterPassword(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_RotateNsxtPassword.json +func ExamplePrivateCloudsClient_BeginRotateNsxtPassword() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + poller, err := client.BeginRotateNsxtPassword(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/PrivateClouds_ListAdminCredentials.json +func ExamplePrivateCloudsClient_ListAdminCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewPrivateCloudsClient("", cred, nil) + _, err = client.ListAdminCredentials(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptcmdlets_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptcmdlets_client_test.go new file mode 100644 index 000000000000..f7575173ac03 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptcmdlets_client_test.go @@ -0,0 +1,59 @@ +//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 armavs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptCmdlets_List.json +func ExampleScriptCmdletsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptCmdletsClient("", cred, nil) + pager := client.List("", + "", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ScriptCmdlet.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptCmdlets_Get.json +func ExampleScriptCmdletsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptCmdletsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ScriptCmdlet.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptexecutions_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptexecutions_client_test.go new file mode 100644 index 000000000000..b0b8ebc75050 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptexecutions_client_test.go @@ -0,0 +1,159 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptExecutions_List.json +func ExampleScriptExecutionsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptExecutionsClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ScriptExecution.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptExecutions_Get.json +func ExampleScriptExecutionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptExecutionsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ScriptExecution.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptExecutions_CreateOrUpdate.json +func ExampleScriptExecutionsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptExecutionsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + "", + armavs.ScriptExecution{ + Properties: &armavs.ScriptExecutionProperties{ + HiddenParameters: []armavs.ScriptExecutionParameterClassification{ + &armavs.ScriptSecureStringExecutionParameter{ + ScriptExecutionParameter: armavs.ScriptExecutionParameter{ + Name: to.StringPtr(""), + Type: armavs.ScriptExecutionParameterTypeSecureValue.ToPtr(), + }, + SecureValue: to.StringPtr(""), + }}, + Parameters: []armavs.ScriptExecutionParameterClassification{ + &armavs.ScriptStringExecutionParameter{ + ScriptExecutionParameter: armavs.ScriptExecutionParameter{ + Name: to.StringPtr(""), + Type: armavs.ScriptExecutionParameterTypeValue.ToPtr(), + }, + Value: to.StringPtr(""), + }, + &armavs.ScriptStringExecutionParameter{ + ScriptExecutionParameter: armavs.ScriptExecutionParameter{ + Name: to.StringPtr(""), + Type: armavs.ScriptExecutionParameterTypeValue.ToPtr(), + }, + Value: to.StringPtr(""), + }}, + Retention: to.StringPtr(""), + ScriptCmdletID: to.StringPtr(""), + Timeout: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("ScriptExecution.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptExecutions_Delete.json +func ExampleScriptExecutionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptExecutionsClient("", cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptExecutions_GetExecutionLogs.json +func ExampleScriptExecutionsClient_GetExecutionLogs() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptExecutionsClient("", cred, nil) + res, err := client.GetExecutionLogs(ctx, + "", + "", + "", + &armavs.ScriptExecutionsGetExecutionLogsOptions{ScriptOutputStreamType: []*armavs.ScriptOutputStreamType{ + armavs.ScriptOutputStreamTypeInformation.ToPtr(), + armavs.ScriptOutputStreamTypeInformation.ToPtr(), + armavs.ScriptOutputStreamTypeInformation.ToPtr(), + armavs.ScriptOutputStreamTypeOutput.ToPtr()}, + }) + if err != nil { + log.Fatal(err) + } + log.Printf("ScriptExecution.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptpackages_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptpackages_client_test.go new file mode 100644 index 000000000000..4dcd5a0b4558 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_scriptpackages_client_test.go @@ -0,0 +1,57 @@ +//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 armavs_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptPackages_List.json +func ExampleScriptPackagesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptPackagesClient("", cred, nil) + pager := client.List("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ScriptPackage.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/ScriptPackages_Get.json +func ExampleScriptPackagesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewScriptPackagesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ScriptPackage.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_virtualmachines_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_virtualmachines_client_test.go new file mode 100644 index 000000000000..d521852fa838 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_virtualmachines_client_test.go @@ -0,0 +1,87 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/VirtualMachines_List.json +func ExampleVirtualMachinesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewVirtualMachinesClient("", cred, nil) + pager := client.List("", + "", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("VirtualMachine.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/VirtualMachines_Get.json +func ExampleVirtualMachinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewVirtualMachinesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VirtualMachine.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/VirtualMachines_RestrictMovement.json +func ExampleVirtualMachinesClient_BeginRestrictMovement() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewVirtualMachinesClient("", cred, nil) + poller, err := client.BeginRestrictMovement(ctx, + "", + "", + "", + "", + armavs.VirtualMachineRestrictMovement{ + RestrictMovement: armavs.VirtualMachineRestrictMovementStateEnabled.ToPtr(), + }, + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/ze_generated_example_workloadnetworks_client_test.go b/sdk/resourcemanager/avs/armavs/ze_generated_example_workloadnetworks_client_test.go new file mode 100644 index 000000000000..53e18b8c07f7 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/ze_generated_example_workloadnetworks_client_test.go @@ -0,0 +1,957 @@ +//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 armavs_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/avs/armavs" +) + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListSegments.json +func ExampleWorkloadNetworksClient_ListSegments() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListSegments("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkSegment.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetSegments.json +func ExampleWorkloadNetworksClient_GetSegment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetSegment(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkSegment.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreateSegments.json +func ExampleWorkloadNetworksClient_BeginCreateSegments() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreateSegments(ctx, + "", + "", + "", + armavs.WorkloadNetworkSegment{ + Properties: &armavs.WorkloadNetworkSegmentProperties{ + ConnectedGateway: to.StringPtr(""), + DisplayName: to.StringPtr(""), + Revision: to.Int64Ptr(1), + Subnet: &armavs.WorkloadNetworkSegmentSubnet{ + DhcpRanges: []*string{ + to.StringPtr("40.20.0.0-40.20.0.1")}, + GatewayAddress: to.StringPtr(""), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkSegment.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_UpdateSegments.json +func ExampleWorkloadNetworksClient_BeginUpdateSegments() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginUpdateSegments(ctx, + "", + "", + "", + armavs.WorkloadNetworkSegment{ + Properties: &armavs.WorkloadNetworkSegmentProperties{ + ConnectedGateway: to.StringPtr(""), + Revision: to.Int64Ptr(1), + Subnet: &armavs.WorkloadNetworkSegmentSubnet{ + DhcpRanges: []*string{ + to.StringPtr("40.20.0.0-40.20.0.1")}, + GatewayAddress: to.StringPtr(""), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkSegment.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeleteSegments.json +func ExampleWorkloadNetworksClient_BeginDeleteSegment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeleteSegment(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListDhcpConfigurations.json +func ExampleWorkloadNetworksClient_ListDhcp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListDhcp("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkDhcp.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetDhcpConfigurations.json +func ExampleWorkloadNetworksClient_GetDhcp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetDhcp(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDhcp.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreateDhcpConfigurations.json +func ExampleWorkloadNetworksClient_BeginCreateDhcp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreateDhcp(ctx, + "", + "", + "", + armavs.WorkloadNetworkDhcp{ + Properties: &armavs.WorkloadNetworkDhcpServer{ + WorkloadNetworkDhcpEntity: armavs.WorkloadNetworkDhcpEntity{ + DhcpType: armavs.DhcpTypeEnumSERVER.ToPtr(), + DisplayName: to.StringPtr(""), + Revision: to.Int64Ptr(1), + }, + LeaseTime: to.Int64Ptr(86400), + ServerAddress: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDhcp.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_UpdateDhcpConfigurations.json +func ExampleWorkloadNetworksClient_BeginUpdateDhcp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginUpdateDhcp(ctx, + "", + "", + "", + armavs.WorkloadNetworkDhcp{ + Properties: &armavs.WorkloadNetworkDhcpServer{ + WorkloadNetworkDhcpEntity: armavs.WorkloadNetworkDhcpEntity{ + DhcpType: armavs.DhcpTypeEnumSERVER.ToPtr(), + Revision: to.Int64Ptr(1), + }, + LeaseTime: to.Int64Ptr(86400), + ServerAddress: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDhcp.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeleteDhcpConfigurations.json +func ExampleWorkloadNetworksClient_BeginDeleteDhcp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeleteDhcp(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListGateways.json +func ExampleWorkloadNetworksClient_ListGateways() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListGateways("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkGateway.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetGateway.json +func ExampleWorkloadNetworksClient_GetGateway() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetGateway(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkGateway.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListPortMirroringProfiles.json +func ExampleWorkloadNetworksClient_ListPortMirroring() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListPortMirroring("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkPortMirroring.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetPortMirroringProfiles.json +func ExampleWorkloadNetworksClient_GetPortMirroring() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetPortMirroring(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkPortMirroring.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreatePortMirroringProfiles.json +func ExampleWorkloadNetworksClient_BeginCreatePortMirroring() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreatePortMirroring(ctx, + "", + "", + "", + armavs.WorkloadNetworkPortMirroring{ + Properties: &armavs.WorkloadNetworkPortMirroringProperties{ + Destination: to.StringPtr(""), + Direction: armavs.PortMirroringDirectionEnumBIDIRECTIONAL.ToPtr(), + DisplayName: to.StringPtr(""), + Revision: to.Int64Ptr(1), + Source: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkPortMirroring.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_UpdatePortMirroringProfiles.json +func ExampleWorkloadNetworksClient_BeginUpdatePortMirroring() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginUpdatePortMirroring(ctx, + "", + "", + "", + armavs.WorkloadNetworkPortMirroring{ + Properties: &armavs.WorkloadNetworkPortMirroringProperties{ + Destination: to.StringPtr(""), + Direction: armavs.PortMirroringDirectionEnumBIDIRECTIONAL.ToPtr(), + Revision: to.Int64Ptr(1), + Source: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkPortMirroring.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeletePortMirroringProfiles.json +func ExampleWorkloadNetworksClient_BeginDeletePortMirroring() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeletePortMirroring(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListVMGroups.json +func ExampleWorkloadNetworksClient_ListVMGroups() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListVMGroups("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkVMGroup.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetVMGroups.json +func ExampleWorkloadNetworksClient_GetVMGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetVMGroup(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkVMGroup.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreateVMGroups.json +func ExampleWorkloadNetworksClient_BeginCreateVMGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreateVMGroup(ctx, + "", + "", + "", + armavs.WorkloadNetworkVMGroup{ + Properties: &armavs.WorkloadNetworkVMGroupProperties{ + DisplayName: to.StringPtr(""), + Members: []*string{ + to.StringPtr("564d43da-fefc-2a3b-1d92-42855622fa50")}, + Revision: to.Int64Ptr(1), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkVMGroup.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_UpdateVMGroups.json +func ExampleWorkloadNetworksClient_BeginUpdateVMGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginUpdateVMGroup(ctx, + "", + "", + "", + armavs.WorkloadNetworkVMGroup{ + Properties: &armavs.WorkloadNetworkVMGroupProperties{ + Members: []*string{ + to.StringPtr("564d43da-fefc-2a3b-1d92-42855622fa50")}, + Revision: to.Int64Ptr(1), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkVMGroup.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeleteVMGroups.json +func ExampleWorkloadNetworksClient_BeginDeleteVMGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeleteVMGroup(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListVirtualMachines.json +func ExampleWorkloadNetworksClient_ListVirtualMachines() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListVirtualMachines("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkVirtualMachine.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetVirtualMachine.json +func ExampleWorkloadNetworksClient_GetVirtualMachine() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetVirtualMachine(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkVirtualMachine.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListDnsServices.json +func ExampleWorkloadNetworksClient_ListDNSServices() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListDNSServices("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkDNSService.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetDnsServices.json +func ExampleWorkloadNetworksClient_GetDNSService() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetDNSService(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDNSService.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreateDnsServices.json +func ExampleWorkloadNetworksClient_BeginCreateDNSService() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreateDNSService(ctx, + "", + "", + "", + armavs.WorkloadNetworkDNSService{ + Properties: &armavs.WorkloadNetworkDNSServiceProperties{ + DefaultDNSZone: to.StringPtr(""), + DisplayName: to.StringPtr(""), + DNSServiceIP: to.StringPtr(""), + FqdnZones: []*string{ + to.StringPtr("fqdnZone1")}, + LogLevel: armavs.DNSServiceLogLevelEnumINFO.ToPtr(), + Revision: to.Int64Ptr(1), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDNSService.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_UpdateDnsServices.json +func ExampleWorkloadNetworksClient_BeginUpdateDNSService() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginUpdateDNSService(ctx, + "", + "", + "", + armavs.WorkloadNetworkDNSService{ + Properties: &armavs.WorkloadNetworkDNSServiceProperties{ + DefaultDNSZone: to.StringPtr(""), + DisplayName: to.StringPtr(""), + DNSServiceIP: to.StringPtr(""), + FqdnZones: []*string{ + to.StringPtr("fqdnZone1")}, + LogLevel: armavs.DNSServiceLogLevelEnumINFO.ToPtr(), + Revision: to.Int64Ptr(1), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDNSService.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeleteDnsServices.json +func ExampleWorkloadNetworksClient_BeginDeleteDNSService() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeleteDNSService(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListDnsZones.json +func ExampleWorkloadNetworksClient_ListDNSZones() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListDNSZones("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkDNSZone.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetDnsZones.json +func ExampleWorkloadNetworksClient_GetDNSZone() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetDNSZone(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDNSZone.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreateDnsZones.json +func ExampleWorkloadNetworksClient_BeginCreateDNSZone() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreateDNSZone(ctx, + "", + "", + "", + armavs.WorkloadNetworkDNSZone{ + Properties: &armavs.WorkloadNetworkDNSZoneProperties{ + DisplayName: to.StringPtr(""), + DNSServerIPs: []*string{ + to.StringPtr("1.1.1.1")}, + Domain: []*string{}, + Revision: to.Int64Ptr(1), + SourceIP: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDNSZone.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_UpdateDnsZones.json +func ExampleWorkloadNetworksClient_BeginUpdateDNSZone() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginUpdateDNSZone(ctx, + "", + "", + "", + armavs.WorkloadNetworkDNSZone{ + Properties: &armavs.WorkloadNetworkDNSZoneProperties{ + DisplayName: to.StringPtr(""), + DNSServerIPs: []*string{ + to.StringPtr("1.1.1.1")}, + Domain: []*string{}, + Revision: to.Int64Ptr(1), + SourceIP: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkDNSZone.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeleteDnsZones.json +func ExampleWorkloadNetworksClient_BeginDeleteDNSZone() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeleteDNSZone(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_ListPublicIPs.json +func ExampleWorkloadNetworksClient_ListPublicIPs() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + pager := client.ListPublicIPs("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("WorkloadNetworkPublicIP.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_GetPublicIPs.json +func ExampleWorkloadNetworksClient_GetPublicIP() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + res, err := client.GetPublicIP(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkPublicIP.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_CreatePublicIPs.json +func ExampleWorkloadNetworksClient_BeginCreatePublicIP() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginCreatePublicIP(ctx, + "", + "", + "", + armavs.WorkloadNetworkPublicIP{ + Properties: &armavs.WorkloadNetworkPublicIPProperties{ + DisplayName: to.StringPtr(""), + NumberOfPublicIPs: to.Int64Ptr(32), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("WorkloadNetworkPublicIP.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/vmware/resource-manager/Microsoft.AVS/stable/2021-12-01/examples/WorkloadNetworks_DeletePublicIPs.json +func ExampleWorkloadNetworksClient_BeginDeletePublicIP() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armavs.NewWorkloadNetworksClient("", cred, nil) + poller, err := client.BeginDeletePublicIP(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_addons_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_addons_client.go new file mode 100644 index 000000000000..75bbfca55e6d --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_addons_client.go @@ -0,0 +1,334 @@ +//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 armavs + +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" +) + +// AddonsClient contains the methods for the Addons group. +// Don't use this type directly, use NewAddonsClient() instead. +type AddonsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAddonsClient creates a new instance of AddonsClient with the specified values. +func NewAddonsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AddonsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AddonsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a addon in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AddonsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, addon Addon, options *AddonsBeginCreateOrUpdateOptions) (AddonsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, addonName, addon, options) + if err != nil { + return AddonsCreateOrUpdatePollerResponse{}, err + } + result := AddonsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("AddonsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return AddonsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &AddonsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a addon in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AddonsClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, addon Addon, options *AddonsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, addonName, addon, 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 *AddonsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, addon Addon, options *AddonsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if addonName == "" { + return nil, errors.New("parameter addonName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{addonName}", url.PathEscape(addonName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, addon) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AddonsClient) 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 - Delete a addon in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AddonsClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, options *AddonsBeginDeleteOptions) (AddonsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, addonName, options) + if err != nil { + return AddonsDeletePollerResponse{}, err + } + result := AddonsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("AddonsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return AddonsDeletePollerResponse{}, err + } + result.Poller = &AddonsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a addon in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AddonsClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, options *AddonsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, addonName, 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 *AddonsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, options *AddonsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if addonName == "" { + return nil, errors.New("parameter addonName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{addonName}", url.PathEscape(addonName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AddonsClient) 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 - Get an addon by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AddonsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, options *AddonsGetOptions) (AddonsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, addonName, options) + if err != nil { + return AddonsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AddonsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AddonsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AddonsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, options *AddonsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if addonName == "" { + return nil, errors.New("parameter addonName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{addonName}", url.PathEscape(addonName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AddonsClient) getHandleResponse(resp *http.Response) (AddonsGetResponse, error) { + result := AddonsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Addon); err != nil { + return AddonsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AddonsClient) 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 - List addons in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AddonsClient) List(resourceGroupName string, privateCloudName string, options *AddonsListOptions) *AddonsListPager { + return &AddonsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp AddonsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AddonList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *AddonsClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *AddonsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AddonsClient) listHandleResponse(resp *http.Response) (AddonsListResponse, error) { + result := AddonsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AddonList); err != nil { + return AddonsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *AddonsClient) 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/avs/armavs/zz_generated_authorizations_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_authorizations_client.go new file mode 100644 index 000000000000..8c6416a1f5c6 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_authorizations_client.go @@ -0,0 +1,334 @@ +//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 armavs + +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" +) + +// AuthorizationsClient contains the methods for the Authorizations group. +// Don't use this type directly, use NewAuthorizationsClient() instead. +type AuthorizationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAuthorizationsClient creates a new instance of AuthorizationsClient with the specified values. +func NewAuthorizationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AuthorizationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AuthorizationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update an ExpressRoute Circuit Authorization in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AuthorizationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization ExpressRouteAuthorization, options *AuthorizationsBeginCreateOrUpdateOptions) (AuthorizationsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, authorizationName, authorization, options) + if err != nil { + return AuthorizationsCreateOrUpdatePollerResponse{}, err + } + result := AuthorizationsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("AuthorizationsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return AuthorizationsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &AuthorizationsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update an ExpressRoute Circuit Authorization in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AuthorizationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization ExpressRouteAuthorization, options *AuthorizationsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, authorizationName, authorization, 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 *AuthorizationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization ExpressRouteAuthorization, options *AuthorizationsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if authorizationName == "" { + return nil, errors.New("parameter authorizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationName}", url.PathEscape(authorizationName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, authorization) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AuthorizationsClient) 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 - Delete an ExpressRoute Circuit Authorization in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AuthorizationsClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, options *AuthorizationsBeginDeleteOptions) (AuthorizationsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, authorizationName, options) + if err != nil { + return AuthorizationsDeletePollerResponse{}, err + } + result := AuthorizationsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("AuthorizationsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return AuthorizationsDeletePollerResponse{}, err + } + result.Poller = &AuthorizationsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete an ExpressRoute Circuit Authorization in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AuthorizationsClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, options *AuthorizationsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, authorizationName, 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 *AuthorizationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, options *AuthorizationsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if authorizationName == "" { + return nil, errors.New("parameter authorizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationName}", url.PathEscape(authorizationName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AuthorizationsClient) 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 - Get an ExpressRoute Circuit Authorization by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AuthorizationsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, options *AuthorizationsGetOptions) (AuthorizationsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, authorizationName, options) + if err != nil { + return AuthorizationsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AuthorizationsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AuthorizationsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AuthorizationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, options *AuthorizationsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if authorizationName == "" { + return nil, errors.New("parameter authorizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationName}", url.PathEscape(authorizationName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AuthorizationsClient) getHandleResponse(resp *http.Response) (AuthorizationsGetResponse, error) { + result := AuthorizationsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteAuthorization); err != nil { + return AuthorizationsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AuthorizationsClient) 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 - List ExpressRoute Circuit Authorizations in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *AuthorizationsClient) List(resourceGroupName string, privateCloudName string, options *AuthorizationsListOptions) *AuthorizationsListPager { + return &AuthorizationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp AuthorizationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ExpressRouteAuthorizationList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *AuthorizationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *AuthorizationsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AuthorizationsClient) listHandleResponse(resp *http.Response) (AuthorizationsListResponse, error) { + result := AuthorizationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExpressRouteAuthorizationList); err != nil { + return AuthorizationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *AuthorizationsClient) 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/avs/armavs/zz_generated_cloudlinks_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_cloudlinks_client.go new file mode 100644 index 000000000000..ac8c02bdabf2 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_cloudlinks_client.go @@ -0,0 +1,334 @@ +//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 armavs + +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" +) + +// CloudLinksClient contains the methods for the CloudLinks group. +// Don't use this type directly, use NewCloudLinksClient() instead. +type CloudLinksClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewCloudLinksClient creates a new instance of CloudLinksClient with the specified values. +func NewCloudLinksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *CloudLinksClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CloudLinksClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a cloud link in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *CloudLinksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, cloudLink CloudLink, options *CloudLinksBeginCreateOrUpdateOptions) (CloudLinksCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, cloudLinkName, cloudLink, options) + if err != nil { + return CloudLinksCreateOrUpdatePollerResponse{}, err + } + result := CloudLinksCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CloudLinksClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return CloudLinksCreateOrUpdatePollerResponse{}, err + } + result.Poller = &CloudLinksCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a cloud link in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *CloudLinksClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, cloudLink CloudLink, options *CloudLinksBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, cloudLinkName, cloudLink, 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 *CloudLinksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, cloudLink CloudLink, options *CloudLinksBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if cloudLinkName == "" { + return nil, errors.New("parameter cloudLinkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudLinkName}", url.PathEscape(cloudLinkName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, cloudLink) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CloudLinksClient) 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 - Delete a cloud link in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *CloudLinksClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, options *CloudLinksBeginDeleteOptions) (CloudLinksDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, cloudLinkName, options) + if err != nil { + return CloudLinksDeletePollerResponse{}, err + } + result := CloudLinksDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CloudLinksClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return CloudLinksDeletePollerResponse{}, err + } + result.Poller = &CloudLinksDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a cloud link in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *CloudLinksClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, options *CloudLinksBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, cloudLinkName, 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 *CloudLinksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, options *CloudLinksBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if cloudLinkName == "" { + return nil, errors.New("parameter cloudLinkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudLinkName}", url.PathEscape(cloudLinkName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CloudLinksClient) 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 - Get an cloud link by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *CloudLinksClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, options *CloudLinksGetOptions) (CloudLinksGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, cloudLinkName, options) + if err != nil { + return CloudLinksGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CloudLinksGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CloudLinksGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CloudLinksClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, options *CloudLinksGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if cloudLinkName == "" { + return nil, errors.New("parameter cloudLinkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudLinkName}", url.PathEscape(cloudLinkName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CloudLinksClient) getHandleResponse(resp *http.Response) (CloudLinksGetResponse, error) { + result := CloudLinksGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CloudLink); err != nil { + return CloudLinksGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CloudLinksClient) 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 - List cloud link in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *CloudLinksClient) List(resourceGroupName string, privateCloudName string, options *CloudLinksListOptions) *CloudLinksListPager { + return &CloudLinksListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp CloudLinksListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CloudLinkList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *CloudLinksClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *CloudLinksListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CloudLinksClient) listHandleResponse(resp *http.Response) (CloudLinksListResponse, error) { + result := CloudLinksListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CloudLinkList); err != nil { + return CloudLinksListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *CloudLinksClient) 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/avs/armavs/zz_generated_clusters_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_clusters_client.go new file mode 100644 index 000000000000..46209a2976f9 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_clusters_client.go @@ -0,0 +1,414 @@ +//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 armavs + +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)} +} + +// BeginCreateOrUpdate - Create or update a cluster in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster, options *ClustersBeginCreateOrUpdateOptions) (ClustersCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, clusterName, cluster, 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 cluster in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster, options *ClustersBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, cluster, 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, privateCloudName string, clusterName string, cluster Cluster, options *ClustersBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, cluster) +} + +// 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 - Delete a cluster in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, options *ClustersBeginDeleteOptions) (ClustersDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, 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 - Delete a cluster in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, options *ClustersBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, 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, privateCloudName string, clusterName string, options *ClustersBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01") + 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) +} + +// Get - Get a cluster by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, options *ClustersGetOptions) (ClustersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, 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, privateCloudName string, clusterName string, options *ClustersGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + 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 - List clusters in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) List(resourceGroupName string, privateCloudName string, options *ClustersListOptions) *ClustersListPager { + return &ClustersListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp ClustersListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ClusterList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ClustersClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *ClustersListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + 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.ClusterList); 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) +} + +// BeginUpdate - Update a cluster in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) BeginUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate, options *ClustersBeginUpdateOptions) (ClustersUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, privateCloudName, clusterName, clusterUpdate, 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 cluster in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ClustersClient) update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate, options *ClustersBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, clusterUpdate, 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.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ClustersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate, options *ClustersBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, clusterUpdate) +} + +// 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/avs/armavs/zz_generated_constants.go b/sdk/resourcemanager/avs/armavs/zz_generated_constants.go new file mode 100644 index 000000000000..43d9649be879 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_constants.go @@ -0,0 +1,1147 @@ +//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 armavs + +const ( + module = "armavs" + version = "v0.1.0" +) + +// AddonProvisioningState - The state of the addon provisioning +type AddonProvisioningState string + +const ( + AddonProvisioningStateBuilding AddonProvisioningState = "Building" + AddonProvisioningStateCancelled AddonProvisioningState = "Cancelled" + AddonProvisioningStateDeleting AddonProvisioningState = "Deleting" + AddonProvisioningStateFailed AddonProvisioningState = "Failed" + AddonProvisioningStateSucceeded AddonProvisioningState = "Succeeded" + AddonProvisioningStateUpdating AddonProvisioningState = "Updating" +) + +// PossibleAddonProvisioningStateValues returns the possible values for the AddonProvisioningState const type. +func PossibleAddonProvisioningStateValues() []AddonProvisioningState { + return []AddonProvisioningState{ + AddonProvisioningStateBuilding, + AddonProvisioningStateCancelled, + AddonProvisioningStateDeleting, + AddonProvisioningStateFailed, + AddonProvisioningStateSucceeded, + AddonProvisioningStateUpdating, + } +} + +// ToPtr returns a *AddonProvisioningState pointing to the current value. +func (c AddonProvisioningState) ToPtr() *AddonProvisioningState { + return &c +} + +// AddonType - The type of private cloud addon +type AddonType string + +const ( + AddonTypeHCX AddonType = "HCX" + AddonTypeSRM AddonType = "SRM" + AddonTypeVR AddonType = "VR" +) + +// PossibleAddonTypeValues returns the possible values for the AddonType const type. +func PossibleAddonTypeValues() []AddonType { + return []AddonType{ + AddonTypeHCX, + AddonTypeSRM, + AddonTypeVR, + } +} + +// ToPtr returns a *AddonType pointing to the current value. +func (c AddonType) ToPtr() *AddonType { + return &c +} + +// AffinityType - Placement policy affinity type +type AffinityType string + +const ( + AffinityTypeAffinity AffinityType = "Affinity" + AffinityTypeAntiAffinity AffinityType = "AntiAffinity" +) + +// PossibleAffinityTypeValues returns the possible values for the AffinityType const type. +func PossibleAffinityTypeValues() []AffinityType { + return []AffinityType{ + AffinityTypeAffinity, + AffinityTypeAntiAffinity, + } +} + +// ToPtr returns a *AffinityType pointing to the current value. +func (c AffinityType) ToPtr() *AffinityType { + return &c +} + +// AvailabilityStrategy - The availability strategy for the private cloud +type AvailabilityStrategy string + +const ( + AvailabilityStrategyDualZone AvailabilityStrategy = "DualZone" + AvailabilityStrategySingleZone AvailabilityStrategy = "SingleZone" +) + +// PossibleAvailabilityStrategyValues returns the possible values for the AvailabilityStrategy const type. +func PossibleAvailabilityStrategyValues() []AvailabilityStrategy { + return []AvailabilityStrategy{ + AvailabilityStrategyDualZone, + AvailabilityStrategySingleZone, + } +} + +// ToPtr returns a *AvailabilityStrategy pointing to the current value. +func (c AvailabilityStrategy) ToPtr() *AvailabilityStrategy { + return &c +} + +// CloudLinkStatus - The state of the cloud link. +type CloudLinkStatus string + +const ( + CloudLinkStatusActive CloudLinkStatus = "Active" + CloudLinkStatusBuilding CloudLinkStatus = "Building" + CloudLinkStatusDeleting CloudLinkStatus = "Deleting" + CloudLinkStatusDisconnected CloudLinkStatus = "Disconnected" + CloudLinkStatusFailed CloudLinkStatus = "Failed" +) + +// PossibleCloudLinkStatusValues returns the possible values for the CloudLinkStatus const type. +func PossibleCloudLinkStatusValues() []CloudLinkStatus { + return []CloudLinkStatus{ + CloudLinkStatusActive, + CloudLinkStatusBuilding, + CloudLinkStatusDeleting, + CloudLinkStatusDisconnected, + CloudLinkStatusFailed, + } +} + +// ToPtr returns a *CloudLinkStatus pointing to the current value. +func (c CloudLinkStatus) ToPtr() *CloudLinkStatus { + return &c +} + +// ClusterProvisioningState - The state of the cluster provisioning +type ClusterProvisioningState string + +const ( + ClusterProvisioningStateCancelled ClusterProvisioningState = "Cancelled" + ClusterProvisioningStateDeleting ClusterProvisioningState = "Deleting" + ClusterProvisioningStateFailed ClusterProvisioningState = "Failed" + ClusterProvisioningStateSucceeded ClusterProvisioningState = "Succeeded" + ClusterProvisioningStateUpdating ClusterProvisioningState = "Updating" +) + +// PossibleClusterProvisioningStateValues returns the possible values for the ClusterProvisioningState const type. +func PossibleClusterProvisioningStateValues() []ClusterProvisioningState { + return []ClusterProvisioningState{ + ClusterProvisioningStateCancelled, + ClusterProvisioningStateDeleting, + ClusterProvisioningStateFailed, + ClusterProvisioningStateSucceeded, + ClusterProvisioningStateUpdating, + } +} + +// ToPtr returns a *ClusterProvisioningState pointing to the current value. +func (c ClusterProvisioningState) ToPtr() *ClusterProvisioningState { + return &c +} + +// DNSServiceLogLevelEnum - DNS Service log level. +type DNSServiceLogLevelEnum string + +const ( + DNSServiceLogLevelEnumDEBUG DNSServiceLogLevelEnum = "DEBUG" + DNSServiceLogLevelEnumERROR DNSServiceLogLevelEnum = "ERROR" + DNSServiceLogLevelEnumFATAL DNSServiceLogLevelEnum = "FATAL" + DNSServiceLogLevelEnumINFO DNSServiceLogLevelEnum = "INFO" + DNSServiceLogLevelEnumWARNING DNSServiceLogLevelEnum = "WARNING" +) + +// PossibleDNSServiceLogLevelEnumValues returns the possible values for the DNSServiceLogLevelEnum const type. +func PossibleDNSServiceLogLevelEnumValues() []DNSServiceLogLevelEnum { + return []DNSServiceLogLevelEnum{ + DNSServiceLogLevelEnumDEBUG, + DNSServiceLogLevelEnumERROR, + DNSServiceLogLevelEnumFATAL, + DNSServiceLogLevelEnumINFO, + DNSServiceLogLevelEnumWARNING, + } +} + +// ToPtr returns a *DNSServiceLogLevelEnum pointing to the current value. +func (c DNSServiceLogLevelEnum) ToPtr() *DNSServiceLogLevelEnum { + return &c +} + +// DNSServiceStatusEnum - DNS Service status. +type DNSServiceStatusEnum string + +const ( + DNSServiceStatusEnumFAILURE DNSServiceStatusEnum = "FAILURE" + DNSServiceStatusEnumSUCCESS DNSServiceStatusEnum = "SUCCESS" +) + +// PossibleDNSServiceStatusEnumValues returns the possible values for the DNSServiceStatusEnum const type. +func PossibleDNSServiceStatusEnumValues() []DNSServiceStatusEnum { + return []DNSServiceStatusEnum{ + DNSServiceStatusEnumFAILURE, + DNSServiceStatusEnumSUCCESS, + } +} + +// ToPtr returns a *DNSServiceStatusEnum pointing to the current value. +func (c DNSServiceStatusEnum) ToPtr() *DNSServiceStatusEnum { + return &c +} + +// DatastoreProvisioningState - The state of the datastore provisioning +type DatastoreProvisioningState string + +const ( + DatastoreProvisioningStateCancelled DatastoreProvisioningState = "Cancelled" + DatastoreProvisioningStateCreating DatastoreProvisioningState = "Creating" + DatastoreProvisioningStateDeleting DatastoreProvisioningState = "Deleting" + DatastoreProvisioningStateFailed DatastoreProvisioningState = "Failed" + DatastoreProvisioningStatePending DatastoreProvisioningState = "Pending" + DatastoreProvisioningStateSucceeded DatastoreProvisioningState = "Succeeded" + DatastoreProvisioningStateUpdating DatastoreProvisioningState = "Updating" +) + +// PossibleDatastoreProvisioningStateValues returns the possible values for the DatastoreProvisioningState const type. +func PossibleDatastoreProvisioningStateValues() []DatastoreProvisioningState { + return []DatastoreProvisioningState{ + DatastoreProvisioningStateCancelled, + DatastoreProvisioningStateCreating, + DatastoreProvisioningStateDeleting, + DatastoreProvisioningStateFailed, + DatastoreProvisioningStatePending, + DatastoreProvisioningStateSucceeded, + DatastoreProvisioningStateUpdating, + } +} + +// ToPtr returns a *DatastoreProvisioningState pointing to the current value. +func (c DatastoreProvisioningState) ToPtr() *DatastoreProvisioningState { + return &c +} + +// DatastoreStatus - The operational status of the datastore +type DatastoreStatus string + +const ( + DatastoreStatusAccessible DatastoreStatus = "Accessible" + DatastoreStatusAttached DatastoreStatus = "Attached" + DatastoreStatusDeadOrError DatastoreStatus = "DeadOrError" + DatastoreStatusDetached DatastoreStatus = "Detached" + DatastoreStatusInaccessible DatastoreStatus = "Inaccessible" + DatastoreStatusLostCommunication DatastoreStatus = "LostCommunication" + DatastoreStatusUnknown DatastoreStatus = "Unknown" +) + +// PossibleDatastoreStatusValues returns the possible values for the DatastoreStatus const type. +func PossibleDatastoreStatusValues() []DatastoreStatus { + return []DatastoreStatus{ + DatastoreStatusAccessible, + DatastoreStatusAttached, + DatastoreStatusDeadOrError, + DatastoreStatusDetached, + DatastoreStatusInaccessible, + DatastoreStatusLostCommunication, + DatastoreStatusUnknown, + } +} + +// ToPtr returns a *DatastoreStatus pointing to the current value. +func (c DatastoreStatus) ToPtr() *DatastoreStatus { + return &c +} + +// DhcpTypeEnum - Type of DHCP: SERVER or RELAY. +type DhcpTypeEnum string + +const ( + DhcpTypeEnumRELAY DhcpTypeEnum = "RELAY" + DhcpTypeEnumSERVER DhcpTypeEnum = "SERVER" +) + +// PossibleDhcpTypeEnumValues returns the possible values for the DhcpTypeEnum const type. +func PossibleDhcpTypeEnumValues() []DhcpTypeEnum { + return []DhcpTypeEnum{ + DhcpTypeEnumRELAY, + DhcpTypeEnumSERVER, + } +} + +// ToPtr returns a *DhcpTypeEnum pointing to the current value. +func (c DhcpTypeEnum) ToPtr() *DhcpTypeEnum { + return &c +} + +// EncryptionKeyStatus - The state of key provided +type EncryptionKeyStatus string + +const ( + EncryptionKeyStatusAccessDenied EncryptionKeyStatus = "AccessDenied" + EncryptionKeyStatusConnected EncryptionKeyStatus = "Connected" +) + +// PossibleEncryptionKeyStatusValues returns the possible values for the EncryptionKeyStatus const type. +func PossibleEncryptionKeyStatusValues() []EncryptionKeyStatus { + return []EncryptionKeyStatus{ + EncryptionKeyStatusAccessDenied, + EncryptionKeyStatusConnected, + } +} + +// ToPtr returns a *EncryptionKeyStatus pointing to the current value. +func (c EncryptionKeyStatus) ToPtr() *EncryptionKeyStatus { + return &c +} + +// EncryptionState - Status of customer managed encryption key +type EncryptionState string + +const ( + EncryptionStateDisabled EncryptionState = "Disabled" + EncryptionStateEnabled EncryptionState = "Enabled" +) + +// PossibleEncryptionStateValues returns the possible values for the EncryptionState const type. +func PossibleEncryptionStateValues() []EncryptionState { + return []EncryptionState{ + EncryptionStateDisabled, + EncryptionStateEnabled, + } +} + +// ToPtr returns a *EncryptionState pointing to the current value. +func (c EncryptionState) ToPtr() *EncryptionState { + return &c +} + +// EncryptionVersionType - Property of the key if user provided or auto detected +type EncryptionVersionType string + +const ( + EncryptionVersionTypeAutoDetected EncryptionVersionType = "AutoDetected" + EncryptionVersionTypeFixed EncryptionVersionType = "Fixed" +) + +// PossibleEncryptionVersionTypeValues returns the possible values for the EncryptionVersionType const type. +func PossibleEncryptionVersionTypeValues() []EncryptionVersionType { + return []EncryptionVersionType{ + EncryptionVersionTypeAutoDetected, + EncryptionVersionTypeFixed, + } +} + +// ToPtr returns a *EncryptionVersionType pointing to the current value. +func (c EncryptionVersionType) ToPtr() *EncryptionVersionType { + return &c +} + +// ExpressRouteAuthorizationProvisioningState - The state of the ExpressRoute Circuit Authorization provisioning +type ExpressRouteAuthorizationProvisioningState string + +const ( + ExpressRouteAuthorizationProvisioningStateFailed ExpressRouteAuthorizationProvisioningState = "Failed" + ExpressRouteAuthorizationProvisioningStateSucceeded ExpressRouteAuthorizationProvisioningState = "Succeeded" + ExpressRouteAuthorizationProvisioningStateUpdating ExpressRouteAuthorizationProvisioningState = "Updating" +) + +// PossibleExpressRouteAuthorizationProvisioningStateValues returns the possible values for the ExpressRouteAuthorizationProvisioningState const type. +func PossibleExpressRouteAuthorizationProvisioningStateValues() []ExpressRouteAuthorizationProvisioningState { + return []ExpressRouteAuthorizationProvisioningState{ + ExpressRouteAuthorizationProvisioningStateFailed, + ExpressRouteAuthorizationProvisioningStateSucceeded, + ExpressRouteAuthorizationProvisioningStateUpdating, + } +} + +// ToPtr returns a *ExpressRouteAuthorizationProvisioningState pointing to the current value. +func (c ExpressRouteAuthorizationProvisioningState) ToPtr() *ExpressRouteAuthorizationProvisioningState { + return &c +} + +// GlobalReachConnectionProvisioningState - The state of the ExpressRoute Circuit Authorization provisioning +type GlobalReachConnectionProvisioningState string + +const ( + GlobalReachConnectionProvisioningStateFailed GlobalReachConnectionProvisioningState = "Failed" + GlobalReachConnectionProvisioningStateSucceeded GlobalReachConnectionProvisioningState = "Succeeded" + GlobalReachConnectionProvisioningStateUpdating GlobalReachConnectionProvisioningState = "Updating" +) + +// PossibleGlobalReachConnectionProvisioningStateValues returns the possible values for the GlobalReachConnectionProvisioningState const type. +func PossibleGlobalReachConnectionProvisioningStateValues() []GlobalReachConnectionProvisioningState { + return []GlobalReachConnectionProvisioningState{ + GlobalReachConnectionProvisioningStateFailed, + GlobalReachConnectionProvisioningStateSucceeded, + GlobalReachConnectionProvisioningStateUpdating, + } +} + +// ToPtr returns a *GlobalReachConnectionProvisioningState pointing to the current value. +func (c GlobalReachConnectionProvisioningState) ToPtr() *GlobalReachConnectionProvisioningState { + return &c +} + +// GlobalReachConnectionStatus - The connection status of the global reach connection +type GlobalReachConnectionStatus string + +const ( + GlobalReachConnectionStatusConnected GlobalReachConnectionStatus = "Connected" + GlobalReachConnectionStatusConnecting GlobalReachConnectionStatus = "Connecting" + GlobalReachConnectionStatusDisconnected GlobalReachConnectionStatus = "Disconnected" +) + +// PossibleGlobalReachConnectionStatusValues returns the possible values for the GlobalReachConnectionStatus const type. +func PossibleGlobalReachConnectionStatusValues() []GlobalReachConnectionStatus { + return []GlobalReachConnectionStatus{ + GlobalReachConnectionStatusConnected, + GlobalReachConnectionStatusConnecting, + GlobalReachConnectionStatusDisconnected, + } +} + +// ToPtr returns a *GlobalReachConnectionStatus pointing to the current value. +func (c GlobalReachConnectionStatus) ToPtr() *GlobalReachConnectionStatus { + return &c +} + +// HcxEnterpriseSiteStatus - The status of the HCX Enterprise Site +type HcxEnterpriseSiteStatus string + +const ( + HcxEnterpriseSiteStatusAvailable HcxEnterpriseSiteStatus = "Available" + HcxEnterpriseSiteStatusConsumed HcxEnterpriseSiteStatus = "Consumed" + HcxEnterpriseSiteStatusDeactivated HcxEnterpriseSiteStatus = "Deactivated" + HcxEnterpriseSiteStatusDeleted HcxEnterpriseSiteStatus = "Deleted" +) + +// PossibleHcxEnterpriseSiteStatusValues returns the possible values for the HcxEnterpriseSiteStatus const type. +func PossibleHcxEnterpriseSiteStatusValues() []HcxEnterpriseSiteStatus { + return []HcxEnterpriseSiteStatus{ + HcxEnterpriseSiteStatusAvailable, + HcxEnterpriseSiteStatusConsumed, + HcxEnterpriseSiteStatusDeactivated, + HcxEnterpriseSiteStatusDeleted, + } +} + +// ToPtr returns a *HcxEnterpriseSiteStatus pointing to the current value. +func (c HcxEnterpriseSiteStatus) ToPtr() *HcxEnterpriseSiteStatus { + return &c +} + +// InternetEnum - Connectivity to internet is enabled or disabled +type InternetEnum string + +const ( + InternetEnumDisabled InternetEnum = "Disabled" + InternetEnumEnabled InternetEnum = "Enabled" +) + +// PossibleInternetEnumValues returns the possible values for the InternetEnum const type. +func PossibleInternetEnumValues() []InternetEnum { + return []InternetEnum{ + InternetEnumDisabled, + InternetEnumEnabled, + } +} + +// ToPtr returns a *InternetEnum pointing to the current value. +func (c InternetEnum) ToPtr() *InternetEnum { + return &c +} + +// MountOptionEnum - Mode that describes whether the LUN has to be mounted as a datastore or attached as a LUN +type MountOptionEnum string + +const ( + MountOptionEnumATTACH MountOptionEnum = "ATTACH" + MountOptionEnumMOUNT MountOptionEnum = "MOUNT" +) + +// PossibleMountOptionEnumValues returns the possible values for the MountOptionEnum const type. +func PossibleMountOptionEnumValues() []MountOptionEnum { + return []MountOptionEnum{ + MountOptionEnumATTACH, + MountOptionEnumMOUNT, + } +} + +// ToPtr returns a *MountOptionEnum pointing to the current value. +func (c MountOptionEnum) ToPtr() *MountOptionEnum { + return &c +} + +// OptionalParamEnum - Is this parameter required or optional +type OptionalParamEnum string + +const ( + OptionalParamEnumOptional OptionalParamEnum = "Optional" + OptionalParamEnumRequired OptionalParamEnum = "Required" +) + +// PossibleOptionalParamEnumValues returns the possible values for the OptionalParamEnum const type. +func PossibleOptionalParamEnumValues() []OptionalParamEnum { + return []OptionalParamEnum{ + OptionalParamEnumOptional, + OptionalParamEnumRequired, + } +} + +// ToPtr returns a *OptionalParamEnum pointing to the current value. +func (c OptionalParamEnum) ToPtr() *OptionalParamEnum { + return &c +} + +// PlacementPolicyProvisioningState - The provisioning state +type PlacementPolicyProvisioningState string + +const ( + PlacementPolicyProvisioningStateBuilding PlacementPolicyProvisioningState = "Building" + PlacementPolicyProvisioningStateDeleting PlacementPolicyProvisioningState = "Deleting" + PlacementPolicyProvisioningStateFailed PlacementPolicyProvisioningState = "Failed" + PlacementPolicyProvisioningStateSucceeded PlacementPolicyProvisioningState = "Succeeded" + PlacementPolicyProvisioningStateUpdating PlacementPolicyProvisioningState = "Updating" +) + +// PossiblePlacementPolicyProvisioningStateValues returns the possible values for the PlacementPolicyProvisioningState const type. +func PossiblePlacementPolicyProvisioningStateValues() []PlacementPolicyProvisioningState { + return []PlacementPolicyProvisioningState{ + PlacementPolicyProvisioningStateBuilding, + PlacementPolicyProvisioningStateDeleting, + PlacementPolicyProvisioningStateFailed, + PlacementPolicyProvisioningStateSucceeded, + PlacementPolicyProvisioningStateUpdating, + } +} + +// ToPtr returns a *PlacementPolicyProvisioningState pointing to the current value. +func (c PlacementPolicyProvisioningState) ToPtr() *PlacementPolicyProvisioningState { + return &c +} + +// PlacementPolicyState - Whether the placement policy is enabled or disabled +type PlacementPolicyState string + +const ( + PlacementPolicyStateDisabled PlacementPolicyState = "Disabled" + PlacementPolicyStateEnabled PlacementPolicyState = "Enabled" +) + +// PossiblePlacementPolicyStateValues returns the possible values for the PlacementPolicyState const type. +func PossiblePlacementPolicyStateValues() []PlacementPolicyState { + return []PlacementPolicyState{ + PlacementPolicyStateDisabled, + PlacementPolicyStateEnabled, + } +} + +// ToPtr returns a *PlacementPolicyState pointing to the current value. +func (c PlacementPolicyState) ToPtr() *PlacementPolicyState { + return &c +} + +// PlacementPolicyType - placement policy type +type PlacementPolicyType string + +const ( + PlacementPolicyTypeVMHost PlacementPolicyType = "VmHost" + PlacementPolicyTypeVMVM PlacementPolicyType = "VmVm" +) + +// PossiblePlacementPolicyTypeValues returns the possible values for the PlacementPolicyType const type. +func PossiblePlacementPolicyTypeValues() []PlacementPolicyType { + return []PlacementPolicyType{ + PlacementPolicyTypeVMHost, + PlacementPolicyTypeVMVM, + } +} + +// ToPtr returns a *PlacementPolicyType pointing to the current value. +func (c PlacementPolicyType) ToPtr() *PlacementPolicyType { + return &c +} + +// PortMirroringDirectionEnum - Direction of port mirroring profile. +type PortMirroringDirectionEnum string + +const ( + PortMirroringDirectionEnumBIDIRECTIONAL PortMirroringDirectionEnum = "BIDIRECTIONAL" + PortMirroringDirectionEnumEGRESS PortMirroringDirectionEnum = "EGRESS" + PortMirroringDirectionEnumINGRESS PortMirroringDirectionEnum = "INGRESS" +) + +// PossiblePortMirroringDirectionEnumValues returns the possible values for the PortMirroringDirectionEnum const type. +func PossiblePortMirroringDirectionEnumValues() []PortMirroringDirectionEnum { + return []PortMirroringDirectionEnum{ + PortMirroringDirectionEnumBIDIRECTIONAL, + PortMirroringDirectionEnumEGRESS, + PortMirroringDirectionEnumINGRESS, + } +} + +// ToPtr returns a *PortMirroringDirectionEnum pointing to the current value. +func (c PortMirroringDirectionEnum) ToPtr() *PortMirroringDirectionEnum { + return &c +} + +// PortMirroringStatusEnum - Port Mirroring Status. +type PortMirroringStatusEnum string + +const ( + PortMirroringStatusEnumFAILURE PortMirroringStatusEnum = "FAILURE" + PortMirroringStatusEnumSUCCESS PortMirroringStatusEnum = "SUCCESS" +) + +// PossiblePortMirroringStatusEnumValues returns the possible values for the PortMirroringStatusEnum const type. +func PossiblePortMirroringStatusEnumValues() []PortMirroringStatusEnum { + return []PortMirroringStatusEnum{ + PortMirroringStatusEnumFAILURE, + PortMirroringStatusEnumSUCCESS, + } +} + +// ToPtr returns a *PortMirroringStatusEnum pointing to the current value. +func (c PortMirroringStatusEnum) ToPtr() *PortMirroringStatusEnum { + return &c +} + +// PrivateCloudProvisioningState - The provisioning state +type PrivateCloudProvisioningState string + +const ( + PrivateCloudProvisioningStateBuilding PrivateCloudProvisioningState = "Building" + PrivateCloudProvisioningStateCancelled PrivateCloudProvisioningState = "Cancelled" + PrivateCloudProvisioningStateDeleting PrivateCloudProvisioningState = "Deleting" + PrivateCloudProvisioningStateFailed PrivateCloudProvisioningState = "Failed" + PrivateCloudProvisioningStatePending PrivateCloudProvisioningState = "Pending" + PrivateCloudProvisioningStateSucceeded PrivateCloudProvisioningState = "Succeeded" + PrivateCloudProvisioningStateUpdating PrivateCloudProvisioningState = "Updating" +) + +// PossiblePrivateCloudProvisioningStateValues returns the possible values for the PrivateCloudProvisioningState const type. +func PossiblePrivateCloudProvisioningStateValues() []PrivateCloudProvisioningState { + return []PrivateCloudProvisioningState{ + PrivateCloudProvisioningStateBuilding, + PrivateCloudProvisioningStateCancelled, + PrivateCloudProvisioningStateDeleting, + PrivateCloudProvisioningStateFailed, + PrivateCloudProvisioningStatePending, + PrivateCloudProvisioningStateSucceeded, + PrivateCloudProvisioningStateUpdating, + } +} + +// ToPtr returns a *PrivateCloudProvisioningState pointing to the current value. +func (c PrivateCloudProvisioningState) ToPtr() *PrivateCloudProvisioningState { + return &c +} + +// QuotaEnabled - Host quota is active for current subscription +type QuotaEnabled string + +const ( + QuotaEnabledDisabled QuotaEnabled = "Disabled" + QuotaEnabledEnabled QuotaEnabled = "Enabled" +) + +// PossibleQuotaEnabledValues returns the possible values for the QuotaEnabled const type. +func PossibleQuotaEnabledValues() []QuotaEnabled { + return []QuotaEnabled{ + QuotaEnabledDisabled, + QuotaEnabledEnabled, + } +} + +// ToPtr returns a *QuotaEnabled pointing to the current value. +func (c QuotaEnabled) ToPtr() *QuotaEnabled { + return &c +} + +// ResourceIdentityType - The type of identity used for the private cloud. The type 'SystemAssigned' refers to an implicitly created identity. The type +// 'None' will remove any identities from the Private Cloud. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeNone, + ResourceIdentityTypeSystemAssigned, + } +} + +// ToPtr returns a *ResourceIdentityType pointing to the current value. +func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { + return &c +} + +// SSLEnum - Protect LDAP communication using SSL certificate (LDAPS) +type SSLEnum string + +const ( + SSLEnumDisabled SSLEnum = "Disabled" + SSLEnumEnabled SSLEnum = "Enabled" +) + +// PossibleSSLEnumValues returns the possible values for the SSLEnum const type. +func PossibleSSLEnumValues() []SSLEnum { + return []SSLEnum{ + SSLEnumDisabled, + SSLEnumEnabled, + } +} + +// ToPtr returns a *SSLEnum pointing to the current value. +func (c SSLEnum) ToPtr() *SSLEnum { + return &c +} + +// ScriptExecutionParameterType - The type of execution parameter +type ScriptExecutionParameterType string + +const ( + ScriptExecutionParameterTypeCredential ScriptExecutionParameterType = "Credential" + ScriptExecutionParameterTypeSecureValue ScriptExecutionParameterType = "SecureValue" + ScriptExecutionParameterTypeValue ScriptExecutionParameterType = "Value" +) + +// PossibleScriptExecutionParameterTypeValues returns the possible values for the ScriptExecutionParameterType const type. +func PossibleScriptExecutionParameterTypeValues() []ScriptExecutionParameterType { + return []ScriptExecutionParameterType{ + ScriptExecutionParameterTypeCredential, + ScriptExecutionParameterTypeSecureValue, + ScriptExecutionParameterTypeValue, + } +} + +// ToPtr returns a *ScriptExecutionParameterType pointing to the current value. +func (c ScriptExecutionParameterType) ToPtr() *ScriptExecutionParameterType { + return &c +} + +// ScriptExecutionProvisioningState - The state of the script execution resource +type ScriptExecutionProvisioningState string + +const ( + ScriptExecutionProvisioningStateCancelled ScriptExecutionProvisioningState = "Cancelled" + ScriptExecutionProvisioningStateCancelling ScriptExecutionProvisioningState = "Cancelling" + ScriptExecutionProvisioningStateDeleting ScriptExecutionProvisioningState = "Deleting" + ScriptExecutionProvisioningStateFailed ScriptExecutionProvisioningState = "Failed" + ScriptExecutionProvisioningStatePending ScriptExecutionProvisioningState = "Pending" + ScriptExecutionProvisioningStateRunning ScriptExecutionProvisioningState = "Running" + ScriptExecutionProvisioningStateSucceeded ScriptExecutionProvisioningState = "Succeeded" +) + +// PossibleScriptExecutionProvisioningStateValues returns the possible values for the ScriptExecutionProvisioningState const type. +func PossibleScriptExecutionProvisioningStateValues() []ScriptExecutionProvisioningState { + return []ScriptExecutionProvisioningState{ + ScriptExecutionProvisioningStateCancelled, + ScriptExecutionProvisioningStateCancelling, + ScriptExecutionProvisioningStateDeleting, + ScriptExecutionProvisioningStateFailed, + ScriptExecutionProvisioningStatePending, + ScriptExecutionProvisioningStateRunning, + ScriptExecutionProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ScriptExecutionProvisioningState pointing to the current value. +func (c ScriptExecutionProvisioningState) ToPtr() *ScriptExecutionProvisioningState { + return &c +} + +type ScriptOutputStreamType string + +const ( + ScriptOutputStreamTypeError ScriptOutputStreamType = "Error" + ScriptOutputStreamTypeInformation ScriptOutputStreamType = "Information" + ScriptOutputStreamTypeOutput ScriptOutputStreamType = "Output" + ScriptOutputStreamTypeWarning ScriptOutputStreamType = "Warning" +) + +// PossibleScriptOutputStreamTypeValues returns the possible values for the ScriptOutputStreamType const type. +func PossibleScriptOutputStreamTypeValues() []ScriptOutputStreamType { + return []ScriptOutputStreamType{ + ScriptOutputStreamTypeError, + ScriptOutputStreamTypeInformation, + ScriptOutputStreamTypeOutput, + ScriptOutputStreamTypeWarning, + } +} + +// ToPtr returns a *ScriptOutputStreamType pointing to the current value. +func (c ScriptOutputStreamType) ToPtr() *ScriptOutputStreamType { + return &c +} + +// ScriptParameterTypes - The type of parameter the script is expecting. psCredential is a PSCredentialObject +type ScriptParameterTypes string + +const ( + ScriptParameterTypesBool ScriptParameterTypes = "Bool" + ScriptParameterTypesCredential ScriptParameterTypes = "Credential" + ScriptParameterTypesFloat ScriptParameterTypes = "Float" + ScriptParameterTypesInt ScriptParameterTypes = "Int" + ScriptParameterTypesSecureString ScriptParameterTypes = "SecureString" + ScriptParameterTypesString ScriptParameterTypes = "String" +) + +// PossibleScriptParameterTypesValues returns the possible values for the ScriptParameterTypes const type. +func PossibleScriptParameterTypesValues() []ScriptParameterTypes { + return []ScriptParameterTypes{ + ScriptParameterTypesBool, + ScriptParameterTypesCredential, + ScriptParameterTypesFloat, + ScriptParameterTypesInt, + ScriptParameterTypesSecureString, + ScriptParameterTypesString, + } +} + +// ToPtr returns a *ScriptParameterTypes pointing to the current value. +func (c ScriptParameterTypes) ToPtr() *ScriptParameterTypes { + return &c +} + +// SegmentStatusEnum - Segment status. +type SegmentStatusEnum string + +const ( + SegmentStatusEnumFAILURE SegmentStatusEnum = "FAILURE" + SegmentStatusEnumSUCCESS SegmentStatusEnum = "SUCCESS" +) + +// PossibleSegmentStatusEnumValues returns the possible values for the SegmentStatusEnum const type. +func PossibleSegmentStatusEnumValues() []SegmentStatusEnum { + return []SegmentStatusEnum{ + SegmentStatusEnumFAILURE, + SegmentStatusEnumSUCCESS, + } +} + +// ToPtr returns a *SegmentStatusEnum pointing to the current value. +func (c SegmentStatusEnum) ToPtr() *SegmentStatusEnum { + return &c +} + +// TrialStatus - Trial status +type TrialStatus string + +const ( + TrialStatusTrialAvailable TrialStatus = "TrialAvailable" + TrialStatusTrialDisabled TrialStatus = "TrialDisabled" + TrialStatusTrialUsed TrialStatus = "TrialUsed" +) + +// PossibleTrialStatusValues returns the possible values for the TrialStatus const type. +func PossibleTrialStatusValues() []TrialStatus { + return []TrialStatus{ + TrialStatusTrialAvailable, + TrialStatusTrialDisabled, + TrialStatusTrialUsed, + } +} + +// ToPtr returns a *TrialStatus pointing to the current value. +func (c TrialStatus) ToPtr() *TrialStatus { + return &c +} + +// VMGroupStatusEnum - VM Group status. +type VMGroupStatusEnum string + +const ( + VMGroupStatusEnumFAILURE VMGroupStatusEnum = "FAILURE" + VMGroupStatusEnumSUCCESS VMGroupStatusEnum = "SUCCESS" +) + +// PossibleVMGroupStatusEnumValues returns the possible values for the VMGroupStatusEnum const type. +func PossibleVMGroupStatusEnumValues() []VMGroupStatusEnum { + return []VMGroupStatusEnum{ + VMGroupStatusEnumFAILURE, + VMGroupStatusEnumSUCCESS, + } +} + +// ToPtr returns a *VMGroupStatusEnum pointing to the current value. +func (c VMGroupStatusEnum) ToPtr() *VMGroupStatusEnum { + return &c +} + +// VMTypeEnum - Virtual machine type. +type VMTypeEnum string + +const ( + VMTypeEnumEDGE VMTypeEnum = "EDGE" + VMTypeEnumREGULAR VMTypeEnum = "REGULAR" + VMTypeEnumSERVICE VMTypeEnum = "SERVICE" +) + +// PossibleVMTypeEnumValues returns the possible values for the VMTypeEnum const type. +func PossibleVMTypeEnumValues() []VMTypeEnum { + return []VMTypeEnum{ + VMTypeEnumEDGE, + VMTypeEnumREGULAR, + VMTypeEnumSERVICE, + } +} + +// ToPtr returns a *VMTypeEnum pointing to the current value. +func (c VMTypeEnum) ToPtr() *VMTypeEnum { + return &c +} + +// VirtualMachineRestrictMovementState - Whether VM DRS-driven movement is restricted (enabled) or not (disabled) +type VirtualMachineRestrictMovementState string + +const ( + VirtualMachineRestrictMovementStateDisabled VirtualMachineRestrictMovementState = "Disabled" + VirtualMachineRestrictMovementStateEnabled VirtualMachineRestrictMovementState = "Enabled" +) + +// PossibleVirtualMachineRestrictMovementStateValues returns the possible values for the VirtualMachineRestrictMovementState const type. +func PossibleVirtualMachineRestrictMovementStateValues() []VirtualMachineRestrictMovementState { + return []VirtualMachineRestrictMovementState{ + VirtualMachineRestrictMovementStateDisabled, + VirtualMachineRestrictMovementStateEnabled, + } +} + +// ToPtr returns a *VirtualMachineRestrictMovementState pointing to the current value. +func (c VirtualMachineRestrictMovementState) ToPtr() *VirtualMachineRestrictMovementState { + return &c +} + +// VisibilityParameterEnum - Should this parameter be visible to arm and passed in the parameters argument when executing +type VisibilityParameterEnum string + +const ( + VisibilityParameterEnumHidden VisibilityParameterEnum = "Hidden" + VisibilityParameterEnumVisible VisibilityParameterEnum = "Visible" +) + +// PossibleVisibilityParameterEnumValues returns the possible values for the VisibilityParameterEnum const type. +func PossibleVisibilityParameterEnumValues() []VisibilityParameterEnum { + return []VisibilityParameterEnum{ + VisibilityParameterEnumHidden, + VisibilityParameterEnumVisible, + } +} + +// ToPtr returns a *VisibilityParameterEnum pointing to the current value. +func (c VisibilityParameterEnum) ToPtr() *VisibilityParameterEnum { + return &c +} + +// WorkloadNetworkDNSServiceProvisioningState - The provisioning state +type WorkloadNetworkDNSServiceProvisioningState string + +const ( + WorkloadNetworkDNSServiceProvisioningStateBuilding WorkloadNetworkDNSServiceProvisioningState = "Building" + WorkloadNetworkDNSServiceProvisioningStateDeleting WorkloadNetworkDNSServiceProvisioningState = "Deleting" + WorkloadNetworkDNSServiceProvisioningStateFailed WorkloadNetworkDNSServiceProvisioningState = "Failed" + WorkloadNetworkDNSServiceProvisioningStateSucceeded WorkloadNetworkDNSServiceProvisioningState = "Succeeded" + WorkloadNetworkDNSServiceProvisioningStateUpdating WorkloadNetworkDNSServiceProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkDNSServiceProvisioningStateValues returns the possible values for the WorkloadNetworkDNSServiceProvisioningState const type. +func PossibleWorkloadNetworkDNSServiceProvisioningStateValues() []WorkloadNetworkDNSServiceProvisioningState { + return []WorkloadNetworkDNSServiceProvisioningState{ + WorkloadNetworkDNSServiceProvisioningStateBuilding, + WorkloadNetworkDNSServiceProvisioningStateDeleting, + WorkloadNetworkDNSServiceProvisioningStateFailed, + WorkloadNetworkDNSServiceProvisioningStateSucceeded, + WorkloadNetworkDNSServiceProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkDNSServiceProvisioningState pointing to the current value. +func (c WorkloadNetworkDNSServiceProvisioningState) ToPtr() *WorkloadNetworkDNSServiceProvisioningState { + return &c +} + +// WorkloadNetworkDNSZoneProvisioningState - The provisioning state +type WorkloadNetworkDNSZoneProvisioningState string + +const ( + WorkloadNetworkDNSZoneProvisioningStateBuilding WorkloadNetworkDNSZoneProvisioningState = "Building" + WorkloadNetworkDNSZoneProvisioningStateDeleting WorkloadNetworkDNSZoneProvisioningState = "Deleting" + WorkloadNetworkDNSZoneProvisioningStateFailed WorkloadNetworkDNSZoneProvisioningState = "Failed" + WorkloadNetworkDNSZoneProvisioningStateSucceeded WorkloadNetworkDNSZoneProvisioningState = "Succeeded" + WorkloadNetworkDNSZoneProvisioningStateUpdating WorkloadNetworkDNSZoneProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkDNSZoneProvisioningStateValues returns the possible values for the WorkloadNetworkDNSZoneProvisioningState const type. +func PossibleWorkloadNetworkDNSZoneProvisioningStateValues() []WorkloadNetworkDNSZoneProvisioningState { + return []WorkloadNetworkDNSZoneProvisioningState{ + WorkloadNetworkDNSZoneProvisioningStateBuilding, + WorkloadNetworkDNSZoneProvisioningStateDeleting, + WorkloadNetworkDNSZoneProvisioningStateFailed, + WorkloadNetworkDNSZoneProvisioningStateSucceeded, + WorkloadNetworkDNSZoneProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkDNSZoneProvisioningState pointing to the current value. +func (c WorkloadNetworkDNSZoneProvisioningState) ToPtr() *WorkloadNetworkDNSZoneProvisioningState { + return &c +} + +// WorkloadNetworkDhcpProvisioningState - The provisioning state +type WorkloadNetworkDhcpProvisioningState string + +const ( + WorkloadNetworkDhcpProvisioningStateBuilding WorkloadNetworkDhcpProvisioningState = "Building" + WorkloadNetworkDhcpProvisioningStateDeleting WorkloadNetworkDhcpProvisioningState = "Deleting" + WorkloadNetworkDhcpProvisioningStateFailed WorkloadNetworkDhcpProvisioningState = "Failed" + WorkloadNetworkDhcpProvisioningStateSucceeded WorkloadNetworkDhcpProvisioningState = "Succeeded" + WorkloadNetworkDhcpProvisioningStateUpdating WorkloadNetworkDhcpProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkDhcpProvisioningStateValues returns the possible values for the WorkloadNetworkDhcpProvisioningState const type. +func PossibleWorkloadNetworkDhcpProvisioningStateValues() []WorkloadNetworkDhcpProvisioningState { + return []WorkloadNetworkDhcpProvisioningState{ + WorkloadNetworkDhcpProvisioningStateBuilding, + WorkloadNetworkDhcpProvisioningStateDeleting, + WorkloadNetworkDhcpProvisioningStateFailed, + WorkloadNetworkDhcpProvisioningStateSucceeded, + WorkloadNetworkDhcpProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkDhcpProvisioningState pointing to the current value. +func (c WorkloadNetworkDhcpProvisioningState) ToPtr() *WorkloadNetworkDhcpProvisioningState { + return &c +} + +// WorkloadNetworkPortMirroringProvisioningState - The provisioning state +type WorkloadNetworkPortMirroringProvisioningState string + +const ( + WorkloadNetworkPortMirroringProvisioningStateBuilding WorkloadNetworkPortMirroringProvisioningState = "Building" + WorkloadNetworkPortMirroringProvisioningStateDeleting WorkloadNetworkPortMirroringProvisioningState = "Deleting" + WorkloadNetworkPortMirroringProvisioningStateFailed WorkloadNetworkPortMirroringProvisioningState = "Failed" + WorkloadNetworkPortMirroringProvisioningStateSucceeded WorkloadNetworkPortMirroringProvisioningState = "Succeeded" + WorkloadNetworkPortMirroringProvisioningStateUpdating WorkloadNetworkPortMirroringProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkPortMirroringProvisioningStateValues returns the possible values for the WorkloadNetworkPortMirroringProvisioningState const type. +func PossibleWorkloadNetworkPortMirroringProvisioningStateValues() []WorkloadNetworkPortMirroringProvisioningState { + return []WorkloadNetworkPortMirroringProvisioningState{ + WorkloadNetworkPortMirroringProvisioningStateBuilding, + WorkloadNetworkPortMirroringProvisioningStateDeleting, + WorkloadNetworkPortMirroringProvisioningStateFailed, + WorkloadNetworkPortMirroringProvisioningStateSucceeded, + WorkloadNetworkPortMirroringProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkPortMirroringProvisioningState pointing to the current value. +func (c WorkloadNetworkPortMirroringProvisioningState) ToPtr() *WorkloadNetworkPortMirroringProvisioningState { + return &c +} + +// WorkloadNetworkPublicIPProvisioningState - The provisioning state +type WorkloadNetworkPublicIPProvisioningState string + +const ( + WorkloadNetworkPublicIPProvisioningStateBuilding WorkloadNetworkPublicIPProvisioningState = "Building" + WorkloadNetworkPublicIPProvisioningStateDeleting WorkloadNetworkPublicIPProvisioningState = "Deleting" + WorkloadNetworkPublicIPProvisioningStateFailed WorkloadNetworkPublicIPProvisioningState = "Failed" + WorkloadNetworkPublicIPProvisioningStateSucceeded WorkloadNetworkPublicIPProvisioningState = "Succeeded" + WorkloadNetworkPublicIPProvisioningStateUpdating WorkloadNetworkPublicIPProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkPublicIPProvisioningStateValues returns the possible values for the WorkloadNetworkPublicIPProvisioningState const type. +func PossibleWorkloadNetworkPublicIPProvisioningStateValues() []WorkloadNetworkPublicIPProvisioningState { + return []WorkloadNetworkPublicIPProvisioningState{ + WorkloadNetworkPublicIPProvisioningStateBuilding, + WorkloadNetworkPublicIPProvisioningStateDeleting, + WorkloadNetworkPublicIPProvisioningStateFailed, + WorkloadNetworkPublicIPProvisioningStateSucceeded, + WorkloadNetworkPublicIPProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkPublicIPProvisioningState pointing to the current value. +func (c WorkloadNetworkPublicIPProvisioningState) ToPtr() *WorkloadNetworkPublicIPProvisioningState { + return &c +} + +// WorkloadNetworkSegmentProvisioningState - The provisioning state +type WorkloadNetworkSegmentProvisioningState string + +const ( + WorkloadNetworkSegmentProvisioningStateBuilding WorkloadNetworkSegmentProvisioningState = "Building" + WorkloadNetworkSegmentProvisioningStateDeleting WorkloadNetworkSegmentProvisioningState = "Deleting" + WorkloadNetworkSegmentProvisioningStateFailed WorkloadNetworkSegmentProvisioningState = "Failed" + WorkloadNetworkSegmentProvisioningStateSucceeded WorkloadNetworkSegmentProvisioningState = "Succeeded" + WorkloadNetworkSegmentProvisioningStateUpdating WorkloadNetworkSegmentProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkSegmentProvisioningStateValues returns the possible values for the WorkloadNetworkSegmentProvisioningState const type. +func PossibleWorkloadNetworkSegmentProvisioningStateValues() []WorkloadNetworkSegmentProvisioningState { + return []WorkloadNetworkSegmentProvisioningState{ + WorkloadNetworkSegmentProvisioningStateBuilding, + WorkloadNetworkSegmentProvisioningStateDeleting, + WorkloadNetworkSegmentProvisioningStateFailed, + WorkloadNetworkSegmentProvisioningStateSucceeded, + WorkloadNetworkSegmentProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkSegmentProvisioningState pointing to the current value. +func (c WorkloadNetworkSegmentProvisioningState) ToPtr() *WorkloadNetworkSegmentProvisioningState { + return &c +} + +// WorkloadNetworkVMGroupProvisioningState - The provisioning state +type WorkloadNetworkVMGroupProvisioningState string + +const ( + WorkloadNetworkVMGroupProvisioningStateBuilding WorkloadNetworkVMGroupProvisioningState = "Building" + WorkloadNetworkVMGroupProvisioningStateDeleting WorkloadNetworkVMGroupProvisioningState = "Deleting" + WorkloadNetworkVMGroupProvisioningStateFailed WorkloadNetworkVMGroupProvisioningState = "Failed" + WorkloadNetworkVMGroupProvisioningStateSucceeded WorkloadNetworkVMGroupProvisioningState = "Succeeded" + WorkloadNetworkVMGroupProvisioningStateUpdating WorkloadNetworkVMGroupProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkVMGroupProvisioningStateValues returns the possible values for the WorkloadNetworkVMGroupProvisioningState const type. +func PossibleWorkloadNetworkVMGroupProvisioningStateValues() []WorkloadNetworkVMGroupProvisioningState { + return []WorkloadNetworkVMGroupProvisioningState{ + WorkloadNetworkVMGroupProvisioningStateBuilding, + WorkloadNetworkVMGroupProvisioningStateDeleting, + WorkloadNetworkVMGroupProvisioningStateFailed, + WorkloadNetworkVMGroupProvisioningStateSucceeded, + WorkloadNetworkVMGroupProvisioningStateUpdating, + } +} + +// ToPtr returns a *WorkloadNetworkVMGroupProvisioningState pointing to the current value. +func (c WorkloadNetworkVMGroupProvisioningState) ToPtr() *WorkloadNetworkVMGroupProvisioningState { + return &c +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_datastores_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_datastores_client.go new file mode 100644 index 000000000000..f4520e83113e --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_datastores_client.go @@ -0,0 +1,350 @@ +//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 armavs + +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" +) + +// DatastoresClient contains the methods for the Datastores group. +// Don't use this type directly, use NewDatastoresClient() instead. +type DatastoresClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDatastoresClient creates a new instance of DatastoresClient with the specified values. +func NewDatastoresClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DatastoresClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DatastoresClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a datastore in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *DatastoresClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, datastore Datastore, options *DatastoresBeginCreateOrUpdateOptions) (DatastoresCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName, datastore, options) + if err != nil { + return DatastoresCreateOrUpdatePollerResponse{}, err + } + result := DatastoresCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatastoresClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return DatastoresCreateOrUpdatePollerResponse{}, err + } + result.Poller = &DatastoresCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a datastore in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *DatastoresClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, datastore Datastore, options *DatastoresBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName, datastore, 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 *DatastoresClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, datastore Datastore, options *DatastoresBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if datastoreName == "" { + return nil, errors.New("parameter datastoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, datastore) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DatastoresClient) 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 - Delete a datastore in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *DatastoresClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, options *DatastoresBeginDeleteOptions) (DatastoresDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName, options) + if err != nil { + return DatastoresDeletePollerResponse{}, err + } + result := DatastoresDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DatastoresClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return DatastoresDeletePollerResponse{}, err + } + result.Poller = &DatastoresDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a datastore in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *DatastoresClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, options *DatastoresBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName, 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 *DatastoresClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, options *DatastoresBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if datastoreName == "" { + return nil, errors.New("parameter datastoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DatastoresClient) 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 - Get a datastore in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *DatastoresClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, options *DatastoresGetOptions) (DatastoresGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName, options) + if err != nil { + return DatastoresGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DatastoresGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DatastoresGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DatastoresClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, options *DatastoresGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if datastoreName == "" { + return nil, errors.New("parameter datastoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DatastoresClient) getHandleResponse(resp *http.Response) (DatastoresGetResponse, error) { + result := DatastoresGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Datastore); err != nil { + return DatastoresGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DatastoresClient) 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 - List datastores in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *DatastoresClient) List(resourceGroupName string, privateCloudName string, clusterName string, options *DatastoresListOptions) *DatastoresListPager { + return &DatastoresListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, options) + }, + advancer: func(ctx context.Context, resp DatastoresListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.DatastoreList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *DatastoresClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, options *DatastoresListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DatastoresClient) listHandleResponse(resp *http.Response) (DatastoresListResponse, error) { + result := DatastoresListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DatastoreList); err != nil { + return DatastoresListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DatastoresClient) 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/avs/armavs/zz_generated_globalreachconnections_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_globalreachconnections_client.go new file mode 100644 index 000000000000..fb967f4716ca --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_globalreachconnections_client.go @@ -0,0 +1,334 @@ +//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 armavs + +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" +) + +// GlobalReachConnectionsClient contains the methods for the GlobalReachConnections group. +// Don't use this type directly, use NewGlobalReachConnectionsClient() instead. +type GlobalReachConnectionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewGlobalReachConnectionsClient creates a new instance of GlobalReachConnectionsClient with the specified values. +func NewGlobalReachConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GlobalReachConnectionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GlobalReachConnectionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a global reach connection in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *GlobalReachConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, globalReachConnection GlobalReachConnection, options *GlobalReachConnectionsBeginCreateOrUpdateOptions) (GlobalReachConnectionsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, globalReachConnectionName, globalReachConnection, options) + if err != nil { + return GlobalReachConnectionsCreateOrUpdatePollerResponse{}, err + } + result := GlobalReachConnectionsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("GlobalReachConnectionsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return GlobalReachConnectionsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &GlobalReachConnectionsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a global reach connection in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *GlobalReachConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, globalReachConnection GlobalReachConnection, options *GlobalReachConnectionsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, globalReachConnectionName, globalReachConnection, 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 *GlobalReachConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, globalReachConnection GlobalReachConnection, options *GlobalReachConnectionsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if globalReachConnectionName == "" { + return nil, errors.New("parameter globalReachConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{globalReachConnectionName}", url.PathEscape(globalReachConnectionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, globalReachConnection) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GlobalReachConnectionsClient) 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 - Delete a global reach connection in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *GlobalReachConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, options *GlobalReachConnectionsBeginDeleteOptions) (GlobalReachConnectionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, globalReachConnectionName, options) + if err != nil { + return GlobalReachConnectionsDeletePollerResponse{}, err + } + result := GlobalReachConnectionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("GlobalReachConnectionsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return GlobalReachConnectionsDeletePollerResponse{}, err + } + result.Poller = &GlobalReachConnectionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a global reach connection in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *GlobalReachConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, options *GlobalReachConnectionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, globalReachConnectionName, 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 *GlobalReachConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, options *GlobalReachConnectionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if globalReachConnectionName == "" { + return nil, errors.New("parameter globalReachConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{globalReachConnectionName}", url.PathEscape(globalReachConnectionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GlobalReachConnectionsClient) 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 - Get a global reach connection by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *GlobalReachConnectionsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, options *GlobalReachConnectionsGetOptions) (GlobalReachConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, globalReachConnectionName, options) + if err != nil { + return GlobalReachConnectionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GlobalReachConnectionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GlobalReachConnectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GlobalReachConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, options *GlobalReachConnectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if globalReachConnectionName == "" { + return nil, errors.New("parameter globalReachConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{globalReachConnectionName}", url.PathEscape(globalReachConnectionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GlobalReachConnectionsClient) getHandleResponse(resp *http.Response) (GlobalReachConnectionsGetResponse, error) { + result := GlobalReachConnectionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GlobalReachConnection); err != nil { + return GlobalReachConnectionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GlobalReachConnectionsClient) 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 - List global reach connections in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *GlobalReachConnectionsClient) List(resourceGroupName string, privateCloudName string, options *GlobalReachConnectionsListOptions) *GlobalReachConnectionsListPager { + return &GlobalReachConnectionsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp GlobalReachConnectionsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.GlobalReachConnectionList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *GlobalReachConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *GlobalReachConnectionsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GlobalReachConnectionsClient) listHandleResponse(resp *http.Response) (GlobalReachConnectionsListResponse, error) { + result := GlobalReachConnectionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GlobalReachConnectionList); err != nil { + return GlobalReachConnectionsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *GlobalReachConnectionsClient) 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/avs/armavs/zz_generated_hcxenterprisesites_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_hcxenterprisesites_client.go new file mode 100644 index 000000000000..d926de4fc0d1 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_hcxenterprisesites_client.go @@ -0,0 +1,303 @@ +//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 armavs + +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" +) + +// HcxEnterpriseSitesClient contains the methods for the HcxEnterpriseSites group. +// Don't use this type directly, use NewHcxEnterpriseSitesClient() instead. +type HcxEnterpriseSitesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewHcxEnterpriseSitesClient creates a new instance of HcxEnterpriseSitesClient with the specified values. +func NewHcxEnterpriseSitesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *HcxEnterpriseSitesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &HcxEnterpriseSitesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update an HCX Enterprise Site in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *HcxEnterpriseSitesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite HcxEnterpriseSite, options *HcxEnterpriseSitesCreateOrUpdateOptions) (HcxEnterpriseSitesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, hcxEnterpriseSite, options) + if err != nil { + return HcxEnterpriseSitesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HcxEnterpriseSitesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return HcxEnterpriseSitesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *HcxEnterpriseSitesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite HcxEnterpriseSite, options *HcxEnterpriseSitesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if hcxEnterpriseSiteName == "" { + return nil, errors.New("parameter hcxEnterpriseSiteName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcxEnterpriseSiteName}", url.PathEscape(hcxEnterpriseSiteName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, hcxEnterpriseSite) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *HcxEnterpriseSitesClient) createOrUpdateHandleResponse(resp *http.Response) (HcxEnterpriseSitesCreateOrUpdateResponse, error) { + result := HcxEnterpriseSitesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HcxEnterpriseSite); err != nil { + return HcxEnterpriseSitesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *HcxEnterpriseSitesClient) 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) +} + +// Delete - Delete an HCX Enterprise Site in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *HcxEnterpriseSitesClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, options *HcxEnterpriseSitesDeleteOptions) (HcxEnterpriseSitesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, options) + if err != nil { + return HcxEnterpriseSitesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HcxEnterpriseSitesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return HcxEnterpriseSitesDeleteResponse{}, client.deleteHandleError(resp) + } + return HcxEnterpriseSitesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *HcxEnterpriseSitesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, options *HcxEnterpriseSitesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if hcxEnterpriseSiteName == "" { + return nil, errors.New("parameter hcxEnterpriseSiteName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcxEnterpriseSiteName}", url.PathEscape(hcxEnterpriseSiteName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *HcxEnterpriseSitesClient) 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 - Get an HCX Enterprise Site by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *HcxEnterpriseSitesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, options *HcxEnterpriseSitesGetOptions) (HcxEnterpriseSitesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, options) + if err != nil { + return HcxEnterpriseSitesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HcxEnterpriseSitesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HcxEnterpriseSitesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *HcxEnterpriseSitesClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, options *HcxEnterpriseSitesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if hcxEnterpriseSiteName == "" { + return nil, errors.New("parameter hcxEnterpriseSiteName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcxEnterpriseSiteName}", url.PathEscape(hcxEnterpriseSiteName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *HcxEnterpriseSitesClient) getHandleResponse(resp *http.Response) (HcxEnterpriseSitesGetResponse, error) { + result := HcxEnterpriseSitesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HcxEnterpriseSite); err != nil { + return HcxEnterpriseSitesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *HcxEnterpriseSitesClient) 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 - List HCX Enterprise Sites in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *HcxEnterpriseSitesClient) List(resourceGroupName string, privateCloudName string, options *HcxEnterpriseSitesListOptions) *HcxEnterpriseSitesListPager { + return &HcxEnterpriseSitesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp HcxEnterpriseSitesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.HcxEnterpriseSiteList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *HcxEnterpriseSitesClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *HcxEnterpriseSitesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *HcxEnterpriseSitesClient) listHandleResponse(resp *http.Response) (HcxEnterpriseSitesListResponse, error) { + result := HcxEnterpriseSitesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HcxEnterpriseSiteList); err != nil { + return HcxEnterpriseSitesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *HcxEnterpriseSitesClient) 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/avs/armavs/zz_generated_locations_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_locations_client.go new file mode 100644 index 000000000000..d34bc13c4c8a --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_locations_client.go @@ -0,0 +1,165 @@ +//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 armavs + +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" +) + +// LocationsClient contains the methods for the Locations group. +// Don't use this type directly, use NewLocationsClient() instead. +type LocationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLocationsClient creates a new instance of LocationsClient with the specified values. +func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LocationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LocationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckQuotaAvailability - Return quota for subscription by region +// If the operation fails it returns the *CloudError error type. +func (client *LocationsClient) CheckQuotaAvailability(ctx context.Context, location string, options *LocationsCheckQuotaAvailabilityOptions) (LocationsCheckQuotaAvailabilityResponse, error) { + req, err := client.checkQuotaAvailabilityCreateRequest(ctx, location, options) + if err != nil { + return LocationsCheckQuotaAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LocationsCheckQuotaAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LocationsCheckQuotaAvailabilityResponse{}, client.checkQuotaAvailabilityHandleError(resp) + } + return client.checkQuotaAvailabilityHandleResponse(resp) +} + +// checkQuotaAvailabilityCreateRequest creates the CheckQuotaAvailability request. +func (client *LocationsClient) checkQuotaAvailabilityCreateRequest(ctx context.Context, location string, options *LocationsCheckQuotaAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability" + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// checkQuotaAvailabilityHandleResponse handles the CheckQuotaAvailability response. +func (client *LocationsClient) checkQuotaAvailabilityHandleResponse(resp *http.Response) (LocationsCheckQuotaAvailabilityResponse, error) { + result := LocationsCheckQuotaAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Quota); err != nil { + return LocationsCheckQuotaAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkQuotaAvailabilityHandleError handles the CheckQuotaAvailability error response. +func (client *LocationsClient) checkQuotaAvailabilityHandleError(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) +} + +// CheckTrialAvailability - Return trial status for subscription by region +// If the operation fails it returns the *CloudError error type. +func (client *LocationsClient) CheckTrialAvailability(ctx context.Context, location string, options *LocationsCheckTrialAvailabilityOptions) (LocationsCheckTrialAvailabilityResponse, error) { + req, err := client.checkTrialAvailabilityCreateRequest(ctx, location, options) + if err != nil { + return LocationsCheckTrialAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LocationsCheckTrialAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LocationsCheckTrialAvailabilityResponse{}, client.checkTrialAvailabilityHandleError(resp) + } + return client.checkTrialAvailabilityHandleResponse(resp) +} + +// checkTrialAvailabilityCreateRequest creates the CheckTrialAvailability request. +func (client *LocationsClient) checkTrialAvailabilityCreateRequest(ctx context.Context, location string, options *LocationsCheckTrialAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability" + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// checkTrialAvailabilityHandleResponse handles the CheckTrialAvailability response. +func (client *LocationsClient) checkTrialAvailabilityHandleResponse(resp *http.Response) (LocationsCheckTrialAvailabilityResponse, error) { + result := LocationsCheckTrialAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Trial); err != nil { + return LocationsCheckTrialAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkTrialAvailabilityHandleError handles the CheckTrialAvailability error response. +func (client *LocationsClient) checkTrialAvailabilityHandleError(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/avs/armavs/zz_generated_models.go b/sdk/resourcemanager/avs/armavs/zz_generated_models.go new file mode 100644 index 000000000000..63cf18f21113 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_models.go @@ -0,0 +1,3648 @@ +//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 armavs + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// Addon - An addon resource +type Addon struct { + Resource + // The properties of an addon resource + Properties AddonPropertiesClassification `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Addon. +func (a Addon) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Addon. +func (a *Addon) 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": + a.Properties, err = unmarshalAddonPropertiesClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := a.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// AddonHcxProperties - The properties of an HCX addon +type AddonHcxProperties struct { + AddonProperties + // REQUIRED; The HCX offer, example VMware MaaS Cloud Provider (Enterprise) + Offer *string `json:"offer,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AddonHcxProperties. +func (a AddonHcxProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.AddonProperties.marshalInternal(objectMap, AddonTypeHCX) + populate(objectMap, "offer", a.Offer) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddonHcxProperties. +func (a *AddonHcxProperties) 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 "offer": + err = unpopulate(val, &a.Offer) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := a.AddonProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// AddonList - A paged list of addons +type AddonList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*Addon `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AddonList. +func (a AddonList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AddonPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetAddonProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AddonHcxProperties, *AddonProperties, *AddonSrmProperties, *AddonVrProperties +type AddonPropertiesClassification interface { + // GetAddonProperties returns the AddonProperties content of the underlying type. + GetAddonProperties() *AddonProperties +} + +// AddonProperties - The properties of an addon +type AddonProperties struct { + // REQUIRED; The type of private cloud addon + AddonType *AddonType `json:"addonType,omitempty"` + + // READ-ONLY; The state of the addon provisioning + ProvisioningState *AddonProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GetAddonProperties implements the AddonPropertiesClassification interface for type AddonProperties. +func (a *AddonProperties) GetAddonProperties() *AddonProperties { return a } + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddonProperties. +func (a *AddonProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return a.unmarshalInternal(rawMsg) +} + +func (a AddonProperties) marshalInternal(objectMap map[string]interface{}, discValue AddonType) { + a.AddonType = &discValue + objectMap["addonType"] = a.AddonType + populate(objectMap, "provisioningState", a.ProvisioningState) +} + +func (a *AddonProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "addonType": + err = unpopulate(val, &a.AddonType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &a.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AddonSrmProperties - The properties of a Site Recovery Manager (SRM) addon +type AddonSrmProperties struct { + AddonProperties + // The Site Recovery Manager (SRM) license + LicenseKey *string `json:"licenseKey,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AddonSrmProperties. +func (a AddonSrmProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.AddonProperties.marshalInternal(objectMap, AddonTypeSRM) + populate(objectMap, "licenseKey", a.LicenseKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddonSrmProperties. +func (a *AddonSrmProperties) 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 "licenseKey": + err = unpopulate(val, &a.LicenseKey) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := a.AddonProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// AddonVrProperties - The properties of a vSphere Replication (VR) addon +type AddonVrProperties struct { + AddonProperties + // REQUIRED; The vSphere Replication Server (VRS) count + VrsCount *int32 `json:"vrsCount,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AddonVrProperties. +func (a AddonVrProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.AddonProperties.marshalInternal(objectMap, AddonTypeVR) + populate(objectMap, "vrsCount", a.VrsCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddonVrProperties. +func (a *AddonVrProperties) 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 "vrsCount": + err = unpopulate(val, &a.VrsCount) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := a.AddonProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// AddonsBeginCreateOrUpdateOptions contains the optional parameters for the Addons.BeginCreateOrUpdate method. +type AddonsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AddonsBeginDeleteOptions contains the optional parameters for the Addons.BeginDelete method. +type AddonsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// AddonsGetOptions contains the optional parameters for the Addons.Get method. +type AddonsGetOptions struct { + // placeholder for future optional parameters +} + +// AddonsListOptions contains the optional parameters for the Addons.List method. +type AddonsListOptions struct { + // placeholder for future optional parameters +} + +// AdminCredentials - Administrative credentials for accessing vCenter and NSX-T +type AdminCredentials struct { + // READ-ONLY; NSX-T Manager password + NsxtPassword *string `json:"nsxtPassword,omitempty" azure:"ro"` + + // READ-ONLY; NSX-T Manager username + NsxtUsername *string `json:"nsxtUsername,omitempty" azure:"ro"` + + // READ-ONLY; vCenter admin password + VcenterPassword *string `json:"vcenterPassword,omitempty" azure:"ro"` + + // READ-ONLY; vCenter admin username + VcenterUsername *string `json:"vcenterUsername,omitempty" azure:"ro"` +} + +// AuthorizationsBeginCreateOrUpdateOptions contains the optional parameters for the Authorizations.BeginCreateOrUpdate method. +type AuthorizationsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationsBeginDeleteOptions contains the optional parameters for the Authorizations.BeginDelete method. +type AuthorizationsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationsGetOptions contains the optional parameters for the Authorizations.Get method. +type AuthorizationsGetOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationsListOptions contains the optional parameters for the Authorizations.List method. +type AuthorizationsListOptions struct { + // placeholder for future optional parameters +} + +// AvailabilityProperties - The properties describing private cloud availability zone distribution +type AvailabilityProperties struct { + // The secondary availability zone for the private cloud + SecondaryZone *int32 `json:"secondaryZone,omitempty"` + + // The availability strategy for the private cloud + Strategy *AvailabilityStrategy `json:"strategy,omitempty"` + + // The primary availability zone for the private cloud + Zone *int32 `json:"zone,omitempty"` +} + +// Circuit - An ExpressRoute Circuit +type Circuit struct { + // READ-ONLY; Identifier of the ExpressRoute Circuit (Microsoft Colo only) + ExpressRouteID *string `json:"expressRouteID,omitempty" azure:"ro"` + + // READ-ONLY; ExpressRoute Circuit private peering identifier + ExpressRoutePrivatePeeringID *string `json:"expressRoutePrivatePeeringID,omitempty" azure:"ro"` + + // READ-ONLY; CIDR of primary subnet + PrimarySubnet *string `json:"primarySubnet,omitempty" azure:"ro"` + + // READ-ONLY; CIDR of secondary subnet + SecondarySubnet *string `json:"secondarySubnet,omitempty" azure:"ro"` +} + +// CloudError - API error response +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // An error returned by the API + InnerError *ErrorResponse `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 +} + +// CloudLink - A cloud link resource +type CloudLink struct { + Resource + // The properties of a cloud link. + Properties *CloudLinkProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudLink. +func (c CloudLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudLink. +func (c *CloudLink) 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.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// CloudLinkList - A paged list of cloud links +type CloudLinkList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*CloudLink `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudLinkList. +func (c CloudLinkList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CloudLinkProperties - The properties of a cloud link. +type CloudLinkProperties struct { + // Identifier of the other private cloud participating in the link. + LinkedCloud *string `json:"linkedCloud,omitempty"` + + // READ-ONLY; The state of the cloud link. + Status *CloudLinkStatus `json:"status,omitempty" azure:"ro"` +} + +// CloudLinksBeginCreateOrUpdateOptions contains the optional parameters for the CloudLinks.BeginCreateOrUpdate method. +type CloudLinksBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// CloudLinksBeginDeleteOptions contains the optional parameters for the CloudLinks.BeginDelete method. +type CloudLinksBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// CloudLinksGetOptions contains the optional parameters for the CloudLinks.Get method. +type CloudLinksGetOptions struct { + // placeholder for future optional parameters +} + +// CloudLinksListOptions contains the optional parameters for the CloudLinks.List method. +type CloudLinksListOptions struct { + // placeholder for future optional parameters +} + +// Cluster - A cluster resource +type Cluster struct { + Resource + // REQUIRED; The cluster SKU + SKU *SKU `json:"sku,omitempty"` + + // The properties of a cluster resource + Properties *ClusterProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + 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 "properties": + err = unpopulate(val, &c.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, &c.SKU) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := c.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ClusterList - A paged list of clusters +type ClusterList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*Cluster `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterList. +func (c ClusterList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ClusterProperties - The properties of a cluster +type ClusterProperties struct { + CommonClusterProperties +} + +// ClusterUpdate - An update of a cluster resource +type ClusterUpdate struct { + // The properties of a cluster resource that may be updated + Properties *ClusterUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterUpdate. +func (c ClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// ClusterUpdateProperties - The properties of a cluster that may be updated +type ClusterUpdateProperties struct { + // The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` + + // The hosts + Hosts []*string `json:"hosts,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterUpdateProperties. +func (c ClusterUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clusterSize", c.ClusterSize) + populate(objectMap, "hosts", c.Hosts) + return json.Marshal(objectMap) +} + +// ClustersBeginCreateOrUpdateOptions contains the optional parameters for the Clusters.BeginCreateOrUpdate method. +type ClustersBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginDeleteOptions contains the optional parameters for the Clusters.BeginDelete method. +type ClustersBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginUpdateOptions contains the optional parameters for the Clusters.BeginUpdate method. +type ClustersBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ClustersGetOptions contains the optional parameters for the Clusters.Get method. +type ClustersGetOptions struct { + // placeholder for future optional parameters +} + +// ClustersListOptions contains the optional parameters for the Clusters.List method. +type ClustersListOptions struct { + // placeholder for future optional parameters +} + +// CommonClusterProperties - The common properties of a cluster +type CommonClusterProperties struct { + // The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` + + // The hosts + Hosts []*string `json:"hosts,omitempty"` + + // READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty" azure:"ro"` + + // READ-ONLY; The state of the cluster provisioning + ProvisioningState *ClusterProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CommonClusterProperties. +func (c CommonClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (c CommonClusterProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "clusterId", c.ClusterID) + populate(objectMap, "clusterSize", c.ClusterSize) + populate(objectMap, "hosts", c.Hosts) + populate(objectMap, "provisioningState", c.ProvisioningState) +} + +// Datastore - A datastore resource +type Datastore struct { + Resource + // The properties of a datastore resource + Properties *DatastoreProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Datastore. +func (d Datastore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + d.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Datastore. +func (d *Datastore) 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.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// DatastoreList - A paged list of datastores +type DatastoreList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*Datastore `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DatastoreList. +func (d DatastoreList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DatastoreProperties - The properties of a datastore +type DatastoreProperties struct { + // An iSCSI volume + DiskPoolVolume *DiskPoolVolume `json:"diskPoolVolume,omitempty"` + + // An Azure NetApp Files volume + NetAppVolume *NetAppVolume `json:"netAppVolume,omitempty"` + + // READ-ONLY; The state of the datastore provisioning + ProvisioningState *DatastoreProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The operational status of the datastore + Status *DatastoreStatus `json:"status,omitempty" azure:"ro"` +} + +// DatastoresBeginCreateOrUpdateOptions contains the optional parameters for the Datastores.BeginCreateOrUpdate method. +type DatastoresBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DatastoresBeginDeleteOptions contains the optional parameters for the Datastores.BeginDelete method. +type DatastoresBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DatastoresGetOptions contains the optional parameters for the Datastores.Get method. +type DatastoresGetOptions struct { + // placeholder for future optional parameters +} + +// DatastoresListOptions contains the optional parameters for the Datastores.List method. +type DatastoresListOptions struct { + // placeholder for future optional parameters +} + +// DiskPoolVolume - An iSCSI volume from Microsoft.StoragePool provider +type DiskPoolVolume struct { + // REQUIRED; Name of the LUN to be used for datastore + LunName *string `json:"lunName,omitempty"` + + // REQUIRED; Azure resource ID of the iSCSI target + TargetID *string `json:"targetId,omitempty"` + + // Mode that describes whether the LUN has to be mounted as a datastore or attached as a LUN + MountOption *MountOptionEnum `json:"mountOption,omitempty"` + + // READ-ONLY; Device path + Path *string `json:"path,omitempty" azure:"ro"` +} + +// Encryption - The properties of customer managed encryption key +type Encryption struct { + // The key vault where the encryption key is stored + KeyVaultProperties *EncryptionKeyVaultProperties `json:"keyVaultProperties,omitempty"` + + // Status of customer managed encryption key + Status *EncryptionState `json:"status,omitempty"` +} + +// EncryptionKeyVaultProperties - An Encryption Key +type EncryptionKeyVaultProperties struct { + // The name of the key. + KeyName *string `json:"keyName,omitempty"` + + // The URL of the vault. + KeyVaultURL *string `json:"keyVaultUrl,omitempty"` + + // The version of the key. + KeyVersion *string `json:"keyVersion,omitempty"` + + // READ-ONLY; The state of key provided + KeyState *EncryptionKeyStatus `json:"keyState,omitempty" azure:"ro"` + + // READ-ONLY; Property of the key if user provided or auto detected + VersionType *EncryptionVersionType `json:"versionType,omitempty" azure:"ro"` +} + +// Endpoints - Endpoint addresses +type Endpoints struct { + // READ-ONLY; Endpoint for the HCX Cloud Manager + HcxCloudManager *string `json:"hcxCloudManager,omitempty" azure:"ro"` + + // READ-ONLY; Endpoint for the NSX-T Data Center manager + NsxtManager *string `json:"nsxtManager,omitempty" azure:"ro"` + + // READ-ONLY; Endpoint for Virtual Center Server Appliance + Vcsa *string `json:"vcsa,omitempty" azure:"ro"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.) +type ErrorResponse struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorResponse `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ExpressRouteAuthorization - ExpressRoute Circuit Authorization +type ExpressRouteAuthorization struct { + Resource + // READ-ONLY; The properties of an ExpressRoute Circuit Authorization resource + Properties *ExpressRouteAuthorizationProperties `json:"properties,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExpressRouteAuthorization. +func (e ExpressRouteAuthorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExpressRouteAuthorization. +func (e *ExpressRouteAuthorization) 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.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ExpressRouteAuthorizationList - A paged list of ExpressRoute Circuit Authorizations +type ExpressRouteAuthorizationList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*ExpressRouteAuthorization `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExpressRouteAuthorizationList. +func (e ExpressRouteAuthorizationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ExpressRouteAuthorizationProperties - The properties of an ExpressRoute Circuit Authorization resource +type ExpressRouteAuthorizationProperties struct { + // The ID of the ExpressRoute Circuit + ExpressRouteID *string `json:"expressRouteId,omitempty"` + + // READ-ONLY; The ID of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationID *string `json:"expressRouteAuthorizationId,omitempty" azure:"ro"` + + // READ-ONLY; The key of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationKey *string `json:"expressRouteAuthorizationKey,omitempty" azure:"ro"` + + // READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning + ProvisioningState *ExpressRouteAuthorizationProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GlobalReachConnection - A global reach connection resource +type GlobalReachConnection struct { + Resource + // The properties of a global reach connection resource + Properties *GlobalReachConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GlobalReachConnection. +func (g GlobalReachConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + g.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalReachConnection. +func (g *GlobalReachConnection) 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, &g.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := g.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// GlobalReachConnectionList - A paged list of global reach connections +type GlobalReachConnectionList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*GlobalReachConnection `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GlobalReachConnectionList. +func (g GlobalReachConnectionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GlobalReachConnectionProperties - The properties of a global reach connection +type GlobalReachConnectionProperties struct { + // Authorization key from the peer express route used for the global reach connection + AuthorizationKey *string `json:"authorizationKey,omitempty"` + + // The ID of the Private Cloud's ExpressRoute Circuit that is participating in the global reach connection + ExpressRouteID *string `json:"expressRouteId,omitempty"` + + // Identifier of the ExpressRoute Circuit to peer with in the global reach connection + PeerExpressRouteCircuit *string `json:"peerExpressRouteCircuit,omitempty"` + + // READ-ONLY; The network used for global reach carved out from the original network block provided for the private cloud + AddressPrefix *string `json:"addressPrefix,omitempty" azure:"ro"` + + // READ-ONLY; The connection status of the global reach connection + CircuitConnectionStatus *GlobalReachConnectionStatus `json:"circuitConnectionStatus,omitempty" azure:"ro"` + + // READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning + ProvisioningState *GlobalReachConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GlobalReachConnectionsBeginCreateOrUpdateOptions contains the optional parameters for the GlobalReachConnections.BeginCreateOrUpdate method. +type GlobalReachConnectionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// GlobalReachConnectionsBeginDeleteOptions contains the optional parameters for the GlobalReachConnections.BeginDelete method. +type GlobalReachConnectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// GlobalReachConnectionsGetOptions contains the optional parameters for the GlobalReachConnections.Get method. +type GlobalReachConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// GlobalReachConnectionsListOptions contains the optional parameters for the GlobalReachConnections.List method. +type GlobalReachConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// HcxEnterpriseSite - An HCX Enterprise Site resource +type HcxEnterpriseSite struct { + Resource + // READ-ONLY; The properties of an HCX Enterprise Site resource + Properties *HcxEnterpriseSiteProperties `json:"properties,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type HcxEnterpriseSite. +func (h HcxEnterpriseSite) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + h.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", h.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HcxEnterpriseSite. +func (h *HcxEnterpriseSite) 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, &h.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := h.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// HcxEnterpriseSiteList - A paged list of HCX Enterprise Sites +type HcxEnterpriseSiteList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on a page + Value []*HcxEnterpriseSite `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type HcxEnterpriseSiteList. +func (h HcxEnterpriseSiteList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// HcxEnterpriseSiteProperties - The properties of an HCX Enterprise Site +type HcxEnterpriseSiteProperties struct { + // READ-ONLY; The activation key + ActivationKey *string `json:"activationKey,omitempty" azure:"ro"` + + // READ-ONLY; The status of the HCX Enterprise Site + Status *HcxEnterpriseSiteStatus `json:"status,omitempty" azure:"ro"` +} + +// HcxEnterpriseSitesCreateOrUpdateOptions contains the optional parameters for the HcxEnterpriseSites.CreateOrUpdate method. +type HcxEnterpriseSitesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// HcxEnterpriseSitesDeleteOptions contains the optional parameters for the HcxEnterpriseSites.Delete method. +type HcxEnterpriseSitesDeleteOptions struct { + // placeholder for future optional parameters +} + +// HcxEnterpriseSitesGetOptions contains the optional parameters for the HcxEnterpriseSites.Get method. +type HcxEnterpriseSitesGetOptions struct { + // placeholder for future optional parameters +} + +// HcxEnterpriseSitesListOptions contains the optional parameters for the HcxEnterpriseSites.List method. +type HcxEnterpriseSitesListOptions struct { + // placeholder for future optional parameters +} + +// IdentitySource - vCenter Single Sign On Identity Source +type IdentitySource struct { + // The domain's NetBIOS name + Alias *string `json:"alias,omitempty"` + + // The base distinguished name for groups + BaseGroupDN *string `json:"baseGroupDN,omitempty"` + + // The base distinguished name for users + BaseUserDN *string `json:"baseUserDN,omitempty"` + + // The domain's dns name + Domain *string `json:"domain,omitempty"` + + // The name of the identity source + Name *string `json:"name,omitempty"` + + // The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. + Password *string `json:"password,omitempty"` + + // Primary server URL + PrimaryServer *string `json:"primaryServer,omitempty"` + + // Protect LDAP communication using SSL certificate (LDAPS) + SSL *SSLEnum `json:"ssl,omitempty"` + + // Secondary server URL + SecondaryServer *string `json:"secondaryServer,omitempty"` + + // The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group + Username *string `json:"username,omitempty"` +} + +// LocationsCheckQuotaAvailabilityOptions contains the optional parameters for the Locations.CheckQuotaAvailability method. +type LocationsCheckQuotaAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// LocationsCheckTrialAvailabilityOptions contains the optional parameters for the Locations.CheckTrialAvailability method. +type LocationsCheckTrialAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// LogSpecification - Specifications of the Log for Azure Monitoring +type LogSpecification struct { + // Blob duration of the log + BlobDuration *string `json:"blobDuration,omitempty"` + + // Localized friendly display name of the log + DisplayName *string `json:"displayName,omitempty"` + + // Name of the log + Name *string `json:"name,omitempty"` +} + +// ManagementCluster - The properties of a management cluster +type ManagementCluster struct { + CommonClusterProperties +} + +// MetricDimension - Specifications of the Dimension of metrics +type MetricDimension struct { + // Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + + // Name of the dimension as it appears in MDM + InternalName *string `json:"internalName,omitempty"` + + // Name of the dimension + Name *string `json:"name,omitempty"` + + // A boolean flag indicating whether this dimension should be included for the shoebox export scenario + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// MetricSpecification - Specifications of the Metrics for Azure Monitoring +type MetricSpecification struct { + // Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + + // Name of the metric category that the metric belongs to. A metric can only belong to a single category. + Category *string `json:"category,omitempty"` + + // Dimensions of the metric + Dimensions []*MetricDimension `json:"dimensions,omitempty"` + + // Localized friendly description of the metric + DisplayDescription *string `json:"displayDescription,omitempty"` + + // Localized friendly display name of the metric + DisplayName *string `json:"displayName,omitempty"` + + // Whether or not the service is using regional MDM accounts. + EnableRegionalMdmAccount *string `json:"enableRegionalMdmAccount,omitempty"` + + // Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published. + FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + + // Name of the metric + Name *string `json:"name,omitempty"` + + // The name of the MDM account. + SourceMdmAccount *string `json:"sourceMdmAccount,omitempty"` + + // The name of the MDM namespace. + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty"` + + // Supported aggregation types + SupportedAggregationTypes []*string `json:"supportedAggregationTypes,omitempty"` + + // Supported time grain types + SupportedTimeGrainTypes []*string `json:"supportedTimeGrainTypes,omitempty"` + + // Unit that makes sense for the metric + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "enableRegionalMdmAccount", m.EnableRegionalMdmAccount) + populate(objectMap, "fillGapWithZero", m.FillGapWithZero) + populate(objectMap, "name", m.Name) + populate(objectMap, "sourceMdmAccount", m.SourceMdmAccount) + populate(objectMap, "sourceMdmNamespace", m.SourceMdmNamespace) + populate(objectMap, "supportedAggregationTypes", m.SupportedAggregationTypes) + populate(objectMap, "supportedTimeGrainTypes", m.SupportedTimeGrainTypes) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// NetAppVolume - An Azure NetApp Files volume from Microsoft.NetApp provider +type NetAppVolume struct { + // REQUIRED; Azure resource ID of the NetApp volume + ID *string `json:"id,omitempty"` +} + +// Operation - A REST API operation +type Operation struct { + // Gets or sets a value indicating whether the operation is a data action or not + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Origin of the operation + Origin *string `json:"origin,omitempty"` + + // Properties of the operation + Properties *OperationProperties `json:"properties,omitempty"` + + // READ-ONLY; Contains the localized display information for this operation + Display *OperationDisplay `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; Name of the operation being performed on this object + Name *string `json:"name,omitempty" azure:"ro"` +} + +// OperationDisplay - Contains the localized display information for this operation +type OperationDisplay struct { + // READ-ONLY; Localized friendly description for the operation + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Localized friendly name for the operation + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Localized friendly form of the resource provider name + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; Localized friendly form of the resource type related to this operation + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationList - Pageable list of operations +type OperationList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationProperties - Extra Operation properties +type OperationProperties struct { + // Service specifications of the operation + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PSCredentialExecutionParameter - a powershell credential object +type PSCredentialExecutionParameter struct { + ScriptExecutionParameter + // password for login + Password *string `json:"password,omitempty"` + + // username for login + Username *string `json:"username,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PSCredentialExecutionParameter. +func (p PSCredentialExecutionParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.ScriptExecutionParameter.marshalInternal(objectMap, ScriptExecutionParameterTypeCredential) + populate(objectMap, "password", p.Password) + populate(objectMap, "username", p.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PSCredentialExecutionParameter. +func (p *PSCredentialExecutionParameter) 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 "password": + err = unpopulate(val, &p.Password) + delete(rawMsg, key) + case "username": + err = unpopulate(val, &p.Username) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.ScriptExecutionParameter.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// PlacementPoliciesBeginCreateOrUpdateOptions contains the optional parameters for the PlacementPolicies.BeginCreateOrUpdate method. +type PlacementPoliciesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PlacementPoliciesBeginDeleteOptions contains the optional parameters for the PlacementPolicies.BeginDelete method. +type PlacementPoliciesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PlacementPoliciesBeginUpdateOptions contains the optional parameters for the PlacementPolicies.BeginUpdate method. +type PlacementPoliciesBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// PlacementPoliciesGetOptions contains the optional parameters for the PlacementPolicies.Get method. +type PlacementPoliciesGetOptions struct { + // placeholder for future optional parameters +} + +// PlacementPoliciesList - Represents list of placement policies +type PlacementPoliciesList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*PlacementPolicy `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PlacementPoliciesList. +func (p PlacementPoliciesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PlacementPoliciesListOptions contains the optional parameters for the PlacementPolicies.List method. +type PlacementPoliciesListOptions struct { + // placeholder for future optional parameters +} + +// PlacementPolicy - A vSphere Distributed Resource Scheduler (DRS) placement policy +type PlacementPolicy struct { + Resource + // placement policy properties + Properties PlacementPolicyPropertiesClassification `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PlacementPolicy. +func (p PlacementPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlacementPolicy. +func (p *PlacementPolicy) 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": + p.Properties, err = unmarshalPlacementPolicyPropertiesClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.Resource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// PlacementPolicyPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetPlacementPolicyProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *PlacementPolicyProperties, *VmHostPlacementPolicyProperties, *VmPlacementPolicyProperties +type PlacementPolicyPropertiesClassification interface { + // GetPlacementPolicyProperties returns the PlacementPolicyProperties content of the underlying type. + GetPlacementPolicyProperties() *PlacementPolicyProperties +} + +// PlacementPolicyProperties - Abstract placement policy properties +type PlacementPolicyProperties struct { + // REQUIRED; placement policy type + Type *PlacementPolicyType `json:"type,omitempty"` + + // Display name of the placement policy + DisplayName *string `json:"displayName,omitempty"` + + // Whether the placement policy is enabled or disabled + State *PlacementPolicyState `json:"state,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *PlacementPolicyProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GetPlacementPolicyProperties implements the PlacementPolicyPropertiesClassification interface for type PlacementPolicyProperties. +func (p *PlacementPolicyProperties) GetPlacementPolicyProperties() *PlacementPolicyProperties { + return p +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlacementPolicyProperties. +func (p *PlacementPolicyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return p.unmarshalInternal(rawMsg) +} + +func (p PlacementPolicyProperties) marshalInternal(objectMap map[string]interface{}, discValue PlacementPolicyType) { + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "state", p.State) + p.Type = &discValue + objectMap["type"] = p.Type +} + +func (p *PlacementPolicyProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, &p.DisplayName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &p.ProvisioningState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &p.State) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &p.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// PlacementPolicyUpdate - An update of a DRS placement policy resource +type PlacementPolicyUpdate struct { + // The properties of a placement policy resource that may be updated + Properties *PlacementPolicyUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PlacementPolicyUpdate. +func (p PlacementPolicyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PlacementPolicyUpdateProperties - The properties of a placement policy resource that may be updated +type PlacementPolicyUpdateProperties struct { + // Host members list + HostMembers []*string `json:"hostMembers,omitempty"` + + // Whether the placement policy is enabled or disabled + State *PlacementPolicyState `json:"state,omitempty"` + + // Virtual machine members list + VMMembers []*string `json:"vmMembers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PlacementPolicyUpdateProperties. +func (p PlacementPolicyUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hostMembers", p.HostMembers) + populate(objectMap, "state", p.State) + populate(objectMap, "vmMembers", p.VMMembers) + return json.Marshal(objectMap) +} + +// PrivateCloud - A private cloud resource +type PrivateCloud struct { + TrackedResource + // REQUIRED; The private cloud SKU + SKU *SKU `json:"sku,omitempty"` + + // The identity of the private cloud, if configured. + Identity *PrivateCloudIdentity `json:"identity,omitempty"` + + // The properties of a private cloud resource + Properties *PrivateCloudProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateCloud. +func (p PrivateCloud) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateCloud. +func (p *PrivateCloud) 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, &p.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &p.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, &p.SKU) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.TrackedResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// PrivateCloudIdentity - Identity for the virtual machine. +type PrivateCloudIdentity struct { + // The type of identity used for the private cloud. The type 'SystemAssigned' refers to an implicitly created identity. The type 'None' will remove any + // identities from the Private Cloud. + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; The principal ID of private cloud identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID associated with the private cloud. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// PrivateCloudList - A paged list of private clouds +type PrivateCloudList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*PrivateCloud `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateCloudList. +func (p PrivateCloudList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateCloudProperties - The properties of a private cloud resource +type PrivateCloudProperties struct { + PrivateCloudUpdateProperties + // REQUIRED; The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) + // where A,B,C,D are between 0 and 255, and X is + // between 0 and 22 + NetworkBlock *string `json:"networkBlock,omitempty"` + + // An ExpressRoute Circuit + Circuit *Circuit `json:"circuit,omitempty"` + + // Optionally, set the NSX-T Manager password when the private cloud is created + NsxtPassword *string `json:"nsxtPassword,omitempty"` + + // A secondary expressRoute circuit from a separate AZ. Only present in a stretched private cloud + SecondaryCircuit *Circuit `json:"secondaryCircuit,omitempty"` + + // Optionally, set the vCenter admin password when the private cloud is created + VcenterPassword *string `json:"vcenterPassword,omitempty"` + + // READ-ONLY; The endpoints + Endpoints *Endpoints `json:"endpoints,omitempty" azure:"ro"` + + // READ-ONLY; Array of cloud link IDs from other clouds that connect to this one + ExternalCloudLinks []*string `json:"externalCloudLinks,omitempty" azure:"ro"` + + // READ-ONLY; Network used to access vCenter Server and NSX-T Manager + ManagementNetwork *string `json:"managementNetwork,omitempty" azure:"ro"` + + // READ-ONLY; Thumbprint of the NSX-T Manager SSL certificate + NsxtCertificateThumbprint *string `json:"nsxtCertificateThumbprint,omitempty" azure:"ro"` + + // READ-ONLY; Used for virtual machine cold migration, cloning, and snapshot migration + ProvisioningNetwork *string `json:"provisioningNetwork,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state + ProvisioningState *PrivateCloudProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Thumbprint of the vCenter Server SSL certificate + VcenterCertificateThumbprint *string `json:"vcenterCertificateThumbprint,omitempty" azure:"ro"` + + // READ-ONLY; Used for live migration of virtual machines + VmotionNetwork *string `json:"vmotionNetwork,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateCloudProperties. +func (p PrivateCloudProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.PrivateCloudUpdateProperties.marshalInternal(objectMap) + populate(objectMap, "circuit", p.Circuit) + populate(objectMap, "endpoints", p.Endpoints) + populate(objectMap, "externalCloudLinks", p.ExternalCloudLinks) + populate(objectMap, "managementNetwork", p.ManagementNetwork) + populate(objectMap, "networkBlock", p.NetworkBlock) + populate(objectMap, "nsxtCertificateThumbprint", p.NsxtCertificateThumbprint) + populate(objectMap, "nsxtPassword", p.NsxtPassword) + populate(objectMap, "provisioningNetwork", p.ProvisioningNetwork) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "secondaryCircuit", p.SecondaryCircuit) + populate(objectMap, "vcenterCertificateThumbprint", p.VcenterCertificateThumbprint) + populate(objectMap, "vcenterPassword", p.VcenterPassword) + populate(objectMap, "vmotionNetwork", p.VmotionNetwork) + return json.Marshal(objectMap) +} + +// PrivateCloudUpdate - An update to a private cloud resource +type PrivateCloudUpdate struct { + // The identity of the private cloud, if configured. + Identity *PrivateCloudIdentity `json:"identity,omitempty"` + + // The updatable properties of a private cloud resource + Properties *PrivateCloudUpdateProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateCloudUpdate. +func (p PrivateCloudUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// PrivateCloudUpdateProperties - The properties of a private cloud resource that may be updated +type PrivateCloudUpdateProperties struct { + // Properties describing how the cloud is distributed across availability zones + Availability *AvailabilityProperties `json:"availability,omitempty"` + + // Customer managed key encryption, can be enabled or disabled + Encryption *Encryption `json:"encryption,omitempty"` + + // vCenter Single Sign On Identity Sources + IdentitySources []*IdentitySource `json:"identitySources,omitempty"` + + // Connectivity to internet is enabled or disabled + Internet *InternetEnum `json:"internet,omitempty"` + + // The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateCloudUpdateProperties. +func (p PrivateCloudUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (p PrivateCloudUpdateProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "availability", p.Availability) + populate(objectMap, "encryption", p.Encryption) + populate(objectMap, "identitySources", p.IdentitySources) + populate(objectMap, "internet", p.Internet) + populate(objectMap, "managementCluster", p.ManagementCluster) +} + +// PrivateCloudsBeginCreateOrUpdateOptions contains the optional parameters for the PrivateClouds.BeginCreateOrUpdate method. +type PrivateCloudsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsBeginDeleteOptions contains the optional parameters for the PrivateClouds.BeginDelete method. +type PrivateCloudsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsBeginRotateNsxtPasswordOptions contains the optional parameters for the PrivateClouds.BeginRotateNsxtPassword method. +type PrivateCloudsBeginRotateNsxtPasswordOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsBeginRotateVcenterPasswordOptions contains the optional parameters for the PrivateClouds.BeginRotateVcenterPassword method. +type PrivateCloudsBeginRotateVcenterPasswordOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsBeginUpdateOptions contains the optional parameters for the PrivateClouds.BeginUpdate method. +type PrivateCloudsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsGetOptions contains the optional parameters for the PrivateClouds.Get method. +type PrivateCloudsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsListAdminCredentialsOptions contains the optional parameters for the PrivateClouds.ListAdminCredentials method. +type PrivateCloudsListAdminCredentialsOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsListInSubscriptionOptions contains the optional parameters for the PrivateClouds.ListInSubscription method. +type PrivateCloudsListInSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// PrivateCloudsListOptions contains the optional parameters for the PrivateClouds.List method. +type PrivateCloudsListOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - The resource model definition for a ARM proxy resource +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 +} + +// Quota - Subscription quotas +type Quota struct { + // READ-ONLY; Remaining hosts quota by sku type + HostsRemaining map[string]*int32 `json:"hostsRemaining,omitempty" azure:"ro"` + + // READ-ONLY; Host quota is active for current subscription + QuotaEnabled *QuotaEnabled `json:"quotaEnabled,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Quota. +func (q Quota) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hostsRemaining", q.HostsRemaining) + populate(objectMap, "quotaEnabled", q.QuotaEnabled) + return json.Marshal(objectMap) +} + +// Resource - The core properties of ARM resources +type Resource struct { + // READ-ONLY; Resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type. + 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 +} + +// SKU - The resource model definition representing SKU +type SKU struct { + // REQUIRED; The name of the SKU. + Name *string `json:"name,omitempty"` +} + +// ScriptCmdlet - A cmdlet available for script execution +type ScriptCmdlet struct { + ProxyResource + // The properties of a script cmdlet resource + Properties *ScriptCmdletProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptCmdlet. +func (s ScriptCmdlet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptCmdlet. +func (s *ScriptCmdlet) 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) + } + if err != nil { + return err + } + } + if err := s.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ScriptCmdletProperties - Properties of a pre-canned script +type ScriptCmdletProperties struct { + // READ-ONLY; Description of the scripts functionality + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Parameters the script will accept + Parameters []*ScriptParameter `json:"parameters,omitempty" azure:"ro"` + + // READ-ONLY; Recommended time limit for execution + Timeout *string `json:"timeout,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptCmdletProperties. +func (s ScriptCmdletProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", s.Description) + populate(objectMap, "parameters", s.Parameters) + populate(objectMap, "timeout", s.Timeout) + return json.Marshal(objectMap) +} + +// ScriptCmdletsGetOptions contains the optional parameters for the ScriptCmdlets.Get method. +type ScriptCmdletsGetOptions struct { + // placeholder for future optional parameters +} + +// ScriptCmdletsList - Pageable list of scripts/cmdlets +type ScriptCmdletsList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of scripts + Value []*ScriptCmdlet `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptCmdletsList. +func (s ScriptCmdletsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ScriptCmdletsListOptions contains the optional parameters for the ScriptCmdlets.List method. +type ScriptCmdletsListOptions struct { + // placeholder for future optional parameters +} + +// ScriptExecution - An instance of a script executed by a user - custom or AVS +type ScriptExecution struct { + ProxyResource + // The properties of a script execution resource + Properties *ScriptExecutionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptExecution. +func (s ScriptExecution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecution. +func (s *ScriptExecution) 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) + } + if err != nil { + return err + } + } + if err := s.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ScriptExecutionParameterClassification provides polymorphic access to related types. +// Call the interface's GetScriptExecutionParameter() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *PSCredentialExecutionParameter, *ScriptExecutionParameter, *ScriptSecureStringExecutionParameter, *ScriptStringExecutionParameter +type ScriptExecutionParameterClassification interface { + // GetScriptExecutionParameter returns the ScriptExecutionParameter content of the underlying type. + GetScriptExecutionParameter() *ScriptExecutionParameter +} + +// ScriptExecutionParameter - The arguments passed in to the execution +type ScriptExecutionParameter struct { + // REQUIRED; The parameter name + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of execution parameter + Type *ScriptExecutionParameterType `json:"type,omitempty"` +} + +// GetScriptExecutionParameter implements the ScriptExecutionParameterClassification interface for type ScriptExecutionParameter. +func (s *ScriptExecutionParameter) GetScriptExecutionParameter() *ScriptExecutionParameter { return s } + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecutionParameter. +func (s *ScriptExecutionParameter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return s.unmarshalInternal(rawMsg) +} + +func (s ScriptExecutionParameter) marshalInternal(objectMap map[string]interface{}, discValue ScriptExecutionParameterType) { + populate(objectMap, "name", s.Name) + s.Type = &discValue + objectMap["type"] = s.Type +} + +func (s *ScriptExecutionParameter) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, &s.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &s.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ScriptExecutionProperties - Properties of a user-invoked script +type ScriptExecutionProperties struct { + // REQUIRED; Time limit for execution + Timeout *string `json:"timeout,omitempty"` + + // Error message if the script was able to run, but if the script itself had errors or powershell threw an exception + FailureReason *string `json:"failureReason,omitempty"` + + // Parameters that will be hidden/not visible to ARM, such as passwords and credentials + HiddenParameters []ScriptExecutionParameterClassification `json:"hiddenParameters,omitempty"` + + // User-defined dictionary. + NamedOutputs map[string]map[string]interface{} `json:"namedOutputs,omitempty"` + + // Standard output stream from the powershell execution + Output []*string `json:"output,omitempty"` + + // Parameters the script will accept + Parameters []ScriptExecutionParameterClassification `json:"parameters,omitempty"` + + // Time to live for the resource. If not provided, will be available for 60 days + Retention *string `json:"retention,omitempty"` + + // A reference to the script cmdlet resource if user is running a AVS script + ScriptCmdletID *string `json:"scriptCmdletId,omitempty"` + + // READ-ONLY; Standard error output stream from the powershell execution + Errors []*string `json:"errors,omitempty" azure:"ro"` + + // READ-ONLY; Time the script execution was finished + FinishedAt *time.Time `json:"finishedAt,omitempty" azure:"ro"` + + // READ-ONLY; Standard information out stream from the powershell execution + Information []*string `json:"information,omitempty" azure:"ro"` + + // READ-ONLY; The state of the script execution resource + ProvisioningState *ScriptExecutionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Time the script execution was started + StartedAt *time.Time `json:"startedAt,omitempty" azure:"ro"` + + // READ-ONLY; Time the script execution was submitted + SubmittedAt *time.Time `json:"submittedAt,omitempty" azure:"ro"` + + // READ-ONLY; Standard warning out stream from the powershell execution + Warnings []*string `json:"warnings,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptExecutionProperties. +func (s ScriptExecutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "errors", s.Errors) + populate(objectMap, "failureReason", s.FailureReason) + populateTimeRFC3339(objectMap, "finishedAt", s.FinishedAt) + populate(objectMap, "hiddenParameters", s.HiddenParameters) + populate(objectMap, "information", s.Information) + populate(objectMap, "namedOutputs", s.NamedOutputs) + populate(objectMap, "output", s.Output) + populate(objectMap, "parameters", s.Parameters) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "retention", s.Retention) + populate(objectMap, "scriptCmdletId", s.ScriptCmdletID) + populateTimeRFC3339(objectMap, "startedAt", s.StartedAt) + populateTimeRFC3339(objectMap, "submittedAt", s.SubmittedAt) + populate(objectMap, "timeout", s.Timeout) + populate(objectMap, "warnings", s.Warnings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecutionProperties. +func (s *ScriptExecutionProperties) 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 "errors": + err = unpopulate(val, &s.Errors) + delete(rawMsg, key) + case "failureReason": + err = unpopulate(val, &s.FailureReason) + delete(rawMsg, key) + case "finishedAt": + err = unpopulateTimeRFC3339(val, &s.FinishedAt) + delete(rawMsg, key) + case "hiddenParameters": + s.HiddenParameters, err = unmarshalScriptExecutionParameterClassificationArray(val) + delete(rawMsg, key) + case "information": + err = unpopulate(val, &s.Information) + delete(rawMsg, key) + case "namedOutputs": + err = unpopulate(val, &s.NamedOutputs) + delete(rawMsg, key) + case "output": + err = unpopulate(val, &s.Output) + delete(rawMsg, key) + case "parameters": + s.Parameters, err = unmarshalScriptExecutionParameterClassificationArray(val) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &s.ProvisioningState) + delete(rawMsg, key) + case "retention": + err = unpopulate(val, &s.Retention) + delete(rawMsg, key) + case "scriptCmdletId": + err = unpopulate(val, &s.ScriptCmdletID) + delete(rawMsg, key) + case "startedAt": + err = unpopulateTimeRFC3339(val, &s.StartedAt) + delete(rawMsg, key) + case "submittedAt": + err = unpopulateTimeRFC3339(val, &s.SubmittedAt) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, &s.Timeout) + delete(rawMsg, key) + case "warnings": + err = unpopulate(val, &s.Warnings) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ScriptExecutionsBeginCreateOrUpdateOptions contains the optional parameters for the ScriptExecutions.BeginCreateOrUpdate method. +type ScriptExecutionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScriptExecutionsBeginDeleteOptions contains the optional parameters for the ScriptExecutions.BeginDelete method. +type ScriptExecutionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ScriptExecutionsGetExecutionLogsOptions contains the optional parameters for the ScriptExecutions.GetExecutionLogs method. +type ScriptExecutionsGetExecutionLogsOptions struct { + // Name of the desired output stream to return. If not provided, will return all. An empty array will return nothing + ScriptOutputStreamType []*ScriptOutputStreamType +} + +// ScriptExecutionsGetOptions contains the optional parameters for the ScriptExecutions.Get method. +type ScriptExecutionsGetOptions struct { + // placeholder for future optional parameters +} + +// ScriptExecutionsList - Pageable list of script executions +type ScriptExecutionsList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of scripts + Value []*ScriptExecution `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptExecutionsList. +func (s ScriptExecutionsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ScriptExecutionsListOptions contains the optional parameters for the ScriptExecutions.List method. +type ScriptExecutionsListOptions struct { + // placeholder for future optional parameters +} + +// ScriptPackage - Script Package resources available for execution +type ScriptPackage struct { + ProxyResource + // ScriptPackage resource properties + Properties *ScriptPackageProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptPackage. +func (s ScriptPackage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptPackage. +func (s *ScriptPackage) 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) + } + if err != nil { + return err + } + } + if err := s.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ScriptPackageProperties - Properties of a Script Package subresource +type ScriptPackageProperties struct { + // READ-ONLY; User friendly description of the package + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Module version + Version *string `json:"version,omitempty" azure:"ro"` +} + +// ScriptPackagesGetOptions contains the optional parameters for the ScriptPackages.Get method. +type ScriptPackagesGetOptions struct { + // placeholder for future optional parameters +} + +// ScriptPackagesList - A list of the available script packages +type ScriptPackagesList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of script package resources + Value []*ScriptPackage `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptPackagesList. +func (s ScriptPackagesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ScriptPackagesListOptions contains the optional parameters for the ScriptPackages.List method. +type ScriptPackagesListOptions struct { + // placeholder for future optional parameters +} + +// ScriptParameter - An parameter that the script will accept +type ScriptParameter struct { + // The parameter name that the script will expect a parameter value for + Name *string `json:"name,omitempty"` + + // READ-ONLY; User friendly description of the parameter + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Is this parameter required or optional + Optional *OptionalParamEnum `json:"optional,omitempty" azure:"ro"` + + // READ-ONLY; The type of parameter the script is expecting. psCredential is a PSCredentialObject + Type *ScriptParameterTypes `json:"type,omitempty" azure:"ro"` + + // READ-ONLY; Should this parameter be visible to arm and passed in the parameters argument when executing + Visibility *VisibilityParameterEnum `json:"visibility,omitempty" azure:"ro"` +} + +// ScriptSecureStringExecutionParameter - a plain text value execution parameter +type ScriptSecureStringExecutionParameter struct { + ScriptExecutionParameter + // A secure value for the passed parameter, not to be stored in logs + SecureValue *string `json:"secureValue,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptSecureStringExecutionParameter. +func (s ScriptSecureStringExecutionParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ScriptExecutionParameter.marshalInternal(objectMap, ScriptExecutionParameterTypeSecureValue) + populate(objectMap, "secureValue", s.SecureValue) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptSecureStringExecutionParameter. +func (s *ScriptSecureStringExecutionParameter) 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 "secureValue": + err = unpopulate(val, &s.SecureValue) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.ScriptExecutionParameter.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ScriptStringExecutionParameter - a plain text value execution parameter +type ScriptStringExecutionParameter struct { + ScriptExecutionParameter + // The value for the passed parameter + Value *string `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptStringExecutionParameter. +func (s ScriptStringExecutionParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ScriptExecutionParameter.marshalInternal(objectMap, ScriptExecutionParameterTypeValue) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptStringExecutionParameter. +func (s *ScriptStringExecutionParameter) 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": + err = unpopulate(val, &s.Value) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.ScriptExecutionParameter.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ServiceSpecification - Service specification payload +type ServiceSpecification struct { + // Specifications of the Log for Azure Monitoring + LogSpecifications []*LogSpecification `json:"logSpecifications,omitempty"` + + // Specifications of the Metrics for Azure Monitoring + MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "logSpecifications", s.LogSpecifications) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +// TrackedResource - The resource model definition for a ARM tracked top level resource +type TrackedResource struct { + Resource + // Resource location + 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 +} + +// Trial - Subscription trial availability +type Trial struct { + // READ-ONLY; Number of trial hosts available + AvailableHosts *int32 `json:"availableHosts,omitempty" azure:"ro"` + + // READ-ONLY; Trial status + Status *TrialStatus `json:"status,omitempty" azure:"ro"` +} + +// VMHostPlacementPolicyProperties - VM-Host placement policy properties +type VMHostPlacementPolicyProperties struct { + PlacementPolicyProperties + // REQUIRED; placement policy affinity type + AffinityType *AffinityType `json:"affinityType,omitempty"` + + // REQUIRED; Host members list + HostMembers []*string `json:"hostMembers,omitempty"` + + // REQUIRED; Virtual machine members list + VMMembers []*string `json:"vmMembers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VMHostPlacementPolicyProperties. +func (v VMHostPlacementPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.PlacementPolicyProperties.marshalInternal(objectMap, PlacementPolicyTypeVMHost) + populate(objectMap, "affinityType", v.AffinityType) + populate(objectMap, "hostMembers", v.HostMembers) + populate(objectMap, "vmMembers", v.VMMembers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMHostPlacementPolicyProperties. +func (v *VMHostPlacementPolicyProperties) 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 "affinityType": + err = unpopulate(val, &v.AffinityType) + delete(rawMsg, key) + case "hostMembers": + err = unpopulate(val, &v.HostMembers) + delete(rawMsg, key) + case "vmMembers": + err = unpopulate(val, &v.VMMembers) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := v.PlacementPolicyProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VMPlacementPolicyProperties - VM-VM placement policy properties +type VMPlacementPolicyProperties struct { + PlacementPolicyProperties + // REQUIRED; placement policy affinity type + AffinityType *AffinityType `json:"affinityType,omitempty"` + + // REQUIRED; Virtual machine members list + VMMembers []*string `json:"vmMembers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VMPlacementPolicyProperties. +func (v VMPlacementPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.PlacementPolicyProperties.marshalInternal(objectMap, PlacementPolicyTypeVMVM) + populate(objectMap, "affinityType", v.AffinityType) + populate(objectMap, "vmMembers", v.VMMembers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMPlacementPolicyProperties. +func (v *VMPlacementPolicyProperties) 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 "affinityType": + err = unpopulate(val, &v.AffinityType) + delete(rawMsg, key) + case "vmMembers": + err = unpopulate(val, &v.VMMembers) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := v.PlacementPolicyProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VirtualMachine - Virtual Machine +type VirtualMachine struct { + ProxyResource + // Virtual machine properties. + Properties *VirtualMachineProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachine. +func (v VirtualMachine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachine. +func (v *VirtualMachine) 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, &v.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := v.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VirtualMachineProperties - Virtual Machine Properties +type VirtualMachineProperties struct { + // READ-ONLY; Display name of the VM. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Path to virtual machine's folder starting from datacenter virtual machine folder + FolderPath *string `json:"folderPath,omitempty" azure:"ro"` + + // READ-ONLY; Virtual machine managed object reference id + MoRefID *string `json:"moRefId,omitempty" azure:"ro"` + + // READ-ONLY; Whether VM DRS-driven movement is restricted (enabled) or not (disabled) + RestrictMovement *VirtualMachineRestrictMovementState `json:"restrictMovement,omitempty" azure:"ro"` +} + +// VirtualMachineRestrictMovement - Set VM DRS-driven movement to restricted (enabled) or not (disabled) +type VirtualMachineRestrictMovement struct { + // Whether VM DRS-driven movement is restricted (enabled) or not (disabled) + RestrictMovement *VirtualMachineRestrictMovementState `json:"restrictMovement,omitempty"` +} + +// VirtualMachinesBeginRestrictMovementOptions contains the optional parameters for the VirtualMachines.BeginRestrictMovement method. +type VirtualMachinesBeginRestrictMovementOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesGetOptions contains the optional parameters for the VirtualMachines.Get method. +type VirtualMachinesGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesList - A list of Virtual Machines +type VirtualMachinesList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items to be displayed on the page + Value []*VirtualMachine `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachinesList. +func (v VirtualMachinesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// VirtualMachinesListOptions contains the optional parameters for the VirtualMachines.List method. +type VirtualMachinesListOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworkDNSService - NSX DNS Service +type WorkloadNetworkDNSService struct { + ProxyResource + // DNS Service properties + Properties *WorkloadNetworkDNSServiceProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDNSService. +func (w WorkloadNetworkDNSService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkDNSService. +func (w *WorkloadNetworkDNSService) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkDNSServiceProperties - NSX DNS Service Properties +type WorkloadNetworkDNSServiceProperties struct { + // DNS service IP of the DNS Service. + DNSServiceIP *string `json:"dnsServiceIp,omitempty"` + + // Default DNS zone of the DNS Service. + DefaultDNSZone *string `json:"defaultDnsZone,omitempty"` + + // Display name of the DNS Service. + DisplayName *string `json:"displayName,omitempty"` + + // FQDN zones of the DNS Service. + FqdnZones []*string `json:"fqdnZones,omitempty"` + + // DNS Service log level. + LogLevel *DNSServiceLogLevelEnum `json:"logLevel,omitempty"` + + // NSX revision number. + Revision *int64 `json:"revision,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkDNSServiceProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; DNS Service status. + Status *DNSServiceStatusEnum `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDNSServiceProperties. +func (w WorkloadNetworkDNSServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dnsServiceIp", w.DNSServiceIP) + populate(objectMap, "defaultDnsZone", w.DefaultDNSZone) + populate(objectMap, "displayName", w.DisplayName) + populate(objectMap, "fqdnZones", w.FqdnZones) + populate(objectMap, "logLevel", w.LogLevel) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "revision", w.Revision) + populate(objectMap, "status", w.Status) + return json.Marshal(objectMap) +} + +// WorkloadNetworkDNSServicesList - A list of NSX DNS Services +type WorkloadNetworkDNSServicesList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkDNSService `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDNSServicesList. +func (w WorkloadNetworkDNSServicesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkDNSZone - NSX DNS Zone +type WorkloadNetworkDNSZone struct { + ProxyResource + // DNS Zone properties + Properties *WorkloadNetworkDNSZoneProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDNSZone. +func (w WorkloadNetworkDNSZone) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkDNSZone. +func (w *WorkloadNetworkDNSZone) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkDNSZoneProperties - NSX DNS Zone Properties +type WorkloadNetworkDNSZoneProperties struct { + // DNS Server IP array of the DNS Zone. + DNSServerIPs []*string `json:"dnsServerIps,omitempty"` + + // Number of DNS Services using the DNS zone. + DNSServices *int64 `json:"dnsServices,omitempty"` + + // Display name of the DNS Zone. + DisplayName *string `json:"displayName,omitempty"` + + // Domain names of the DNS Zone. + Domain []*string `json:"domain,omitempty"` + + // NSX revision number. + Revision *int64 `json:"revision,omitempty"` + + // Source IP of the DNS Zone. + SourceIP *string `json:"sourceIp,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkDNSZoneProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDNSZoneProperties. +func (w WorkloadNetworkDNSZoneProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dnsServerIps", w.DNSServerIPs) + populate(objectMap, "dnsServices", w.DNSServices) + populate(objectMap, "displayName", w.DisplayName) + populate(objectMap, "domain", w.Domain) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "revision", w.Revision) + populate(objectMap, "sourceIp", w.SourceIP) + return json.Marshal(objectMap) +} + +// WorkloadNetworkDNSZonesList - A list of NSX DNS Zones +type WorkloadNetworkDNSZonesList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkDNSZone `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDNSZonesList. +func (w WorkloadNetworkDNSZonesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkDhcp - NSX DHCP +type WorkloadNetworkDhcp struct { + ProxyResource + // DHCP properties. + Properties WorkloadNetworkDhcpEntityClassification `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDhcp. +func (w WorkloadNetworkDhcp) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkDhcp. +func (w *WorkloadNetworkDhcp) 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": + w.Properties, err = unmarshalWorkloadNetworkDhcpEntityClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkDhcpEntityClassification provides polymorphic access to related types. +// Call the interface's GetWorkloadNetworkDhcpEntity() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *WorkloadNetworkDhcpEntity, *WorkloadNetworkDhcpRelay, *WorkloadNetworkDhcpServer +type WorkloadNetworkDhcpEntityClassification interface { + // GetWorkloadNetworkDhcpEntity returns the WorkloadNetworkDhcpEntity content of the underlying type. + GetWorkloadNetworkDhcpEntity() *WorkloadNetworkDhcpEntity +} + +// WorkloadNetworkDhcpEntity - Base class for WorkloadNetworkDhcpServer and WorkloadNetworkDhcpRelay to inherit from +type WorkloadNetworkDhcpEntity struct { + // REQUIRED; Type of DHCP: SERVER or RELAY. + DhcpType *DhcpTypeEnum `json:"dhcpType,omitempty"` + + // Display name of the DHCP entity. + DisplayName *string `json:"displayName,omitempty"` + + // NSX revision number. + Revision *int64 `json:"revision,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkDhcpProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; NSX Segments consuming DHCP. + Segments []*string `json:"segments,omitempty" azure:"ro"` +} + +// GetWorkloadNetworkDhcpEntity implements the WorkloadNetworkDhcpEntityClassification interface for type WorkloadNetworkDhcpEntity. +func (w *WorkloadNetworkDhcpEntity) GetWorkloadNetworkDhcpEntity() *WorkloadNetworkDhcpEntity { + return w +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkDhcpEntity. +func (w *WorkloadNetworkDhcpEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return w.unmarshalInternal(rawMsg) +} + +func (w WorkloadNetworkDhcpEntity) marshalInternal(objectMap map[string]interface{}, discValue DhcpTypeEnum) { + w.DhcpType = &discValue + objectMap["dhcpType"] = w.DhcpType + populate(objectMap, "displayName", w.DisplayName) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "revision", w.Revision) + populate(objectMap, "segments", w.Segments) +} + +func (w *WorkloadNetworkDhcpEntity) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "dhcpType": + err = unpopulate(val, &w.DhcpType) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &w.DisplayName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &w.ProvisioningState) + delete(rawMsg, key) + case "revision": + err = unpopulate(val, &w.Revision) + delete(rawMsg, key) + case "segments": + err = unpopulate(val, &w.Segments) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// WorkloadNetworkDhcpList - A list of NSX dhcp entities +type WorkloadNetworkDhcpList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkDhcp `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDhcpList. +func (w WorkloadNetworkDhcpList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkDhcpRelay - NSX DHCP Relay +type WorkloadNetworkDhcpRelay struct { + WorkloadNetworkDhcpEntity + // DHCP Relay Addresses. Max 3. + ServerAddresses []*string `json:"serverAddresses,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDhcpRelay. +func (w WorkloadNetworkDhcpRelay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.WorkloadNetworkDhcpEntity.marshalInternal(objectMap, DhcpTypeEnumRELAY) + populate(objectMap, "serverAddresses", w.ServerAddresses) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkDhcpRelay. +func (w *WorkloadNetworkDhcpRelay) 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 "serverAddresses": + err = unpopulate(val, &w.ServerAddresses) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.WorkloadNetworkDhcpEntity.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkDhcpServer - NSX DHCP Server +type WorkloadNetworkDhcpServer struct { + WorkloadNetworkDhcpEntity + // DHCP Server Lease Time. + LeaseTime *int64 `json:"leaseTime,omitempty"` + + // DHCP Server Address. + ServerAddress *string `json:"serverAddress,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkDhcpServer. +func (w WorkloadNetworkDhcpServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.WorkloadNetworkDhcpEntity.marshalInternal(objectMap, DhcpTypeEnumSERVER) + populate(objectMap, "leaseTime", w.LeaseTime) + populate(objectMap, "serverAddress", w.ServerAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkDhcpServer. +func (w *WorkloadNetworkDhcpServer) 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 "leaseTime": + err = unpopulate(val, &w.LeaseTime) + delete(rawMsg, key) + case "serverAddress": + err = unpopulate(val, &w.ServerAddress) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.WorkloadNetworkDhcpEntity.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkGateway - NSX Gateway. +type WorkloadNetworkGateway struct { + ProxyResource + // Gateway properties. + Properties *WorkloadNetworkGatewayProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkGateway. +func (w WorkloadNetworkGateway) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkGateway. +func (w *WorkloadNetworkGateway) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkGatewayList - A list of NSX Gateways +type WorkloadNetworkGatewayList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkGateway `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkGatewayList. +func (w WorkloadNetworkGatewayList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkGatewayProperties - Properties of a NSX Gateway. +type WorkloadNetworkGatewayProperties struct { + // Display name of the DHCP entity. + DisplayName *string `json:"displayName,omitempty"` + + // READ-ONLY; NSX Gateway Path. + Path *string `json:"path,omitempty" azure:"ro"` +} + +// WorkloadNetworkPortMirroring - NSX Port Mirroring +type WorkloadNetworkPortMirroring struct { + ProxyResource + // Port Mirroring Properties. + Properties *WorkloadNetworkPortMirroringProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkPortMirroring. +func (w WorkloadNetworkPortMirroring) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkPortMirroring. +func (w *WorkloadNetworkPortMirroring) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkPortMirroringList - A list of NSX Port Mirroring +type WorkloadNetworkPortMirroringList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkPortMirroring `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkPortMirroringList. +func (w WorkloadNetworkPortMirroringList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkPortMirroringProperties - NSX Port Mirroring Properties +type WorkloadNetworkPortMirroringProperties struct { + // Destination VM Group. + Destination *string `json:"destination,omitempty"` + + // Direction of port mirroring profile. + Direction *PortMirroringDirectionEnum `json:"direction,omitempty"` + + // Display name of the port mirroring profile. + DisplayName *string `json:"displayName,omitempty"` + + // NSX revision number. + Revision *int64 `json:"revision,omitempty"` + + // Source VM Group. + Source *string `json:"source,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkPortMirroringProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Port Mirroring Status. + Status *PortMirroringStatusEnum `json:"status,omitempty" azure:"ro"` +} + +// WorkloadNetworkPublicIP - NSX Public IP Block +type WorkloadNetworkPublicIP struct { + ProxyResource + // Public IP Block properties + Properties *WorkloadNetworkPublicIPProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkPublicIP. +func (w WorkloadNetworkPublicIP) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkPublicIP. +func (w *WorkloadNetworkPublicIP) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkPublicIPProperties - NSX Public IP Block Properties +type WorkloadNetworkPublicIPProperties struct { + // Display name of the Public IP Block. + DisplayName *string `json:"displayName,omitempty"` + + // Number of Public IPs requested. + NumberOfPublicIPs *int64 `json:"numberOfPublicIPs,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkPublicIPProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; CIDR Block of the Public IP Block. + PublicIPBlock *string `json:"publicIPBlock,omitempty" azure:"ro"` +} + +// WorkloadNetworkPublicIPsList - A list of NSX Public IP Blocks +type WorkloadNetworkPublicIPsList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkPublicIP `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkPublicIPsList. +func (w WorkloadNetworkPublicIPsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkSegment - NSX Segment +type WorkloadNetworkSegment struct { + ProxyResource + // The properties of a Workload Segment proxy resource. + Properties *WorkloadNetworkSegmentProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkSegment. +func (w WorkloadNetworkSegment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkSegment. +func (w *WorkloadNetworkSegment) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkSegmentPortVif - Ports and any VIF attached to segment. +type WorkloadNetworkSegmentPortVif struct { + // Name of port or VIF attached to segment. + PortName *string `json:"portName,omitempty"` +} + +// WorkloadNetworkSegmentProperties - NSX Segment Properties +type WorkloadNetworkSegmentProperties struct { + // Gateway which to connect segment to. + ConnectedGateway *string `json:"connectedGateway,omitempty"` + + // Display name of the segment. + DisplayName *string `json:"displayName,omitempty"` + + // NSX revision number. + Revision *int64 `json:"revision,omitempty"` + + // Subnet which to connect segment to. + Subnet *WorkloadNetworkSegmentSubnet `json:"subnet,omitempty"` + + // READ-ONLY; Port Vif which segment is associated with. + PortVif []*WorkloadNetworkSegmentPortVif `json:"portVif,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkSegmentProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Segment status. + Status *SegmentStatusEnum `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkSegmentProperties. +func (w WorkloadNetworkSegmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "connectedGateway", w.ConnectedGateway) + populate(objectMap, "displayName", w.DisplayName) + populate(objectMap, "portVif", w.PortVif) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "revision", w.Revision) + populate(objectMap, "status", w.Status) + populate(objectMap, "subnet", w.Subnet) + return json.Marshal(objectMap) +} + +// WorkloadNetworkSegmentSubnet - Subnet configuration for segment +type WorkloadNetworkSegmentSubnet struct { + // DHCP Range assigned for subnet. + DhcpRanges []*string `json:"dhcpRanges,omitempty"` + + // Gateway address. + GatewayAddress *string `json:"gatewayAddress,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkSegmentSubnet. +func (w WorkloadNetworkSegmentSubnet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dhcpRanges", w.DhcpRanges) + populate(objectMap, "gatewayAddress", w.GatewayAddress) + return json.Marshal(objectMap) +} + +// WorkloadNetworkSegmentsList - A list of NSX Segments +type WorkloadNetworkSegmentsList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkSegment `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkSegmentsList. +func (w WorkloadNetworkSegmentsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkVMGroup - NSX VM Group +type WorkloadNetworkVMGroup struct { + ProxyResource + // VM Group properties. + Properties *WorkloadNetworkVMGroupProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkVMGroup. +func (w WorkloadNetworkVMGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkVMGroup. +func (w *WorkloadNetworkVMGroup) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkVMGroupProperties - NSX VM Group Properties +type WorkloadNetworkVMGroupProperties struct { + // Display name of the VM group. + DisplayName *string `json:"displayName,omitempty"` + + // Virtual machine members of this group. + Members []*string `json:"members,omitempty"` + + // NSX revision number. + Revision *int64 `json:"revision,omitempty"` + + // READ-ONLY; The provisioning state + ProvisioningState *WorkloadNetworkVMGroupProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; VM Group status. + Status *VMGroupStatusEnum `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkVMGroupProperties. +func (w WorkloadNetworkVMGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", w.DisplayName) + populate(objectMap, "members", w.Members) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "revision", w.Revision) + populate(objectMap, "status", w.Status) + return json.Marshal(objectMap) +} + +// WorkloadNetworkVMGroupsList - A list of NSX VM Groups +type WorkloadNetworkVMGroupsList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkVMGroup `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkVMGroupsList. +func (w WorkloadNetworkVMGroupsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworkVirtualMachine - NSX Virtual Machine +type WorkloadNetworkVirtualMachine struct { + ProxyResource + // Virtual machine properties. + Properties *WorkloadNetworkVirtualMachineProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkVirtualMachine. +func (w WorkloadNetworkVirtualMachine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + w.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadNetworkVirtualMachine. +func (w *WorkloadNetworkVirtualMachine) 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, &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := w.ProxyResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// WorkloadNetworkVirtualMachineProperties - NSX Virtual Machine Properties +type WorkloadNetworkVirtualMachineProperties struct { + // Display name of the VM. + DisplayName *string `json:"displayName,omitempty"` + + // READ-ONLY; Virtual machine type. + VMType *VMTypeEnum `json:"vmType,omitempty" azure:"ro"` +} + +// WorkloadNetworkVirtualMachinesList - A list of NSX Virtual Machines +type WorkloadNetworkVirtualMachinesList struct { + // READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The items on the page + Value []*WorkloadNetworkVirtualMachine `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadNetworkVirtualMachinesList. +func (w WorkloadNetworkVirtualMachinesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkloadNetworksBeginCreateDNSServiceOptions contains the optional parameters for the WorkloadNetworks.BeginCreateDNSService method. +type WorkloadNetworksBeginCreateDNSServiceOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginCreateDNSZoneOptions contains the optional parameters for the WorkloadNetworks.BeginCreateDNSZone method. +type WorkloadNetworksBeginCreateDNSZoneOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginCreateDhcpOptions contains the optional parameters for the WorkloadNetworks.BeginCreateDhcp method. +type WorkloadNetworksBeginCreateDhcpOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginCreatePortMirroringOptions contains the optional parameters for the WorkloadNetworks.BeginCreatePortMirroring method. +type WorkloadNetworksBeginCreatePortMirroringOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginCreatePublicIPOptions contains the optional parameters for the WorkloadNetworks.BeginCreatePublicIP method. +type WorkloadNetworksBeginCreatePublicIPOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginCreateSegmentsOptions contains the optional parameters for the WorkloadNetworks.BeginCreateSegments method. +type WorkloadNetworksBeginCreateSegmentsOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginCreateVMGroupOptions contains the optional parameters for the WorkloadNetworks.BeginCreateVMGroup method. +type WorkloadNetworksBeginCreateVMGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeleteDNSServiceOptions contains the optional parameters for the WorkloadNetworks.BeginDeleteDNSService method. +type WorkloadNetworksBeginDeleteDNSServiceOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeleteDNSZoneOptions contains the optional parameters for the WorkloadNetworks.BeginDeleteDNSZone method. +type WorkloadNetworksBeginDeleteDNSZoneOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeleteDhcpOptions contains the optional parameters for the WorkloadNetworks.BeginDeleteDhcp method. +type WorkloadNetworksBeginDeleteDhcpOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeletePortMirroringOptions contains the optional parameters for the WorkloadNetworks.BeginDeletePortMirroring method. +type WorkloadNetworksBeginDeletePortMirroringOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeletePublicIPOptions contains the optional parameters for the WorkloadNetworks.BeginDeletePublicIP method. +type WorkloadNetworksBeginDeletePublicIPOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeleteSegmentOptions contains the optional parameters for the WorkloadNetworks.BeginDeleteSegment method. +type WorkloadNetworksBeginDeleteSegmentOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginDeleteVMGroupOptions contains the optional parameters for the WorkloadNetworks.BeginDeleteVMGroup method. +type WorkloadNetworksBeginDeleteVMGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginUpdateDNSServiceOptions contains the optional parameters for the WorkloadNetworks.BeginUpdateDNSService method. +type WorkloadNetworksBeginUpdateDNSServiceOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginUpdateDNSZoneOptions contains the optional parameters for the WorkloadNetworks.BeginUpdateDNSZone method. +type WorkloadNetworksBeginUpdateDNSZoneOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginUpdateDhcpOptions contains the optional parameters for the WorkloadNetworks.BeginUpdateDhcp method. +type WorkloadNetworksBeginUpdateDhcpOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginUpdatePortMirroringOptions contains the optional parameters for the WorkloadNetworks.BeginUpdatePortMirroring method. +type WorkloadNetworksBeginUpdatePortMirroringOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginUpdateSegmentsOptions contains the optional parameters for the WorkloadNetworks.BeginUpdateSegments method. +type WorkloadNetworksBeginUpdateSegmentsOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksBeginUpdateVMGroupOptions contains the optional parameters for the WorkloadNetworks.BeginUpdateVMGroup method. +type WorkloadNetworksBeginUpdateVMGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetDNSServiceOptions contains the optional parameters for the WorkloadNetworks.GetDNSService method. +type WorkloadNetworksGetDNSServiceOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetDNSZoneOptions contains the optional parameters for the WorkloadNetworks.GetDNSZone method. +type WorkloadNetworksGetDNSZoneOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetDhcpOptions contains the optional parameters for the WorkloadNetworks.GetDhcp method. +type WorkloadNetworksGetDhcpOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetGatewayOptions contains the optional parameters for the WorkloadNetworks.GetGateway method. +type WorkloadNetworksGetGatewayOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetPortMirroringOptions contains the optional parameters for the WorkloadNetworks.GetPortMirroring method. +type WorkloadNetworksGetPortMirroringOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetPublicIPOptions contains the optional parameters for the WorkloadNetworks.GetPublicIP method. +type WorkloadNetworksGetPublicIPOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetSegmentOptions contains the optional parameters for the WorkloadNetworks.GetSegment method. +type WorkloadNetworksGetSegmentOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetVMGroupOptions contains the optional parameters for the WorkloadNetworks.GetVMGroup method. +type WorkloadNetworksGetVMGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksGetVirtualMachineOptions contains the optional parameters for the WorkloadNetworks.GetVirtualMachine method. +type WorkloadNetworksGetVirtualMachineOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListDNSServicesOptions contains the optional parameters for the WorkloadNetworks.ListDNSServices method. +type WorkloadNetworksListDNSServicesOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListDNSZonesOptions contains the optional parameters for the WorkloadNetworks.ListDNSZones method. +type WorkloadNetworksListDNSZonesOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListDhcpOptions contains the optional parameters for the WorkloadNetworks.ListDhcp method. +type WorkloadNetworksListDhcpOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListGatewaysOptions contains the optional parameters for the WorkloadNetworks.ListGateways method. +type WorkloadNetworksListGatewaysOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListPortMirroringOptions contains the optional parameters for the WorkloadNetworks.ListPortMirroring method. +type WorkloadNetworksListPortMirroringOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListPublicIPsOptions contains the optional parameters for the WorkloadNetworks.ListPublicIPs method. +type WorkloadNetworksListPublicIPsOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListSegmentsOptions contains the optional parameters for the WorkloadNetworks.ListSegments method. +type WorkloadNetworksListSegmentsOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListVMGroupsOptions contains the optional parameters for the WorkloadNetworks.ListVMGroups method. +type WorkloadNetworksListVMGroupsOptions struct { + // placeholder for future optional parameters +} + +// WorkloadNetworksListVirtualMachinesOptions contains the optional parameters for the WorkloadNetworks.ListVirtualMachines method. +type WorkloadNetworksListVirtualMachinesOptions struct { + // placeholder for future optional parameters +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_operations_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_operations_client.go new file mode 100644 index 000000000000..0e39149fb1b5 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/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 armavs + +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 all of the available operations +// 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.OperationList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AVS/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-12-01") + 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.OperationList); 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/avs/armavs/zz_generated_pagers.go b/sdk/resourcemanager/avs/armavs/zz_generated_pagers.go new file mode 100644 index 000000000000..480db93b18c5 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_pagers.go @@ -0,0 +1,1313 @@ +//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 armavs + +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" +) + +// AddonsListPager provides operations for iterating over paged responses. +type AddonsListPager struct { + client *AddonsClient + current AddonsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AddonsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AddonsListPager) 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 *AddonsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AddonList.NextLink == nil || len(*p.current.AddonList.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 AddonsListResponse page. +func (p *AddonsListPager) PageResponse() AddonsListResponse { + return p.current +} + +// AuthorizationsListPager provides operations for iterating over paged responses. +type AuthorizationsListPager struct { + client *AuthorizationsClient + current AuthorizationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AuthorizationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AuthorizationsListPager) 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 *AuthorizationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExpressRouteAuthorizationList.NextLink == nil || len(*p.current.ExpressRouteAuthorizationList.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 AuthorizationsListResponse page. +func (p *AuthorizationsListPager) PageResponse() AuthorizationsListResponse { + return p.current +} + +// CloudLinksListPager provides operations for iterating over paged responses. +type CloudLinksListPager struct { + client *CloudLinksClient + current CloudLinksListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CloudLinksListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CloudLinksListPager) 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 *CloudLinksListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CloudLinkList.NextLink == nil || len(*p.current.CloudLinkList.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 CloudLinksListResponse page. +func (p *CloudLinksListPager) PageResponse() CloudLinksListResponse { + return p.current +} + +// ClustersListPager provides operations for iterating over paged responses. +type ClustersListPager struct { + client *ClustersClient + current ClustersListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ClustersListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ClustersListPager) 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 *ClustersListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ClusterList.NextLink == nil || len(*p.current.ClusterList.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 ClustersListResponse page. +func (p *ClustersListPager) PageResponse() ClustersListResponse { + return p.current +} + +// DatastoresListPager provides operations for iterating over paged responses. +type DatastoresListPager struct { + client *DatastoresClient + current DatastoresListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, DatastoresListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *DatastoresListPager) 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 *DatastoresListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DatastoreList.NextLink == nil || len(*p.current.DatastoreList.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 DatastoresListResponse page. +func (p *DatastoresListPager) PageResponse() DatastoresListResponse { + return p.current +} + +// GlobalReachConnectionsListPager provides operations for iterating over paged responses. +type GlobalReachConnectionsListPager struct { + client *GlobalReachConnectionsClient + current GlobalReachConnectionsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, GlobalReachConnectionsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *GlobalReachConnectionsListPager) 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 *GlobalReachConnectionsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GlobalReachConnectionList.NextLink == nil || len(*p.current.GlobalReachConnectionList.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 GlobalReachConnectionsListResponse page. +func (p *GlobalReachConnectionsListPager) PageResponse() GlobalReachConnectionsListResponse { + return p.current +} + +// HcxEnterpriseSitesListPager provides operations for iterating over paged responses. +type HcxEnterpriseSitesListPager struct { + client *HcxEnterpriseSitesClient + current HcxEnterpriseSitesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, HcxEnterpriseSitesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *HcxEnterpriseSitesListPager) 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 *HcxEnterpriseSitesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.HcxEnterpriseSiteList.NextLink == nil || len(*p.current.HcxEnterpriseSiteList.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 HcxEnterpriseSitesListResponse page. +func (p *HcxEnterpriseSitesListPager) PageResponse() HcxEnterpriseSitesListResponse { + 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.OperationList.NextLink == nil || len(*p.current.OperationList.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 +} + +// PlacementPoliciesListPager provides operations for iterating over paged responses. +type PlacementPoliciesListPager struct { + client *PlacementPoliciesClient + current PlacementPoliciesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PlacementPoliciesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PlacementPoliciesListPager) 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 *PlacementPoliciesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PlacementPoliciesList.NextLink == nil || len(*p.current.PlacementPoliciesList.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 PlacementPoliciesListResponse page. +func (p *PlacementPoliciesListPager) PageResponse() PlacementPoliciesListResponse { + return p.current +} + +// PrivateCloudsListInSubscriptionPager provides operations for iterating over paged responses. +type PrivateCloudsListInSubscriptionPager struct { + client *PrivateCloudsClient + current PrivateCloudsListInSubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrivateCloudsListInSubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrivateCloudsListInSubscriptionPager) 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 *PrivateCloudsListInSubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateCloudList.NextLink == nil || len(*p.current.PrivateCloudList.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.listInSubscriptionHandleError(resp) + return false + } + result, err := p.client.listInSubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PrivateCloudsListInSubscriptionResponse page. +func (p *PrivateCloudsListInSubscriptionPager) PageResponse() PrivateCloudsListInSubscriptionResponse { + return p.current +} + +// PrivateCloudsListPager provides operations for iterating over paged responses. +type PrivateCloudsListPager struct { + client *PrivateCloudsClient + current PrivateCloudsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrivateCloudsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrivateCloudsListPager) 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 *PrivateCloudsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateCloudList.NextLink == nil || len(*p.current.PrivateCloudList.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 PrivateCloudsListResponse page. +func (p *PrivateCloudsListPager) PageResponse() PrivateCloudsListResponse { + return p.current +} + +// ScriptCmdletsListPager provides operations for iterating over paged responses. +type ScriptCmdletsListPager struct { + client *ScriptCmdletsClient + current ScriptCmdletsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ScriptCmdletsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ScriptCmdletsListPager) 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 *ScriptCmdletsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ScriptCmdletsList.NextLink == nil || len(*p.current.ScriptCmdletsList.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 ScriptCmdletsListResponse page. +func (p *ScriptCmdletsListPager) PageResponse() ScriptCmdletsListResponse { + return p.current +} + +// ScriptExecutionsListPager provides operations for iterating over paged responses. +type ScriptExecutionsListPager struct { + client *ScriptExecutionsClient + current ScriptExecutionsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ScriptExecutionsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ScriptExecutionsListPager) 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 *ScriptExecutionsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ScriptExecutionsList.NextLink == nil || len(*p.current.ScriptExecutionsList.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 ScriptExecutionsListResponse page. +func (p *ScriptExecutionsListPager) PageResponse() ScriptExecutionsListResponse { + return p.current +} + +// ScriptPackagesListPager provides operations for iterating over paged responses. +type ScriptPackagesListPager struct { + client *ScriptPackagesClient + current ScriptPackagesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ScriptPackagesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ScriptPackagesListPager) 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 *ScriptPackagesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ScriptPackagesList.NextLink == nil || len(*p.current.ScriptPackagesList.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 ScriptPackagesListResponse page. +func (p *ScriptPackagesListPager) PageResponse() ScriptPackagesListResponse { + return p.current +} + +// VirtualMachinesListPager provides operations for iterating over paged responses. +type VirtualMachinesListPager struct { + client *VirtualMachinesClient + current VirtualMachinesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, VirtualMachinesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *VirtualMachinesListPager) 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 *VirtualMachinesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.VirtualMachinesList.NextLink == nil || len(*p.current.VirtualMachinesList.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 VirtualMachinesListResponse page. +func (p *VirtualMachinesListPager) PageResponse() VirtualMachinesListResponse { + return p.current +} + +// WorkloadNetworksListDNSServicesPager provides operations for iterating over paged responses. +type WorkloadNetworksListDNSServicesPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListDNSServicesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListDNSServicesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListDNSServicesPager) 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 *WorkloadNetworksListDNSServicesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkDNSServicesList.NextLink == nil || len(*p.current.WorkloadNetworkDNSServicesList.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.listDNSServicesHandleError(resp) + return false + } + result, err := p.client.listDNSServicesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListDNSServicesResponse page. +func (p *WorkloadNetworksListDNSServicesPager) PageResponse() WorkloadNetworksListDNSServicesResponse { + return p.current +} + +// WorkloadNetworksListDNSZonesPager provides operations for iterating over paged responses. +type WorkloadNetworksListDNSZonesPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListDNSZonesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListDNSZonesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListDNSZonesPager) 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 *WorkloadNetworksListDNSZonesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkDNSZonesList.NextLink == nil || len(*p.current.WorkloadNetworkDNSZonesList.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.listDNSZonesHandleError(resp) + return false + } + result, err := p.client.listDNSZonesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListDNSZonesResponse page. +func (p *WorkloadNetworksListDNSZonesPager) PageResponse() WorkloadNetworksListDNSZonesResponse { + return p.current +} + +// WorkloadNetworksListDhcpPager provides operations for iterating over paged responses. +type WorkloadNetworksListDhcpPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListDhcpResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListDhcpResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListDhcpPager) 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 *WorkloadNetworksListDhcpPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkDhcpList.NextLink == nil || len(*p.current.WorkloadNetworkDhcpList.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.listDhcpHandleError(resp) + return false + } + result, err := p.client.listDhcpHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListDhcpResponse page. +func (p *WorkloadNetworksListDhcpPager) PageResponse() WorkloadNetworksListDhcpResponse { + return p.current +} + +// WorkloadNetworksListGatewaysPager provides operations for iterating over paged responses. +type WorkloadNetworksListGatewaysPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListGatewaysResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListGatewaysResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListGatewaysPager) 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 *WorkloadNetworksListGatewaysPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkGatewayList.NextLink == nil || len(*p.current.WorkloadNetworkGatewayList.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.listGatewaysHandleError(resp) + return false + } + result, err := p.client.listGatewaysHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListGatewaysResponse page. +func (p *WorkloadNetworksListGatewaysPager) PageResponse() WorkloadNetworksListGatewaysResponse { + return p.current +} + +// WorkloadNetworksListPortMirroringPager provides operations for iterating over paged responses. +type WorkloadNetworksListPortMirroringPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListPortMirroringResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListPortMirroringResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListPortMirroringPager) 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 *WorkloadNetworksListPortMirroringPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkPortMirroringList.NextLink == nil || len(*p.current.WorkloadNetworkPortMirroringList.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.listPortMirroringHandleError(resp) + return false + } + result, err := p.client.listPortMirroringHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListPortMirroringResponse page. +func (p *WorkloadNetworksListPortMirroringPager) PageResponse() WorkloadNetworksListPortMirroringResponse { + return p.current +} + +// WorkloadNetworksListPublicIPsPager provides operations for iterating over paged responses. +type WorkloadNetworksListPublicIPsPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListPublicIPsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListPublicIPsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListPublicIPsPager) 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 *WorkloadNetworksListPublicIPsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkPublicIPsList.NextLink == nil || len(*p.current.WorkloadNetworkPublicIPsList.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.listPublicIPsHandleError(resp) + return false + } + result, err := p.client.listPublicIPsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListPublicIPsResponse page. +func (p *WorkloadNetworksListPublicIPsPager) PageResponse() WorkloadNetworksListPublicIPsResponse { + return p.current +} + +// WorkloadNetworksListSegmentsPager provides operations for iterating over paged responses. +type WorkloadNetworksListSegmentsPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListSegmentsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListSegmentsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListSegmentsPager) 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 *WorkloadNetworksListSegmentsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkSegmentsList.NextLink == nil || len(*p.current.WorkloadNetworkSegmentsList.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.listSegmentsHandleError(resp) + return false + } + result, err := p.client.listSegmentsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListSegmentsResponse page. +func (p *WorkloadNetworksListSegmentsPager) PageResponse() WorkloadNetworksListSegmentsResponse { + return p.current +} + +// WorkloadNetworksListVMGroupsPager provides operations for iterating over paged responses. +type WorkloadNetworksListVMGroupsPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListVMGroupsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListVMGroupsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListVMGroupsPager) 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 *WorkloadNetworksListVMGroupsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkVMGroupsList.NextLink == nil || len(*p.current.WorkloadNetworkVMGroupsList.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.listVMGroupsHandleError(resp) + return false + } + result, err := p.client.listVMGroupsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListVMGroupsResponse page. +func (p *WorkloadNetworksListVMGroupsPager) PageResponse() WorkloadNetworksListVMGroupsResponse { + return p.current +} + +// WorkloadNetworksListVirtualMachinesPager provides operations for iterating over paged responses. +type WorkloadNetworksListVirtualMachinesPager struct { + client *WorkloadNetworksClient + current WorkloadNetworksListVirtualMachinesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, WorkloadNetworksListVirtualMachinesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *WorkloadNetworksListVirtualMachinesPager) 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 *WorkloadNetworksListVirtualMachinesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WorkloadNetworkVirtualMachinesList.NextLink == nil || len(*p.current.WorkloadNetworkVirtualMachinesList.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.listVirtualMachinesHandleError(resp) + return false + } + result, err := p.client.listVirtualMachinesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current WorkloadNetworksListVirtualMachinesResponse page. +func (p *WorkloadNetworksListVirtualMachinesPager) PageResponse() WorkloadNetworksListVirtualMachinesResponse { + return p.current +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_placementpolicies_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_placementpolicies_client.go new file mode 100644 index 000000000000..1516749c6d36 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_placementpolicies_client.go @@ -0,0 +1,434 @@ +//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 armavs + +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" +) + +// PlacementPoliciesClient contains the methods for the PlacementPolicies group. +// Don't use this type directly, use NewPlacementPoliciesClient() instead. +type PlacementPoliciesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPlacementPoliciesClient creates a new instance of PlacementPoliciesClient with the specified values. +func NewPlacementPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PlacementPoliciesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PlacementPoliciesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a placement policy in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, placementPolicy PlacementPolicy, options *PlacementPoliciesBeginCreateOrUpdateOptions) (PlacementPoliciesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, placementPolicy, options) + if err != nil { + return PlacementPoliciesCreateOrUpdatePollerResponse{}, err + } + result := PlacementPoliciesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PlacementPoliciesClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return PlacementPoliciesCreateOrUpdatePollerResponse{}, err + } + result.Poller = &PlacementPoliciesCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a placement policy in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, placementPolicy PlacementPolicy, options *PlacementPoliciesBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, placementPolicy, 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 *PlacementPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, placementPolicy PlacementPolicy, options *PlacementPoliciesBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if placementPolicyName == "" { + return nil, errors.New("parameter placementPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{placementPolicyName}", url.PathEscape(placementPolicyName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, placementPolicy) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PlacementPoliciesClient) 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 - Delete a placement policy in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, options *PlacementPoliciesBeginDeleteOptions) (PlacementPoliciesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, options) + if err != nil { + return PlacementPoliciesDeletePollerResponse{}, err + } + result := PlacementPoliciesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PlacementPoliciesClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return PlacementPoliciesDeletePollerResponse{}, err + } + result.Poller = &PlacementPoliciesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a placement policy in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, options *PlacementPoliciesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, 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 *PlacementPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, options *PlacementPoliciesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if placementPolicyName == "" { + return nil, errors.New("parameter placementPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{placementPolicyName}", url.PathEscape(placementPolicyName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PlacementPoliciesClient) 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 - Get a placement policy by name in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, options *PlacementPoliciesGetOptions) (PlacementPoliciesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, options) + if err != nil { + return PlacementPoliciesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PlacementPoliciesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PlacementPoliciesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PlacementPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, options *PlacementPoliciesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if placementPolicyName == "" { + return nil, errors.New("parameter placementPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{placementPolicyName}", url.PathEscape(placementPolicyName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PlacementPoliciesClient) getHandleResponse(resp *http.Response) (PlacementPoliciesGetResponse, error) { + result := PlacementPoliciesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PlacementPolicy); err != nil { + return PlacementPoliciesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PlacementPoliciesClient) 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 - List placement policies in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) List(resourceGroupName string, privateCloudName string, clusterName string, options *PlacementPoliciesListOptions) *PlacementPoliciesListPager { + return &PlacementPoliciesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, options) + }, + advancer: func(ctx context.Context, resp PlacementPoliciesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PlacementPoliciesList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PlacementPoliciesClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, options *PlacementPoliciesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PlacementPoliciesClient) listHandleResponse(resp *http.Response) (PlacementPoliciesListResponse, error) { + result := PlacementPoliciesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PlacementPoliciesList); err != nil { + return PlacementPoliciesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PlacementPoliciesClient) 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 - Update a placement policy in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) BeginUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, placementPolicyUpdate PlacementPolicyUpdate, options *PlacementPoliciesBeginUpdateOptions) (PlacementPoliciesUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, placementPolicyUpdate, options) + if err != nil { + return PlacementPoliciesUpdatePollerResponse{}, err + } + result := PlacementPoliciesUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PlacementPoliciesClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return PlacementPoliciesUpdatePollerResponse{}, err + } + result.Poller = &PlacementPoliciesUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Update a placement policy in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *PlacementPoliciesClient) update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, placementPolicyUpdate PlacementPolicyUpdate, options *PlacementPoliciesBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, placementPolicyName, placementPolicyUpdate, 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 *PlacementPoliciesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, placementPolicyName string, placementPolicyUpdate PlacementPolicyUpdate, options *PlacementPoliciesBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if placementPolicyName == "" { + return nil, errors.New("parameter placementPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{placementPolicyName}", url.PathEscape(placementPolicyName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, placementPolicyUpdate) +} + +// updateHandleError handles the Update error response. +func (client *PlacementPoliciesClient) 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/avs/armavs/zz_generated_pollers.go b/sdk/resourcemanager/avs/armavs/zz_generated_pollers.go new file mode 100644 index 000000000000..8753431067d4 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_pollers.go @@ -0,0 +1,1907 @@ +//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 armavs + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// AddonsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type AddonsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *AddonsCreateOrUpdatePoller) 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 *AddonsCreateOrUpdatePoller) 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 AddonsCreateOrUpdateResponse will be returned. +func (p *AddonsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (AddonsCreateOrUpdateResponse, error) { + respType := AddonsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Addon) + if err != nil { + return AddonsCreateOrUpdateResponse{}, 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 *AddonsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// AddonsDeletePoller provides polling facilities until the operation reaches a terminal state. +type AddonsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *AddonsDeletePoller) 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 *AddonsDeletePoller) 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 AddonsDeleteResponse will be returned. +func (p *AddonsDeletePoller) FinalResponse(ctx context.Context) (AddonsDeleteResponse, error) { + respType := AddonsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return AddonsDeleteResponse{}, 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 *AddonsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// AuthorizationsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type AuthorizationsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *AuthorizationsCreateOrUpdatePoller) 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 *AuthorizationsCreateOrUpdatePoller) 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 AuthorizationsCreateOrUpdateResponse will be returned. +func (p *AuthorizationsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (AuthorizationsCreateOrUpdateResponse, error) { + respType := AuthorizationsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ExpressRouteAuthorization) + if err != nil { + return AuthorizationsCreateOrUpdateResponse{}, 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 *AuthorizationsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// AuthorizationsDeletePoller provides polling facilities until the operation reaches a terminal state. +type AuthorizationsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *AuthorizationsDeletePoller) 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 *AuthorizationsDeletePoller) 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 AuthorizationsDeleteResponse will be returned. +func (p *AuthorizationsDeletePoller) FinalResponse(ctx context.Context) (AuthorizationsDeleteResponse, error) { + respType := AuthorizationsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return AuthorizationsDeleteResponse{}, 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 *AuthorizationsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CloudLinksCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type CloudLinksCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CloudLinksCreateOrUpdatePoller) 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 *CloudLinksCreateOrUpdatePoller) 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 CloudLinksCreateOrUpdateResponse will be returned. +func (p *CloudLinksCreateOrUpdatePoller) FinalResponse(ctx context.Context) (CloudLinksCreateOrUpdateResponse, error) { + respType := CloudLinksCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.CloudLink) + if err != nil { + return CloudLinksCreateOrUpdateResponse{}, 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 *CloudLinksCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CloudLinksDeletePoller provides polling facilities until the operation reaches a terminal state. +type CloudLinksDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CloudLinksDeletePoller) 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 *CloudLinksDeletePoller) 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 CloudLinksDeleteResponse will be returned. +func (p *CloudLinksDeletePoller) FinalResponse(ctx context.Context) (CloudLinksDeleteResponse, error) { + respType := CloudLinksDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CloudLinksDeleteResponse{}, 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 *CloudLinksDeletePoller) 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() +} + +// 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() +} + +// DatastoresCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DatastoresCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatastoresCreateOrUpdatePoller) 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 *DatastoresCreateOrUpdatePoller) 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 DatastoresCreateOrUpdateResponse will be returned. +func (p *DatastoresCreateOrUpdatePoller) FinalResponse(ctx context.Context) (DatastoresCreateOrUpdateResponse, error) { + respType := DatastoresCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Datastore) + if err != nil { + return DatastoresCreateOrUpdateResponse{}, 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 *DatastoresCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DatastoresDeletePoller provides polling facilities until the operation reaches a terminal state. +type DatastoresDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DatastoresDeletePoller) 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 *DatastoresDeletePoller) 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 DatastoresDeleteResponse will be returned. +func (p *DatastoresDeletePoller) FinalResponse(ctx context.Context) (DatastoresDeleteResponse, error) { + respType := DatastoresDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return DatastoresDeleteResponse{}, 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 *DatastoresDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// GlobalReachConnectionsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type GlobalReachConnectionsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *GlobalReachConnectionsCreateOrUpdatePoller) 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 *GlobalReachConnectionsCreateOrUpdatePoller) 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 GlobalReachConnectionsCreateOrUpdateResponse will be returned. +func (p *GlobalReachConnectionsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (GlobalReachConnectionsCreateOrUpdateResponse, error) { + respType := GlobalReachConnectionsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.GlobalReachConnection) + if err != nil { + return GlobalReachConnectionsCreateOrUpdateResponse{}, 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 *GlobalReachConnectionsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// GlobalReachConnectionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type GlobalReachConnectionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *GlobalReachConnectionsDeletePoller) 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 *GlobalReachConnectionsDeletePoller) 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 GlobalReachConnectionsDeleteResponse will be returned. +func (p *GlobalReachConnectionsDeletePoller) FinalResponse(ctx context.Context) (GlobalReachConnectionsDeleteResponse, error) { + respType := GlobalReachConnectionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return GlobalReachConnectionsDeleteResponse{}, 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 *GlobalReachConnectionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PlacementPoliciesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PlacementPoliciesCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PlacementPoliciesCreateOrUpdatePoller) 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 *PlacementPoliciesCreateOrUpdatePoller) 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 PlacementPoliciesCreateOrUpdateResponse will be returned. +func (p *PlacementPoliciesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (PlacementPoliciesCreateOrUpdateResponse, error) { + respType := PlacementPoliciesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PlacementPolicy) + if err != nil { + return PlacementPoliciesCreateOrUpdateResponse{}, 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 *PlacementPoliciesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PlacementPoliciesDeletePoller provides polling facilities until the operation reaches a terminal state. +type PlacementPoliciesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PlacementPoliciesDeletePoller) 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 *PlacementPoliciesDeletePoller) 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 PlacementPoliciesDeleteResponse will be returned. +func (p *PlacementPoliciesDeletePoller) FinalResponse(ctx context.Context) (PlacementPoliciesDeleteResponse, error) { + respType := PlacementPoliciesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PlacementPoliciesDeleteResponse{}, 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 *PlacementPoliciesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PlacementPoliciesUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PlacementPoliciesUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PlacementPoliciesUpdatePoller) 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 *PlacementPoliciesUpdatePoller) 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 PlacementPoliciesUpdateResponse will be returned. +func (p *PlacementPoliciesUpdatePoller) FinalResponse(ctx context.Context) (PlacementPoliciesUpdateResponse, error) { + respType := PlacementPoliciesUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PlacementPolicy) + if err != nil { + return PlacementPoliciesUpdateResponse{}, 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 *PlacementPoliciesUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateCloudsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PrivateCloudsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateCloudsCreateOrUpdatePoller) 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 *PrivateCloudsCreateOrUpdatePoller) 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 PrivateCloudsCreateOrUpdateResponse will be returned. +func (p *PrivateCloudsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (PrivateCloudsCreateOrUpdateResponse, error) { + respType := PrivateCloudsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PrivateCloud) + if err != nil { + return PrivateCloudsCreateOrUpdateResponse{}, 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 *PrivateCloudsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateCloudsDeletePoller provides polling facilities until the operation reaches a terminal state. +type PrivateCloudsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateCloudsDeletePoller) 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 *PrivateCloudsDeletePoller) 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 PrivateCloudsDeleteResponse will be returned. +func (p *PrivateCloudsDeletePoller) FinalResponse(ctx context.Context) (PrivateCloudsDeleteResponse, error) { + respType := PrivateCloudsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PrivateCloudsDeleteResponse{}, 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 *PrivateCloudsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateCloudsRotateNsxtPasswordPoller provides polling facilities until the operation reaches a terminal state. +type PrivateCloudsRotateNsxtPasswordPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateCloudsRotateNsxtPasswordPoller) 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 *PrivateCloudsRotateNsxtPasswordPoller) 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 PrivateCloudsRotateNsxtPasswordResponse will be returned. +func (p *PrivateCloudsRotateNsxtPasswordPoller) FinalResponse(ctx context.Context) (PrivateCloudsRotateNsxtPasswordResponse, error) { + respType := PrivateCloudsRotateNsxtPasswordResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PrivateCloudsRotateNsxtPasswordResponse{}, 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 *PrivateCloudsRotateNsxtPasswordPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateCloudsRotateVcenterPasswordPoller provides polling facilities until the operation reaches a terminal state. +type PrivateCloudsRotateVcenterPasswordPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateCloudsRotateVcenterPasswordPoller) 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 *PrivateCloudsRotateVcenterPasswordPoller) 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 PrivateCloudsRotateVcenterPasswordResponse will be returned. +func (p *PrivateCloudsRotateVcenterPasswordPoller) FinalResponse(ctx context.Context) (PrivateCloudsRotateVcenterPasswordResponse, error) { + respType := PrivateCloudsRotateVcenterPasswordResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PrivateCloudsRotateVcenterPasswordResponse{}, 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 *PrivateCloudsRotateVcenterPasswordPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateCloudsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PrivateCloudsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateCloudsUpdatePoller) 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 *PrivateCloudsUpdatePoller) 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 PrivateCloudsUpdateResponse will be returned. +func (p *PrivateCloudsUpdatePoller) FinalResponse(ctx context.Context) (PrivateCloudsUpdateResponse, error) { + respType := PrivateCloudsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PrivateCloud) + if err != nil { + return PrivateCloudsUpdateResponse{}, 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 *PrivateCloudsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ScriptExecutionsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ScriptExecutionsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ScriptExecutionsCreateOrUpdatePoller) 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 *ScriptExecutionsCreateOrUpdatePoller) 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 ScriptExecutionsCreateOrUpdateResponse will be returned. +func (p *ScriptExecutionsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ScriptExecutionsCreateOrUpdateResponse, error) { + respType := ScriptExecutionsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ScriptExecution) + if err != nil { + return ScriptExecutionsCreateOrUpdateResponse{}, 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 *ScriptExecutionsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ScriptExecutionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ScriptExecutionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ScriptExecutionsDeletePoller) 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 *ScriptExecutionsDeletePoller) 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 ScriptExecutionsDeleteResponse will be returned. +func (p *ScriptExecutionsDeletePoller) FinalResponse(ctx context.Context) (ScriptExecutionsDeleteResponse, error) { + respType := ScriptExecutionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ScriptExecutionsDeleteResponse{}, 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 *ScriptExecutionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VirtualMachinesRestrictMovementPoller provides polling facilities until the operation reaches a terminal state. +type VirtualMachinesRestrictMovementPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VirtualMachinesRestrictMovementPoller) 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 *VirtualMachinesRestrictMovementPoller) 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 VirtualMachinesRestrictMovementResponse will be returned. +func (p *VirtualMachinesRestrictMovementPoller) FinalResponse(ctx context.Context) (VirtualMachinesRestrictMovementResponse, error) { + respType := VirtualMachinesRestrictMovementResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VirtualMachinesRestrictMovementResponse{}, 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 *VirtualMachinesRestrictMovementPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreateDNSServicePoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreateDNSServicePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreateDNSServicePoller) 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 *WorkloadNetworksCreateDNSServicePoller) 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 WorkloadNetworksCreateDNSServiceResponse will be returned. +func (p *WorkloadNetworksCreateDNSServicePoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreateDNSServiceResponse, error) { + respType := WorkloadNetworksCreateDNSServiceResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkDNSService) + if err != nil { + return WorkloadNetworksCreateDNSServiceResponse{}, 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 *WorkloadNetworksCreateDNSServicePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreateDNSZonePoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreateDNSZonePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreateDNSZonePoller) 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 *WorkloadNetworksCreateDNSZonePoller) 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 WorkloadNetworksCreateDNSZoneResponse will be returned. +func (p *WorkloadNetworksCreateDNSZonePoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreateDNSZoneResponse, error) { + respType := WorkloadNetworksCreateDNSZoneResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkDNSZone) + if err != nil { + return WorkloadNetworksCreateDNSZoneResponse{}, 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 *WorkloadNetworksCreateDNSZonePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreateDhcpPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreateDhcpPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreateDhcpPoller) 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 *WorkloadNetworksCreateDhcpPoller) 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 WorkloadNetworksCreateDhcpResponse will be returned. +func (p *WorkloadNetworksCreateDhcpPoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreateDhcpResponse, error) { + respType := WorkloadNetworksCreateDhcpResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkDhcp) + if err != nil { + return WorkloadNetworksCreateDhcpResponse{}, 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 *WorkloadNetworksCreateDhcpPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreatePortMirroringPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreatePortMirroringPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreatePortMirroringPoller) 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 *WorkloadNetworksCreatePortMirroringPoller) 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 WorkloadNetworksCreatePortMirroringResponse will be returned. +func (p *WorkloadNetworksCreatePortMirroringPoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreatePortMirroringResponse, error) { + respType := WorkloadNetworksCreatePortMirroringResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkPortMirroring) + if err != nil { + return WorkloadNetworksCreatePortMirroringResponse{}, 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 *WorkloadNetworksCreatePortMirroringPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreatePublicIPPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreatePublicIPPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreatePublicIPPoller) 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 *WorkloadNetworksCreatePublicIPPoller) 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 WorkloadNetworksCreatePublicIPResponse will be returned. +func (p *WorkloadNetworksCreatePublicIPPoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreatePublicIPResponse, error) { + respType := WorkloadNetworksCreatePublicIPResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkPublicIP) + if err != nil { + return WorkloadNetworksCreatePublicIPResponse{}, 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 *WorkloadNetworksCreatePublicIPPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreateSegmentsPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreateSegmentsPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreateSegmentsPoller) 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 *WorkloadNetworksCreateSegmentsPoller) 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 WorkloadNetworksCreateSegmentsResponse will be returned. +func (p *WorkloadNetworksCreateSegmentsPoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreateSegmentsResponse, error) { + respType := WorkloadNetworksCreateSegmentsResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkSegment) + if err != nil { + return WorkloadNetworksCreateSegmentsResponse{}, 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 *WorkloadNetworksCreateSegmentsPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksCreateVMGroupPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksCreateVMGroupPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksCreateVMGroupPoller) 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 *WorkloadNetworksCreateVMGroupPoller) 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 WorkloadNetworksCreateVMGroupResponse will be returned. +func (p *WorkloadNetworksCreateVMGroupPoller) FinalResponse(ctx context.Context) (WorkloadNetworksCreateVMGroupResponse, error) { + respType := WorkloadNetworksCreateVMGroupResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkVMGroup) + if err != nil { + return WorkloadNetworksCreateVMGroupResponse{}, 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 *WorkloadNetworksCreateVMGroupPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeleteDNSServicePoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeleteDNSServicePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeleteDNSServicePoller) 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 *WorkloadNetworksDeleteDNSServicePoller) 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 WorkloadNetworksDeleteDNSServiceResponse will be returned. +func (p *WorkloadNetworksDeleteDNSServicePoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeleteDNSServiceResponse, error) { + respType := WorkloadNetworksDeleteDNSServiceResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeleteDNSServiceResponse{}, 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 *WorkloadNetworksDeleteDNSServicePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeleteDNSZonePoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeleteDNSZonePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeleteDNSZonePoller) 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 *WorkloadNetworksDeleteDNSZonePoller) 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 WorkloadNetworksDeleteDNSZoneResponse will be returned. +func (p *WorkloadNetworksDeleteDNSZonePoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeleteDNSZoneResponse, error) { + respType := WorkloadNetworksDeleteDNSZoneResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeleteDNSZoneResponse{}, 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 *WorkloadNetworksDeleteDNSZonePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeleteDhcpPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeleteDhcpPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeleteDhcpPoller) 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 *WorkloadNetworksDeleteDhcpPoller) 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 WorkloadNetworksDeleteDhcpResponse will be returned. +func (p *WorkloadNetworksDeleteDhcpPoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeleteDhcpResponse, error) { + respType := WorkloadNetworksDeleteDhcpResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeleteDhcpResponse{}, 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 *WorkloadNetworksDeleteDhcpPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeletePortMirroringPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeletePortMirroringPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeletePortMirroringPoller) 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 *WorkloadNetworksDeletePortMirroringPoller) 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 WorkloadNetworksDeletePortMirroringResponse will be returned. +func (p *WorkloadNetworksDeletePortMirroringPoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeletePortMirroringResponse, error) { + respType := WorkloadNetworksDeletePortMirroringResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeletePortMirroringResponse{}, 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 *WorkloadNetworksDeletePortMirroringPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeletePublicIPPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeletePublicIPPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeletePublicIPPoller) 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 *WorkloadNetworksDeletePublicIPPoller) 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 WorkloadNetworksDeletePublicIPResponse will be returned. +func (p *WorkloadNetworksDeletePublicIPPoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeletePublicIPResponse, error) { + respType := WorkloadNetworksDeletePublicIPResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeletePublicIPResponse{}, 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 *WorkloadNetworksDeletePublicIPPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeleteSegmentPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeleteSegmentPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeleteSegmentPoller) 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 *WorkloadNetworksDeleteSegmentPoller) 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 WorkloadNetworksDeleteSegmentResponse will be returned. +func (p *WorkloadNetworksDeleteSegmentPoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeleteSegmentResponse, error) { + respType := WorkloadNetworksDeleteSegmentResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeleteSegmentResponse{}, 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 *WorkloadNetworksDeleteSegmentPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksDeleteVMGroupPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksDeleteVMGroupPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksDeleteVMGroupPoller) 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 *WorkloadNetworksDeleteVMGroupPoller) 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 WorkloadNetworksDeleteVMGroupResponse will be returned. +func (p *WorkloadNetworksDeleteVMGroupPoller) FinalResponse(ctx context.Context) (WorkloadNetworksDeleteVMGroupResponse, error) { + respType := WorkloadNetworksDeleteVMGroupResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkloadNetworksDeleteVMGroupResponse{}, 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 *WorkloadNetworksDeleteVMGroupPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksUpdateDNSServicePoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksUpdateDNSServicePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksUpdateDNSServicePoller) 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 *WorkloadNetworksUpdateDNSServicePoller) 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 WorkloadNetworksUpdateDNSServiceResponse will be returned. +func (p *WorkloadNetworksUpdateDNSServicePoller) FinalResponse(ctx context.Context) (WorkloadNetworksUpdateDNSServiceResponse, error) { + respType := WorkloadNetworksUpdateDNSServiceResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkDNSService) + if err != nil { + return WorkloadNetworksUpdateDNSServiceResponse{}, 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 *WorkloadNetworksUpdateDNSServicePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksUpdateDNSZonePoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksUpdateDNSZonePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksUpdateDNSZonePoller) 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 *WorkloadNetworksUpdateDNSZonePoller) 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 WorkloadNetworksUpdateDNSZoneResponse will be returned. +func (p *WorkloadNetworksUpdateDNSZonePoller) FinalResponse(ctx context.Context) (WorkloadNetworksUpdateDNSZoneResponse, error) { + respType := WorkloadNetworksUpdateDNSZoneResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkDNSZone) + if err != nil { + return WorkloadNetworksUpdateDNSZoneResponse{}, 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 *WorkloadNetworksUpdateDNSZonePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksUpdateDhcpPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksUpdateDhcpPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksUpdateDhcpPoller) 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 *WorkloadNetworksUpdateDhcpPoller) 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 WorkloadNetworksUpdateDhcpResponse will be returned. +func (p *WorkloadNetworksUpdateDhcpPoller) FinalResponse(ctx context.Context) (WorkloadNetworksUpdateDhcpResponse, error) { + respType := WorkloadNetworksUpdateDhcpResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkDhcp) + if err != nil { + return WorkloadNetworksUpdateDhcpResponse{}, 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 *WorkloadNetworksUpdateDhcpPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksUpdatePortMirroringPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksUpdatePortMirroringPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksUpdatePortMirroringPoller) 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 *WorkloadNetworksUpdatePortMirroringPoller) 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 WorkloadNetworksUpdatePortMirroringResponse will be returned. +func (p *WorkloadNetworksUpdatePortMirroringPoller) FinalResponse(ctx context.Context) (WorkloadNetworksUpdatePortMirroringResponse, error) { + respType := WorkloadNetworksUpdatePortMirroringResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkPortMirroring) + if err != nil { + return WorkloadNetworksUpdatePortMirroringResponse{}, 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 *WorkloadNetworksUpdatePortMirroringPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksUpdateSegmentsPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksUpdateSegmentsPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksUpdateSegmentsPoller) 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 *WorkloadNetworksUpdateSegmentsPoller) 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 WorkloadNetworksUpdateSegmentsResponse will be returned. +func (p *WorkloadNetworksUpdateSegmentsPoller) FinalResponse(ctx context.Context) (WorkloadNetworksUpdateSegmentsResponse, error) { + respType := WorkloadNetworksUpdateSegmentsResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkSegment) + if err != nil { + return WorkloadNetworksUpdateSegmentsResponse{}, 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 *WorkloadNetworksUpdateSegmentsPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// WorkloadNetworksUpdateVMGroupPoller provides polling facilities until the operation reaches a terminal state. +type WorkloadNetworksUpdateVMGroupPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *WorkloadNetworksUpdateVMGroupPoller) 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 *WorkloadNetworksUpdateVMGroupPoller) 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 WorkloadNetworksUpdateVMGroupResponse will be returned. +func (p *WorkloadNetworksUpdateVMGroupPoller) FinalResponse(ctx context.Context) (WorkloadNetworksUpdateVMGroupResponse, error) { + respType := WorkloadNetworksUpdateVMGroupResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.WorkloadNetworkVMGroup) + if err != nil { + return WorkloadNetworksUpdateVMGroupResponse{}, 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 *WorkloadNetworksUpdateVMGroupPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/avs/armavs/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..37d05974a7e4 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_polymorphic_helpers.go @@ -0,0 +1,247 @@ +//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 armavs + +import "encoding/json" + +func unmarshalAddonPropertiesClassification(rawMsg json.RawMessage) (AddonPropertiesClassification, 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 AddonPropertiesClassification + switch m["addonType"] { + case string(AddonTypeHCX): + b = &AddonHcxProperties{} + case string(AddonTypeSRM): + b = &AddonSrmProperties{} + case string(AddonTypeVR): + b = &AddonVrProperties{} + default: + b = &AddonProperties{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalAddonPropertiesClassificationArray(rawMsg json.RawMessage) ([]AddonPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]AddonPropertiesClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalAddonPropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalAddonPropertiesClassificationMap(rawMsg json.RawMessage) (map[string]AddonPropertiesClassification, 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]AddonPropertiesClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalAddonPropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalPlacementPolicyPropertiesClassification(rawMsg json.RawMessage) (PlacementPolicyPropertiesClassification, 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 PlacementPolicyPropertiesClassification + switch m["type"] { + case string(PlacementPolicyTypeVMHost): + b = &VMHostPlacementPolicyProperties{} + case string(PlacementPolicyTypeVMVM): + b = &VMPlacementPolicyProperties{} + default: + b = &PlacementPolicyProperties{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalPlacementPolicyPropertiesClassificationArray(rawMsg json.RawMessage) ([]PlacementPolicyPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]PlacementPolicyPropertiesClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalPlacementPolicyPropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalPlacementPolicyPropertiesClassificationMap(rawMsg json.RawMessage) (map[string]PlacementPolicyPropertiesClassification, 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]PlacementPolicyPropertiesClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalPlacementPolicyPropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalScriptExecutionParameterClassification(rawMsg json.RawMessage) (ScriptExecutionParameterClassification, 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 ScriptExecutionParameterClassification + switch m["type"] { + case string(ScriptExecutionParameterTypeCredential): + b = &PSCredentialExecutionParameter{} + case string(ScriptExecutionParameterTypeSecureValue): + b = &ScriptSecureStringExecutionParameter{} + case string(ScriptExecutionParameterTypeValue): + b = &ScriptStringExecutionParameter{} + default: + b = &ScriptExecutionParameter{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalScriptExecutionParameterClassificationArray(rawMsg json.RawMessage) ([]ScriptExecutionParameterClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]ScriptExecutionParameterClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalScriptExecutionParameterClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalScriptExecutionParameterClassificationMap(rawMsg json.RawMessage) (map[string]ScriptExecutionParameterClassification, 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]ScriptExecutionParameterClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalScriptExecutionParameterClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalWorkloadNetworkDhcpEntityClassification(rawMsg json.RawMessage) (WorkloadNetworkDhcpEntityClassification, 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 WorkloadNetworkDhcpEntityClassification + switch m["dhcpType"] { + case string(DhcpTypeEnumRELAY): + b = &WorkloadNetworkDhcpRelay{} + case string(DhcpTypeEnumSERVER): + b = &WorkloadNetworkDhcpServer{} + default: + b = &WorkloadNetworkDhcpEntity{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalWorkloadNetworkDhcpEntityClassificationArray(rawMsg json.RawMessage) ([]WorkloadNetworkDhcpEntityClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]WorkloadNetworkDhcpEntityClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalWorkloadNetworkDhcpEntityClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalWorkloadNetworkDhcpEntityClassificationMap(rawMsg json.RawMessage) (map[string]WorkloadNetworkDhcpEntityClassification, 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]WorkloadNetworkDhcpEntityClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalWorkloadNetworkDhcpEntityClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_privateclouds_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_privateclouds_client.go new file mode 100644 index 000000000000..07e6bd9b04b1 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_privateclouds_client.go @@ -0,0 +1,665 @@ +//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 armavs + +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" +) + +// PrivateCloudsClient contains the methods for the PrivateClouds group. +// Don't use this type directly, use NewPrivateCloudsClient() instead. +type PrivateCloudsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateCloudsClient creates a new instance of PrivateCloudsClient with the specified values. +func NewPrivateCloudsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateCloudsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateCloudsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud, options *PrivateCloudsBeginCreateOrUpdateOptions) (PrivateCloudsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, privateCloud, options) + if err != nil { + return PrivateCloudsCreateOrUpdatePollerResponse{}, err + } + result := PrivateCloudsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateCloudsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return PrivateCloudsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &PrivateCloudsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud, options *PrivateCloudsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, privateCloud, 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 *PrivateCloudsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud, options *PrivateCloudsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, privateCloud) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateCloudsClient) 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 - Delete a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginDeleteOptions) (PrivateCloudsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return PrivateCloudsDeletePollerResponse{}, err + } + result := PrivateCloudsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateCloudsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return PrivateCloudsDeletePollerResponse{}, err + } + result.Poller = &PrivateCloudsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, 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 *PrivateCloudsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateCloudsClient) 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 - Get a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsGetOptions) (PrivateCloudsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return PrivateCloudsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateCloudsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateCloudsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateCloudsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateCloudsClient) getHandleResponse(resp *http.Response) (PrivateCloudsGetResponse, error) { + result := PrivateCloudsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateCloud); err != nil { + return PrivateCloudsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateCloudsClient) 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 - List private clouds in a resource group +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) List(resourceGroupName string, options *PrivateCloudsListOptions) *PrivateCloudsListPager { + return &PrivateCloudsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp PrivateCloudsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PrivateCloudList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateCloudsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *PrivateCloudsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds" + 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)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateCloudsClient) listHandleResponse(resp *http.Response) (PrivateCloudsListResponse, error) { + result := PrivateCloudsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateCloudList); err != nil { + return PrivateCloudsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateCloudsClient) 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) +} + +// ListAdminCredentials - List the admin credentials for the private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsListAdminCredentialsOptions) (PrivateCloudsListAdminCredentialsResponse, error) { + req, err := client.listAdminCredentialsCreateRequest(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return PrivateCloudsListAdminCredentialsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateCloudsListAdminCredentialsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateCloudsListAdminCredentialsResponse{}, client.listAdminCredentialsHandleError(resp) + } + return client.listAdminCredentialsHandleResponse(resp) +} + +// listAdminCredentialsCreateRequest creates the ListAdminCredentials request. +func (client *PrivateCloudsClient) listAdminCredentialsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsListAdminCredentialsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAdminCredentialsHandleResponse handles the ListAdminCredentials response. +func (client *PrivateCloudsClient) listAdminCredentialsHandleResponse(resp *http.Response) (PrivateCloudsListAdminCredentialsResponse, error) { + result := PrivateCloudsListAdminCredentialsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AdminCredentials); err != nil { + return PrivateCloudsListAdminCredentialsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listAdminCredentialsHandleError handles the ListAdminCredentials error response. +func (client *PrivateCloudsClient) listAdminCredentialsHandleError(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) +} + +// ListInSubscription - List private clouds in a subscription +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) ListInSubscription(options *PrivateCloudsListInSubscriptionOptions) *PrivateCloudsListInSubscriptionPager { + return &PrivateCloudsListInSubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listInSubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PrivateCloudsListInSubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PrivateCloudList.NextLink) + }, + } +} + +// listInSubscriptionCreateRequest creates the ListInSubscription request. +func (client *PrivateCloudsClient) listInSubscriptionCreateRequest(ctx context.Context, options *PrivateCloudsListInSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds" + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listInSubscriptionHandleResponse handles the ListInSubscription response. +func (client *PrivateCloudsClient) listInSubscriptionHandleResponse(resp *http.Response) (PrivateCloudsListInSubscriptionResponse, error) { + result := PrivateCloudsListInSubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateCloudList); err != nil { + return PrivateCloudsListInSubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listInSubscriptionHandleError handles the ListInSubscription error response. +func (client *PrivateCloudsClient) listInSubscriptionHandleError(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) +} + +// BeginRotateNsxtPassword - Rotate the NSX-T Manager password +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) BeginRotateNsxtPassword(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginRotateNsxtPasswordOptions) (PrivateCloudsRotateNsxtPasswordPollerResponse, error) { + resp, err := client.rotateNsxtPassword(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return PrivateCloudsRotateNsxtPasswordPollerResponse{}, err + } + result := PrivateCloudsRotateNsxtPasswordPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateCloudsClient.RotateNsxtPassword", "", resp, client.pl, client.rotateNsxtPasswordHandleError) + if err != nil { + return PrivateCloudsRotateNsxtPasswordPollerResponse{}, err + } + result.Poller = &PrivateCloudsRotateNsxtPasswordPoller{ + pt: pt, + } + return result, nil +} + +// RotateNsxtPassword - Rotate the NSX-T Manager password +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) rotateNsxtPassword(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginRotateNsxtPasswordOptions) (*http.Response, error) { + req, err := client.rotateNsxtPasswordCreateRequest(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, client.rotateNsxtPasswordHandleError(resp) + } + return resp, nil +} + +// rotateNsxtPasswordCreateRequest creates the RotateNsxtPassword request. +func (client *PrivateCloudsClient) rotateNsxtPasswordCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginRotateNsxtPasswordOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// rotateNsxtPasswordHandleError handles the RotateNsxtPassword error response. +func (client *PrivateCloudsClient) rotateNsxtPasswordHandleError(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) +} + +// BeginRotateVcenterPassword - Rotate the vCenter password +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) BeginRotateVcenterPassword(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginRotateVcenterPasswordOptions) (PrivateCloudsRotateVcenterPasswordPollerResponse, error) { + resp, err := client.rotateVcenterPassword(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return PrivateCloudsRotateVcenterPasswordPollerResponse{}, err + } + result := PrivateCloudsRotateVcenterPasswordPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateCloudsClient.RotateVcenterPassword", "", resp, client.pl, client.rotateVcenterPasswordHandleError) + if err != nil { + return PrivateCloudsRotateVcenterPasswordPollerResponse{}, err + } + result.Poller = &PrivateCloudsRotateVcenterPasswordPoller{ + pt: pt, + } + return result, nil +} + +// RotateVcenterPassword - Rotate the vCenter password +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) rotateVcenterPassword(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginRotateVcenterPasswordOptions) (*http.Response, error) { + req, err := client.rotateVcenterPasswordCreateRequest(ctx, resourceGroupName, privateCloudName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, client.rotateVcenterPasswordHandleError(resp) + } + return resp, nil +} + +// rotateVcenterPasswordCreateRequest creates the RotateVcenterPassword request. +func (client *PrivateCloudsClient) rotateVcenterPasswordCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *PrivateCloudsBeginRotateVcenterPasswordOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// rotateVcenterPasswordHandleError handles the RotateVcenterPassword error response. +func (client *PrivateCloudsClient) rotateVcenterPasswordHandleError(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 private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) BeginUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate, options *PrivateCloudsBeginUpdateOptions) (PrivateCloudsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, privateCloudName, privateCloudUpdate, options) + if err != nil { + return PrivateCloudsUpdatePollerResponse{}, err + } + result := PrivateCloudsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateCloudsClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return PrivateCloudsUpdatePollerResponse{}, err + } + result.Poller = &PrivateCloudsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Update a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *PrivateCloudsClient) update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate, options *PrivateCloudsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, privateCloudName, privateCloudUpdate, 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.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *PrivateCloudsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate, options *PrivateCloudsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, privateCloudUpdate) +} + +// updateHandleError handles the Update error response. +func (client *PrivateCloudsClient) 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/avs/armavs/zz_generated_response_types.go b/sdk/resourcemanager/avs/armavs/zz_generated_response_types.go new file mode 100644 index 000000000000..b40e7142fde9 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_response_types.go @@ -0,0 +1,2808 @@ +//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 armavs + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// AddonsCreateOrUpdatePollerResponse contains the response from method Addons.CreateOrUpdate. +type AddonsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *AddonsCreateOrUpdatePoller + + // 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 AddonsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AddonsCreateOrUpdateResponse, error) { + respType := AddonsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Addon) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a AddonsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *AddonsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *AddonsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("AddonsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &AddonsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// AddonsCreateOrUpdateResponse contains the response from method Addons.CreateOrUpdate. +type AddonsCreateOrUpdateResponse struct { + AddonsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AddonsCreateOrUpdateResult contains the result from method Addons.CreateOrUpdate. +type AddonsCreateOrUpdateResult struct { + Addon +} + +// AddonsDeletePollerResponse contains the response from method Addons.Delete. +type AddonsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *AddonsDeletePoller + + // 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 AddonsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AddonsDeleteResponse, error) { + respType := AddonsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a AddonsDeletePollerResponse from the provided client and resume token. +func (l *AddonsDeletePollerResponse) Resume(ctx context.Context, client *AddonsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("AddonsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &AddonsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// AddonsDeleteResponse contains the response from method Addons.Delete. +type AddonsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AddonsGetResponse contains the response from method Addons.Get. +type AddonsGetResponse struct { + AddonsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AddonsGetResult contains the result from method Addons.Get. +type AddonsGetResult struct { + Addon +} + +// AddonsListResponse contains the response from method Addons.List. +type AddonsListResponse struct { + AddonsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AddonsListResult contains the result from method Addons.List. +type AddonsListResult struct { + AddonList +} + +// AuthorizationsCreateOrUpdatePollerResponse contains the response from method Authorizations.CreateOrUpdate. +type AuthorizationsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *AuthorizationsCreateOrUpdatePoller + + // 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 AuthorizationsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AuthorizationsCreateOrUpdateResponse, error) { + respType := AuthorizationsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ExpressRouteAuthorization) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a AuthorizationsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *AuthorizationsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *AuthorizationsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("AuthorizationsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &AuthorizationsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// AuthorizationsCreateOrUpdateResponse contains the response from method Authorizations.CreateOrUpdate. +type AuthorizationsCreateOrUpdateResponse struct { + AuthorizationsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationsCreateOrUpdateResult contains the result from method Authorizations.CreateOrUpdate. +type AuthorizationsCreateOrUpdateResult struct { + ExpressRouteAuthorization +} + +// AuthorizationsDeletePollerResponse contains the response from method Authorizations.Delete. +type AuthorizationsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *AuthorizationsDeletePoller + + // 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 AuthorizationsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AuthorizationsDeleteResponse, error) { + respType := AuthorizationsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a AuthorizationsDeletePollerResponse from the provided client and resume token. +func (l *AuthorizationsDeletePollerResponse) Resume(ctx context.Context, client *AuthorizationsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("AuthorizationsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &AuthorizationsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// AuthorizationsDeleteResponse contains the response from method Authorizations.Delete. +type AuthorizationsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationsGetResponse contains the response from method Authorizations.Get. +type AuthorizationsGetResponse struct { + AuthorizationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationsGetResult contains the result from method Authorizations.Get. +type AuthorizationsGetResult struct { + ExpressRouteAuthorization +} + +// AuthorizationsListResponse contains the response from method Authorizations.List. +type AuthorizationsListResponse struct { + AuthorizationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationsListResult contains the result from method Authorizations.List. +type AuthorizationsListResult struct { + ExpressRouteAuthorizationList +} + +// CloudLinksCreateOrUpdatePollerResponse contains the response from method CloudLinks.CreateOrUpdate. +type CloudLinksCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *CloudLinksCreateOrUpdatePoller + + // 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 CloudLinksCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CloudLinksCreateOrUpdateResponse, error) { + respType := CloudLinksCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.CloudLink) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CloudLinksCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *CloudLinksCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *CloudLinksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CloudLinksClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &CloudLinksCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CloudLinksCreateOrUpdateResponse contains the response from method CloudLinks.CreateOrUpdate. +type CloudLinksCreateOrUpdateResponse struct { + CloudLinksCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CloudLinksCreateOrUpdateResult contains the result from method CloudLinks.CreateOrUpdate. +type CloudLinksCreateOrUpdateResult struct { + CloudLink +} + +// CloudLinksDeletePollerResponse contains the response from method CloudLinks.Delete. +type CloudLinksDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *CloudLinksDeletePoller + + // 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 CloudLinksDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CloudLinksDeleteResponse, error) { + respType := CloudLinksDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CloudLinksDeletePollerResponse from the provided client and resume token. +func (l *CloudLinksDeletePollerResponse) Resume(ctx context.Context, client *CloudLinksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CloudLinksClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &CloudLinksDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CloudLinksDeleteResponse contains the response from method CloudLinks.Delete. +type CloudLinksDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CloudLinksGetResponse contains the response from method CloudLinks.Get. +type CloudLinksGetResponse struct { + CloudLinksGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CloudLinksGetResult contains the result from method CloudLinks.Get. +type CloudLinksGetResult struct { + CloudLink +} + +// CloudLinksListResponse contains the response from method CloudLinks.List. +type CloudLinksListResponse struct { + CloudLinksListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CloudLinksListResult contains the result from method CloudLinks.List. +type CloudLinksListResult struct { + CloudLinkList +} + +// 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 +} + +// 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 +} + +// 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 { + ClusterList +} + +// 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 +} + +// DatastoresCreateOrUpdatePollerResponse contains the response from method Datastores.CreateOrUpdate. +type DatastoresCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatastoresCreateOrUpdatePoller + + // 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 DatastoresCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatastoresCreateOrUpdateResponse, error) { + respType := DatastoresCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Datastore) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatastoresCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *DatastoresCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *DatastoresClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatastoresClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &DatastoresCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatastoresCreateOrUpdateResponse contains the response from method Datastores.CreateOrUpdate. +type DatastoresCreateOrUpdateResponse struct { + DatastoresCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatastoresCreateOrUpdateResult contains the result from method Datastores.CreateOrUpdate. +type DatastoresCreateOrUpdateResult struct { + Datastore +} + +// DatastoresDeletePollerResponse contains the response from method Datastores.Delete. +type DatastoresDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *DatastoresDeletePoller + + // 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 DatastoresDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DatastoresDeleteResponse, error) { + respType := DatastoresDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DatastoresDeletePollerResponse from the provided client and resume token. +func (l *DatastoresDeletePollerResponse) Resume(ctx context.Context, client *DatastoresClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DatastoresClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &DatastoresDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DatastoresDeleteResponse contains the response from method Datastores.Delete. +type DatastoresDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatastoresGetResponse contains the response from method Datastores.Get. +type DatastoresGetResponse struct { + DatastoresGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatastoresGetResult contains the result from method Datastores.Get. +type DatastoresGetResult struct { + Datastore +} + +// DatastoresListResponse contains the response from method Datastores.List. +type DatastoresListResponse struct { + DatastoresListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DatastoresListResult contains the result from method Datastores.List. +type DatastoresListResult struct { + DatastoreList +} + +// GlobalReachConnectionsCreateOrUpdatePollerResponse contains the response from method GlobalReachConnections.CreateOrUpdate. +type GlobalReachConnectionsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *GlobalReachConnectionsCreateOrUpdatePoller + + // 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 GlobalReachConnectionsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (GlobalReachConnectionsCreateOrUpdateResponse, error) { + respType := GlobalReachConnectionsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.GlobalReachConnection) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a GlobalReachConnectionsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *GlobalReachConnectionsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *GlobalReachConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("GlobalReachConnectionsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &GlobalReachConnectionsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// GlobalReachConnectionsCreateOrUpdateResponse contains the response from method GlobalReachConnections.CreateOrUpdate. +type GlobalReachConnectionsCreateOrUpdateResponse struct { + GlobalReachConnectionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GlobalReachConnectionsCreateOrUpdateResult contains the result from method GlobalReachConnections.CreateOrUpdate. +type GlobalReachConnectionsCreateOrUpdateResult struct { + GlobalReachConnection +} + +// GlobalReachConnectionsDeletePollerResponse contains the response from method GlobalReachConnections.Delete. +type GlobalReachConnectionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *GlobalReachConnectionsDeletePoller + + // 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 GlobalReachConnectionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (GlobalReachConnectionsDeleteResponse, error) { + respType := GlobalReachConnectionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a GlobalReachConnectionsDeletePollerResponse from the provided client and resume token. +func (l *GlobalReachConnectionsDeletePollerResponse) Resume(ctx context.Context, client *GlobalReachConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("GlobalReachConnectionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &GlobalReachConnectionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// GlobalReachConnectionsDeleteResponse contains the response from method GlobalReachConnections.Delete. +type GlobalReachConnectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GlobalReachConnectionsGetResponse contains the response from method GlobalReachConnections.Get. +type GlobalReachConnectionsGetResponse struct { + GlobalReachConnectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GlobalReachConnectionsGetResult contains the result from method GlobalReachConnections.Get. +type GlobalReachConnectionsGetResult struct { + GlobalReachConnection +} + +// GlobalReachConnectionsListResponse contains the response from method GlobalReachConnections.List. +type GlobalReachConnectionsListResponse struct { + GlobalReachConnectionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GlobalReachConnectionsListResult contains the result from method GlobalReachConnections.List. +type GlobalReachConnectionsListResult struct { + GlobalReachConnectionList +} + +// HcxEnterpriseSitesCreateOrUpdateResponse contains the response from method HcxEnterpriseSites.CreateOrUpdate. +type HcxEnterpriseSitesCreateOrUpdateResponse struct { + HcxEnterpriseSitesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HcxEnterpriseSitesCreateOrUpdateResult contains the result from method HcxEnterpriseSites.CreateOrUpdate. +type HcxEnterpriseSitesCreateOrUpdateResult struct { + HcxEnterpriseSite +} + +// HcxEnterpriseSitesDeleteResponse contains the response from method HcxEnterpriseSites.Delete. +type HcxEnterpriseSitesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HcxEnterpriseSitesGetResponse contains the response from method HcxEnterpriseSites.Get. +type HcxEnterpriseSitesGetResponse struct { + HcxEnterpriseSitesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HcxEnterpriseSitesGetResult contains the result from method HcxEnterpriseSites.Get. +type HcxEnterpriseSitesGetResult struct { + HcxEnterpriseSite +} + +// HcxEnterpriseSitesListResponse contains the response from method HcxEnterpriseSites.List. +type HcxEnterpriseSitesListResponse struct { + HcxEnterpriseSitesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HcxEnterpriseSitesListResult contains the result from method HcxEnterpriseSites.List. +type HcxEnterpriseSitesListResult struct { + HcxEnterpriseSiteList +} + +// LocationsCheckQuotaAvailabilityResponse contains the response from method Locations.CheckQuotaAvailability. +type LocationsCheckQuotaAvailabilityResponse struct { + LocationsCheckQuotaAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationsCheckQuotaAvailabilityResult contains the result from method Locations.CheckQuotaAvailability. +type LocationsCheckQuotaAvailabilityResult struct { + Quota +} + +// LocationsCheckTrialAvailabilityResponse contains the response from method Locations.CheckTrialAvailability. +type LocationsCheckTrialAvailabilityResponse struct { + LocationsCheckTrialAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationsCheckTrialAvailabilityResult contains the result from method Locations.CheckTrialAvailability. +type LocationsCheckTrialAvailabilityResult struct { + Trial +} + +// 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 { + OperationList +} + +// PlacementPoliciesCreateOrUpdatePollerResponse contains the response from method PlacementPolicies.CreateOrUpdate. +type PlacementPoliciesCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PlacementPoliciesCreateOrUpdatePoller + + // 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 PlacementPoliciesCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PlacementPoliciesCreateOrUpdateResponse, error) { + respType := PlacementPoliciesCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.PlacementPolicy) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PlacementPoliciesCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *PlacementPoliciesCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *PlacementPoliciesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PlacementPoliciesClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &PlacementPoliciesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PlacementPoliciesCreateOrUpdateResponse contains the response from method PlacementPolicies.CreateOrUpdate. +type PlacementPoliciesCreateOrUpdateResponse struct { + PlacementPoliciesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PlacementPoliciesCreateOrUpdateResult contains the result from method PlacementPolicies.CreateOrUpdate. +type PlacementPoliciesCreateOrUpdateResult struct { + PlacementPolicy +} + +// PlacementPoliciesDeletePollerResponse contains the response from method PlacementPolicies.Delete. +type PlacementPoliciesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *PlacementPoliciesDeletePoller + + // 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 PlacementPoliciesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PlacementPoliciesDeleteResponse, error) { + respType := PlacementPoliciesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PlacementPoliciesDeletePollerResponse from the provided client and resume token. +func (l *PlacementPoliciesDeletePollerResponse) Resume(ctx context.Context, client *PlacementPoliciesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PlacementPoliciesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &PlacementPoliciesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PlacementPoliciesDeleteResponse contains the response from method PlacementPolicies.Delete. +type PlacementPoliciesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PlacementPoliciesGetResponse contains the response from method PlacementPolicies.Get. +type PlacementPoliciesGetResponse struct { + PlacementPoliciesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PlacementPoliciesGetResult contains the result from method PlacementPolicies.Get. +type PlacementPoliciesGetResult struct { + PlacementPolicy +} + +// PlacementPoliciesListResponse contains the response from method PlacementPolicies.List. +type PlacementPoliciesListResponse struct { + PlacementPoliciesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PlacementPoliciesListResult contains the result from method PlacementPolicies.List. +type PlacementPoliciesListResult struct { + PlacementPoliciesList +} + +// PlacementPoliciesUpdatePollerResponse contains the response from method PlacementPolicies.Update. +type PlacementPoliciesUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PlacementPoliciesUpdatePoller + + // 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 PlacementPoliciesUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PlacementPoliciesUpdateResponse, error) { + respType := PlacementPoliciesUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.PlacementPolicy) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PlacementPoliciesUpdatePollerResponse from the provided client and resume token. +func (l *PlacementPoliciesUpdatePollerResponse) Resume(ctx context.Context, client *PlacementPoliciesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PlacementPoliciesClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &PlacementPoliciesUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PlacementPoliciesUpdateResponse contains the response from method PlacementPolicies.Update. +type PlacementPoliciesUpdateResponse struct { + PlacementPoliciesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PlacementPoliciesUpdateResult contains the result from method PlacementPolicies.Update. +type PlacementPoliciesUpdateResult struct { + PlacementPolicy +} + +// PrivateCloudsCreateOrUpdatePollerResponse contains the response from method PrivateClouds.CreateOrUpdate. +type PrivateCloudsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateCloudsCreateOrUpdatePoller + + // 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 PrivateCloudsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateCloudsCreateOrUpdateResponse, error) { + respType := PrivateCloudsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.PrivateCloud) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateCloudsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *PrivateCloudsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *PrivateCloudsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateCloudsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &PrivateCloudsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateCloudsCreateOrUpdateResponse contains the response from method PrivateClouds.CreateOrUpdate. +type PrivateCloudsCreateOrUpdateResponse struct { + PrivateCloudsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsCreateOrUpdateResult contains the result from method PrivateClouds.CreateOrUpdate. +type PrivateCloudsCreateOrUpdateResult struct { + PrivateCloud +} + +// PrivateCloudsDeletePollerResponse contains the response from method PrivateClouds.Delete. +type PrivateCloudsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateCloudsDeletePoller + + // 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 PrivateCloudsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateCloudsDeleteResponse, error) { + respType := PrivateCloudsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateCloudsDeletePollerResponse from the provided client and resume token. +func (l *PrivateCloudsDeletePollerResponse) Resume(ctx context.Context, client *PrivateCloudsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateCloudsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &PrivateCloudsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateCloudsDeleteResponse contains the response from method PrivateClouds.Delete. +type PrivateCloudsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsGetResponse contains the response from method PrivateClouds.Get. +type PrivateCloudsGetResponse struct { + PrivateCloudsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsGetResult contains the result from method PrivateClouds.Get. +type PrivateCloudsGetResult struct { + PrivateCloud +} + +// PrivateCloudsListAdminCredentialsResponse contains the response from method PrivateClouds.ListAdminCredentials. +type PrivateCloudsListAdminCredentialsResponse struct { + PrivateCloudsListAdminCredentialsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsListAdminCredentialsResult contains the result from method PrivateClouds.ListAdminCredentials. +type PrivateCloudsListAdminCredentialsResult struct { + AdminCredentials +} + +// PrivateCloudsListInSubscriptionResponse contains the response from method PrivateClouds.ListInSubscription. +type PrivateCloudsListInSubscriptionResponse struct { + PrivateCloudsListInSubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsListInSubscriptionResult contains the result from method PrivateClouds.ListInSubscription. +type PrivateCloudsListInSubscriptionResult struct { + PrivateCloudList +} + +// PrivateCloudsListResponse contains the response from method PrivateClouds.List. +type PrivateCloudsListResponse struct { + PrivateCloudsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsListResult contains the result from method PrivateClouds.List. +type PrivateCloudsListResult struct { + PrivateCloudList +} + +// PrivateCloudsRotateNsxtPasswordPollerResponse contains the response from method PrivateClouds.RotateNsxtPassword. +type PrivateCloudsRotateNsxtPasswordPollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateCloudsRotateNsxtPasswordPoller + + // 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 PrivateCloudsRotateNsxtPasswordPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateCloudsRotateNsxtPasswordResponse, error) { + respType := PrivateCloudsRotateNsxtPasswordResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateCloudsRotateNsxtPasswordPollerResponse from the provided client and resume token. +func (l *PrivateCloudsRotateNsxtPasswordPollerResponse) Resume(ctx context.Context, client *PrivateCloudsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateCloudsClient.RotateNsxtPassword", token, client.pl, client.rotateNsxtPasswordHandleError) + if err != nil { + return err + } + poller := &PrivateCloudsRotateNsxtPasswordPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateCloudsRotateNsxtPasswordResponse contains the response from method PrivateClouds.RotateNsxtPassword. +type PrivateCloudsRotateNsxtPasswordResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsRotateVcenterPasswordPollerResponse contains the response from method PrivateClouds.RotateVcenterPassword. +type PrivateCloudsRotateVcenterPasswordPollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateCloudsRotateVcenterPasswordPoller + + // 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 PrivateCloudsRotateVcenterPasswordPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateCloudsRotateVcenterPasswordResponse, error) { + respType := PrivateCloudsRotateVcenterPasswordResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateCloudsRotateVcenterPasswordPollerResponse from the provided client and resume token. +func (l *PrivateCloudsRotateVcenterPasswordPollerResponse) Resume(ctx context.Context, client *PrivateCloudsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateCloudsClient.RotateVcenterPassword", token, client.pl, client.rotateVcenterPasswordHandleError) + if err != nil { + return err + } + poller := &PrivateCloudsRotateVcenterPasswordPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateCloudsRotateVcenterPasswordResponse contains the response from method PrivateClouds.RotateVcenterPassword. +type PrivateCloudsRotateVcenterPasswordResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsUpdatePollerResponse contains the response from method PrivateClouds.Update. +type PrivateCloudsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateCloudsUpdatePoller + + // 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 PrivateCloudsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateCloudsUpdateResponse, error) { + respType := PrivateCloudsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.PrivateCloud) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateCloudsUpdatePollerResponse from the provided client and resume token. +func (l *PrivateCloudsUpdatePollerResponse) Resume(ctx context.Context, client *PrivateCloudsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateCloudsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &PrivateCloudsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateCloudsUpdateResponse contains the response from method PrivateClouds.Update. +type PrivateCloudsUpdateResponse struct { + PrivateCloudsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateCloudsUpdateResult contains the result from method PrivateClouds.Update. +type PrivateCloudsUpdateResult struct { + PrivateCloud +} + +// ScriptCmdletsGetResponse contains the response from method ScriptCmdlets.Get. +type ScriptCmdletsGetResponse struct { + ScriptCmdletsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptCmdletsGetResult contains the result from method ScriptCmdlets.Get. +type ScriptCmdletsGetResult struct { + ScriptCmdlet +} + +// ScriptCmdletsListResponse contains the response from method ScriptCmdlets.List. +type ScriptCmdletsListResponse struct { + ScriptCmdletsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptCmdletsListResult contains the result from method ScriptCmdlets.List. +type ScriptCmdletsListResult struct { + ScriptCmdletsList +} + +// ScriptExecutionsCreateOrUpdatePollerResponse contains the response from method ScriptExecutions.CreateOrUpdate. +type ScriptExecutionsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ScriptExecutionsCreateOrUpdatePoller + + // 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 ScriptExecutionsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ScriptExecutionsCreateOrUpdateResponse, error) { + respType := ScriptExecutionsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ScriptExecution) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ScriptExecutionsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ScriptExecutionsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ScriptExecutionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ScriptExecutionsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ScriptExecutionsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ScriptExecutionsCreateOrUpdateResponse contains the response from method ScriptExecutions.CreateOrUpdate. +type ScriptExecutionsCreateOrUpdateResponse struct { + ScriptExecutionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptExecutionsCreateOrUpdateResult contains the result from method ScriptExecutions.CreateOrUpdate. +type ScriptExecutionsCreateOrUpdateResult struct { + ScriptExecution +} + +// ScriptExecutionsDeletePollerResponse contains the response from method ScriptExecutions.Delete. +type ScriptExecutionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ScriptExecutionsDeletePoller + + // 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 ScriptExecutionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ScriptExecutionsDeleteResponse, error) { + respType := ScriptExecutionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ScriptExecutionsDeletePollerResponse from the provided client and resume token. +func (l *ScriptExecutionsDeletePollerResponse) Resume(ctx context.Context, client *ScriptExecutionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ScriptExecutionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ScriptExecutionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ScriptExecutionsDeleteResponse contains the response from method ScriptExecutions.Delete. +type ScriptExecutionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptExecutionsGetExecutionLogsResponse contains the response from method ScriptExecutions.GetExecutionLogs. +type ScriptExecutionsGetExecutionLogsResponse struct { + ScriptExecutionsGetExecutionLogsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptExecutionsGetExecutionLogsResult contains the result from method ScriptExecutions.GetExecutionLogs. +type ScriptExecutionsGetExecutionLogsResult struct { + ScriptExecution +} + +// ScriptExecutionsGetResponse contains the response from method ScriptExecutions.Get. +type ScriptExecutionsGetResponse struct { + ScriptExecutionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptExecutionsGetResult contains the result from method ScriptExecutions.Get. +type ScriptExecutionsGetResult struct { + ScriptExecution +} + +// ScriptExecutionsListResponse contains the response from method ScriptExecutions.List. +type ScriptExecutionsListResponse struct { + ScriptExecutionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptExecutionsListResult contains the result from method ScriptExecutions.List. +type ScriptExecutionsListResult struct { + ScriptExecutionsList +} + +// ScriptPackagesGetResponse contains the response from method ScriptPackages.Get. +type ScriptPackagesGetResponse struct { + ScriptPackagesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptPackagesGetResult contains the result from method ScriptPackages.Get. +type ScriptPackagesGetResult struct { + ScriptPackage +} + +// ScriptPackagesListResponse contains the response from method ScriptPackages.List. +type ScriptPackagesListResponse struct { + ScriptPackagesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScriptPackagesListResult contains the result from method ScriptPackages.List. +type ScriptPackagesListResult struct { + ScriptPackagesList +} + +// VirtualMachinesGetResponse contains the response from method VirtualMachines.Get. +type VirtualMachinesGetResponse struct { + VirtualMachinesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesGetResult contains the result from method VirtualMachines.Get. +type VirtualMachinesGetResult struct { + VirtualMachine +} + +// VirtualMachinesListResponse contains the response from method VirtualMachines.List. +type VirtualMachinesListResponse struct { + VirtualMachinesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesListResult contains the result from method VirtualMachines.List. +type VirtualMachinesListResult struct { + VirtualMachinesList +} + +// VirtualMachinesRestrictMovementPollerResponse contains the response from method VirtualMachines.RestrictMovement. +type VirtualMachinesRestrictMovementPollerResponse struct { + // Poller contains an initialized poller. + Poller *VirtualMachinesRestrictMovementPoller + + // 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 VirtualMachinesRestrictMovementPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VirtualMachinesRestrictMovementResponse, error) { + respType := VirtualMachinesRestrictMovementResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VirtualMachinesRestrictMovementPollerResponse from the provided client and resume token. +func (l *VirtualMachinesRestrictMovementPollerResponse) Resume(ctx context.Context, client *VirtualMachinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VirtualMachinesClient.RestrictMovement", token, client.pl, client.restrictMovementHandleError) + if err != nil { + return err + } + poller := &VirtualMachinesRestrictMovementPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VirtualMachinesRestrictMovementResponse contains the response from method VirtualMachines.RestrictMovement. +type VirtualMachinesRestrictMovementResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreateDNSServicePollerResponse contains the response from method WorkloadNetworks.CreateDNSService. +type WorkloadNetworksCreateDNSServicePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreateDNSServicePoller + + // 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 WorkloadNetworksCreateDNSServicePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreateDNSServiceResponse, error) { + respType := WorkloadNetworksCreateDNSServiceResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkDNSService) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreateDNSServicePollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreateDNSServicePollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreateDNSService", token, client.pl, client.createDNSServiceHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreateDNSServicePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreateDNSServiceResponse contains the response from method WorkloadNetworks.CreateDNSService. +type WorkloadNetworksCreateDNSServiceResponse struct { + WorkloadNetworksCreateDNSServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreateDNSServiceResult contains the result from method WorkloadNetworks.CreateDNSService. +type WorkloadNetworksCreateDNSServiceResult struct { + WorkloadNetworkDNSService +} + +// WorkloadNetworksCreateDNSZonePollerResponse contains the response from method WorkloadNetworks.CreateDNSZone. +type WorkloadNetworksCreateDNSZonePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreateDNSZonePoller + + // 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 WorkloadNetworksCreateDNSZonePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreateDNSZoneResponse, error) { + respType := WorkloadNetworksCreateDNSZoneResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkDNSZone) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreateDNSZonePollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreateDNSZonePollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreateDNSZone", token, client.pl, client.createDNSZoneHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreateDNSZonePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreateDNSZoneResponse contains the response from method WorkloadNetworks.CreateDNSZone. +type WorkloadNetworksCreateDNSZoneResponse struct { + WorkloadNetworksCreateDNSZoneResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreateDNSZoneResult contains the result from method WorkloadNetworks.CreateDNSZone. +type WorkloadNetworksCreateDNSZoneResult struct { + WorkloadNetworkDNSZone +} + +// WorkloadNetworksCreateDhcpPollerResponse contains the response from method WorkloadNetworks.CreateDhcp. +type WorkloadNetworksCreateDhcpPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreateDhcpPoller + + // 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 WorkloadNetworksCreateDhcpPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreateDhcpResponse, error) { + respType := WorkloadNetworksCreateDhcpResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkDhcp) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreateDhcpPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreateDhcpPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreateDhcp", token, client.pl, client.createDhcpHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreateDhcpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreateDhcpResponse contains the response from method WorkloadNetworks.CreateDhcp. +type WorkloadNetworksCreateDhcpResponse struct { + WorkloadNetworksCreateDhcpResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreateDhcpResult contains the result from method WorkloadNetworks.CreateDhcp. +type WorkloadNetworksCreateDhcpResult struct { + WorkloadNetworkDhcp +} + +// WorkloadNetworksCreatePortMirroringPollerResponse contains the response from method WorkloadNetworks.CreatePortMirroring. +type WorkloadNetworksCreatePortMirroringPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreatePortMirroringPoller + + // 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 WorkloadNetworksCreatePortMirroringPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreatePortMirroringResponse, error) { + respType := WorkloadNetworksCreatePortMirroringResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkPortMirroring) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreatePortMirroringPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreatePortMirroringPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreatePortMirroring", token, client.pl, client.createPortMirroringHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreatePortMirroringPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreatePortMirroringResponse contains the response from method WorkloadNetworks.CreatePortMirroring. +type WorkloadNetworksCreatePortMirroringResponse struct { + WorkloadNetworksCreatePortMirroringResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreatePortMirroringResult contains the result from method WorkloadNetworks.CreatePortMirroring. +type WorkloadNetworksCreatePortMirroringResult struct { + WorkloadNetworkPortMirroring +} + +// WorkloadNetworksCreatePublicIPPollerResponse contains the response from method WorkloadNetworks.CreatePublicIP. +type WorkloadNetworksCreatePublicIPPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreatePublicIPPoller + + // 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 WorkloadNetworksCreatePublicIPPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreatePublicIPResponse, error) { + respType := WorkloadNetworksCreatePublicIPResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkPublicIP) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreatePublicIPPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreatePublicIPPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreatePublicIP", token, client.pl, client.createPublicIPHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreatePublicIPPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreatePublicIPResponse contains the response from method WorkloadNetworks.CreatePublicIP. +type WorkloadNetworksCreatePublicIPResponse struct { + WorkloadNetworksCreatePublicIPResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreatePublicIPResult contains the result from method WorkloadNetworks.CreatePublicIP. +type WorkloadNetworksCreatePublicIPResult struct { + WorkloadNetworkPublicIP +} + +// WorkloadNetworksCreateSegmentsPollerResponse contains the response from method WorkloadNetworks.CreateSegments. +type WorkloadNetworksCreateSegmentsPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreateSegmentsPoller + + // 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 WorkloadNetworksCreateSegmentsPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreateSegmentsResponse, error) { + respType := WorkloadNetworksCreateSegmentsResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkSegment) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreateSegmentsPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreateSegmentsPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreateSegments", token, client.pl, client.createSegmentsHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreateSegmentsPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreateSegmentsResponse contains the response from method WorkloadNetworks.CreateSegments. +type WorkloadNetworksCreateSegmentsResponse struct { + WorkloadNetworksCreateSegmentsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreateSegmentsResult contains the result from method WorkloadNetworks.CreateSegments. +type WorkloadNetworksCreateSegmentsResult struct { + WorkloadNetworkSegment +} + +// WorkloadNetworksCreateVMGroupPollerResponse contains the response from method WorkloadNetworks.CreateVMGroup. +type WorkloadNetworksCreateVMGroupPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksCreateVMGroupPoller + + // 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 WorkloadNetworksCreateVMGroupPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksCreateVMGroupResponse, error) { + respType := WorkloadNetworksCreateVMGroupResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkVMGroup) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksCreateVMGroupPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksCreateVMGroupPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.CreateVMGroup", token, client.pl, client.createVMGroupHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksCreateVMGroupPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksCreateVMGroupResponse contains the response from method WorkloadNetworks.CreateVMGroup. +type WorkloadNetworksCreateVMGroupResponse struct { + WorkloadNetworksCreateVMGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksCreateVMGroupResult contains the result from method WorkloadNetworks.CreateVMGroup. +type WorkloadNetworksCreateVMGroupResult struct { + WorkloadNetworkVMGroup +} + +// WorkloadNetworksDeleteDNSServicePollerResponse contains the response from method WorkloadNetworks.DeleteDNSService. +type WorkloadNetworksDeleteDNSServicePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeleteDNSServicePoller + + // 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 WorkloadNetworksDeleteDNSServicePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeleteDNSServiceResponse, error) { + respType := WorkloadNetworksDeleteDNSServiceResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeleteDNSServicePollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeleteDNSServicePollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeleteDNSService", token, client.pl, client.deleteDNSServiceHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeleteDNSServicePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeleteDNSServiceResponse contains the response from method WorkloadNetworks.DeleteDNSService. +type WorkloadNetworksDeleteDNSServiceResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksDeleteDNSZonePollerResponse contains the response from method WorkloadNetworks.DeleteDNSZone. +type WorkloadNetworksDeleteDNSZonePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeleteDNSZonePoller + + // 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 WorkloadNetworksDeleteDNSZonePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeleteDNSZoneResponse, error) { + respType := WorkloadNetworksDeleteDNSZoneResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeleteDNSZonePollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeleteDNSZonePollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeleteDNSZone", token, client.pl, client.deleteDNSZoneHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeleteDNSZonePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeleteDNSZoneResponse contains the response from method WorkloadNetworks.DeleteDNSZone. +type WorkloadNetworksDeleteDNSZoneResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksDeleteDhcpPollerResponse contains the response from method WorkloadNetworks.DeleteDhcp. +type WorkloadNetworksDeleteDhcpPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeleteDhcpPoller + + // 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 WorkloadNetworksDeleteDhcpPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeleteDhcpResponse, error) { + respType := WorkloadNetworksDeleteDhcpResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeleteDhcpPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeleteDhcpPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeleteDhcp", token, client.pl, client.deleteDhcpHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeleteDhcpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeleteDhcpResponse contains the response from method WorkloadNetworks.DeleteDhcp. +type WorkloadNetworksDeleteDhcpResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksDeletePortMirroringPollerResponse contains the response from method WorkloadNetworks.DeletePortMirroring. +type WorkloadNetworksDeletePortMirroringPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeletePortMirroringPoller + + // 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 WorkloadNetworksDeletePortMirroringPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeletePortMirroringResponse, error) { + respType := WorkloadNetworksDeletePortMirroringResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeletePortMirroringPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeletePortMirroringPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeletePortMirroring", token, client.pl, client.deletePortMirroringHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeletePortMirroringPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeletePortMirroringResponse contains the response from method WorkloadNetworks.DeletePortMirroring. +type WorkloadNetworksDeletePortMirroringResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksDeletePublicIPPollerResponse contains the response from method WorkloadNetworks.DeletePublicIP. +type WorkloadNetworksDeletePublicIPPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeletePublicIPPoller + + // 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 WorkloadNetworksDeletePublicIPPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeletePublicIPResponse, error) { + respType := WorkloadNetworksDeletePublicIPResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeletePublicIPPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeletePublicIPPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeletePublicIP", token, client.pl, client.deletePublicIPHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeletePublicIPPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeletePublicIPResponse contains the response from method WorkloadNetworks.DeletePublicIP. +type WorkloadNetworksDeletePublicIPResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksDeleteSegmentPollerResponse contains the response from method WorkloadNetworks.DeleteSegment. +type WorkloadNetworksDeleteSegmentPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeleteSegmentPoller + + // 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 WorkloadNetworksDeleteSegmentPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeleteSegmentResponse, error) { + respType := WorkloadNetworksDeleteSegmentResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeleteSegmentPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeleteSegmentPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeleteSegment", token, client.pl, client.deleteSegmentHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeleteSegmentPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeleteSegmentResponse contains the response from method WorkloadNetworks.DeleteSegment. +type WorkloadNetworksDeleteSegmentResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksDeleteVMGroupPollerResponse contains the response from method WorkloadNetworks.DeleteVMGroup. +type WorkloadNetworksDeleteVMGroupPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksDeleteVMGroupPoller + + // 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 WorkloadNetworksDeleteVMGroupPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksDeleteVMGroupResponse, error) { + respType := WorkloadNetworksDeleteVMGroupResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksDeleteVMGroupPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksDeleteVMGroupPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.DeleteVMGroup", token, client.pl, client.deleteVMGroupHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksDeleteVMGroupPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksDeleteVMGroupResponse contains the response from method WorkloadNetworks.DeleteVMGroup. +type WorkloadNetworksDeleteVMGroupResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetDNSServiceResponse contains the response from method WorkloadNetworks.GetDNSService. +type WorkloadNetworksGetDNSServiceResponse struct { + WorkloadNetworksGetDNSServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetDNSServiceResult contains the result from method WorkloadNetworks.GetDNSService. +type WorkloadNetworksGetDNSServiceResult struct { + WorkloadNetworkDNSService +} + +// WorkloadNetworksGetDNSZoneResponse contains the response from method WorkloadNetworks.GetDNSZone. +type WorkloadNetworksGetDNSZoneResponse struct { + WorkloadNetworksGetDNSZoneResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetDNSZoneResult contains the result from method WorkloadNetworks.GetDNSZone. +type WorkloadNetworksGetDNSZoneResult struct { + WorkloadNetworkDNSZone +} + +// WorkloadNetworksGetDhcpResponse contains the response from method WorkloadNetworks.GetDhcp. +type WorkloadNetworksGetDhcpResponse struct { + WorkloadNetworksGetDhcpResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetDhcpResult contains the result from method WorkloadNetworks.GetDhcp. +type WorkloadNetworksGetDhcpResult struct { + WorkloadNetworkDhcp +} + +// WorkloadNetworksGetGatewayResponse contains the response from method WorkloadNetworks.GetGateway. +type WorkloadNetworksGetGatewayResponse struct { + WorkloadNetworksGetGatewayResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetGatewayResult contains the result from method WorkloadNetworks.GetGateway. +type WorkloadNetworksGetGatewayResult struct { + WorkloadNetworkGateway +} + +// WorkloadNetworksGetPortMirroringResponse contains the response from method WorkloadNetworks.GetPortMirroring. +type WorkloadNetworksGetPortMirroringResponse struct { + WorkloadNetworksGetPortMirroringResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetPortMirroringResult contains the result from method WorkloadNetworks.GetPortMirroring. +type WorkloadNetworksGetPortMirroringResult struct { + WorkloadNetworkPortMirroring +} + +// WorkloadNetworksGetPublicIPResponse contains the response from method WorkloadNetworks.GetPublicIP. +type WorkloadNetworksGetPublicIPResponse struct { + WorkloadNetworksGetPublicIPResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetPublicIPResult contains the result from method WorkloadNetworks.GetPublicIP. +type WorkloadNetworksGetPublicIPResult struct { + WorkloadNetworkPublicIP +} + +// WorkloadNetworksGetSegmentResponse contains the response from method WorkloadNetworks.GetSegment. +type WorkloadNetworksGetSegmentResponse struct { + WorkloadNetworksGetSegmentResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetSegmentResult contains the result from method WorkloadNetworks.GetSegment. +type WorkloadNetworksGetSegmentResult struct { + WorkloadNetworkSegment +} + +// WorkloadNetworksGetVMGroupResponse contains the response from method WorkloadNetworks.GetVMGroup. +type WorkloadNetworksGetVMGroupResponse struct { + WorkloadNetworksGetVMGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetVMGroupResult contains the result from method WorkloadNetworks.GetVMGroup. +type WorkloadNetworksGetVMGroupResult struct { + WorkloadNetworkVMGroup +} + +// WorkloadNetworksGetVirtualMachineResponse contains the response from method WorkloadNetworks.GetVirtualMachine. +type WorkloadNetworksGetVirtualMachineResponse struct { + WorkloadNetworksGetVirtualMachineResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksGetVirtualMachineResult contains the result from method WorkloadNetworks.GetVirtualMachine. +type WorkloadNetworksGetVirtualMachineResult struct { + WorkloadNetworkVirtualMachine +} + +// WorkloadNetworksListDNSServicesResponse contains the response from method WorkloadNetworks.ListDNSServices. +type WorkloadNetworksListDNSServicesResponse struct { + WorkloadNetworksListDNSServicesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListDNSServicesResult contains the result from method WorkloadNetworks.ListDNSServices. +type WorkloadNetworksListDNSServicesResult struct { + WorkloadNetworkDNSServicesList +} + +// WorkloadNetworksListDNSZonesResponse contains the response from method WorkloadNetworks.ListDNSZones. +type WorkloadNetworksListDNSZonesResponse struct { + WorkloadNetworksListDNSZonesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListDNSZonesResult contains the result from method WorkloadNetworks.ListDNSZones. +type WorkloadNetworksListDNSZonesResult struct { + WorkloadNetworkDNSZonesList +} + +// WorkloadNetworksListDhcpResponse contains the response from method WorkloadNetworks.ListDhcp. +type WorkloadNetworksListDhcpResponse struct { + WorkloadNetworksListDhcpResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListDhcpResult contains the result from method WorkloadNetworks.ListDhcp. +type WorkloadNetworksListDhcpResult struct { + WorkloadNetworkDhcpList +} + +// WorkloadNetworksListGatewaysResponse contains the response from method WorkloadNetworks.ListGateways. +type WorkloadNetworksListGatewaysResponse struct { + WorkloadNetworksListGatewaysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListGatewaysResult contains the result from method WorkloadNetworks.ListGateways. +type WorkloadNetworksListGatewaysResult struct { + WorkloadNetworkGatewayList +} + +// WorkloadNetworksListPortMirroringResponse contains the response from method WorkloadNetworks.ListPortMirroring. +type WorkloadNetworksListPortMirroringResponse struct { + WorkloadNetworksListPortMirroringResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListPortMirroringResult contains the result from method WorkloadNetworks.ListPortMirroring. +type WorkloadNetworksListPortMirroringResult struct { + WorkloadNetworkPortMirroringList +} + +// WorkloadNetworksListPublicIPsResponse contains the response from method WorkloadNetworks.ListPublicIPs. +type WorkloadNetworksListPublicIPsResponse struct { + WorkloadNetworksListPublicIPsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListPublicIPsResult contains the result from method WorkloadNetworks.ListPublicIPs. +type WorkloadNetworksListPublicIPsResult struct { + WorkloadNetworkPublicIPsList +} + +// WorkloadNetworksListSegmentsResponse contains the response from method WorkloadNetworks.ListSegments. +type WorkloadNetworksListSegmentsResponse struct { + WorkloadNetworksListSegmentsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListSegmentsResult contains the result from method WorkloadNetworks.ListSegments. +type WorkloadNetworksListSegmentsResult struct { + WorkloadNetworkSegmentsList +} + +// WorkloadNetworksListVMGroupsResponse contains the response from method WorkloadNetworks.ListVMGroups. +type WorkloadNetworksListVMGroupsResponse struct { + WorkloadNetworksListVMGroupsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListVMGroupsResult contains the result from method WorkloadNetworks.ListVMGroups. +type WorkloadNetworksListVMGroupsResult struct { + WorkloadNetworkVMGroupsList +} + +// WorkloadNetworksListVirtualMachinesResponse contains the response from method WorkloadNetworks.ListVirtualMachines. +type WorkloadNetworksListVirtualMachinesResponse struct { + WorkloadNetworksListVirtualMachinesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksListVirtualMachinesResult contains the result from method WorkloadNetworks.ListVirtualMachines. +type WorkloadNetworksListVirtualMachinesResult struct { + WorkloadNetworkVirtualMachinesList +} + +// WorkloadNetworksUpdateDNSServicePollerResponse contains the response from method WorkloadNetworks.UpdateDNSService. +type WorkloadNetworksUpdateDNSServicePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksUpdateDNSServicePoller + + // 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 WorkloadNetworksUpdateDNSServicePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksUpdateDNSServiceResponse, error) { + respType := WorkloadNetworksUpdateDNSServiceResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkDNSService) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksUpdateDNSServicePollerResponse from the provided client and resume token. +func (l *WorkloadNetworksUpdateDNSServicePollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.UpdateDNSService", token, client.pl, client.updateDNSServiceHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksUpdateDNSServicePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksUpdateDNSServiceResponse contains the response from method WorkloadNetworks.UpdateDNSService. +type WorkloadNetworksUpdateDNSServiceResponse struct { + WorkloadNetworksUpdateDNSServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksUpdateDNSServiceResult contains the result from method WorkloadNetworks.UpdateDNSService. +type WorkloadNetworksUpdateDNSServiceResult struct { + WorkloadNetworkDNSService +} + +// WorkloadNetworksUpdateDNSZonePollerResponse contains the response from method WorkloadNetworks.UpdateDNSZone. +type WorkloadNetworksUpdateDNSZonePollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksUpdateDNSZonePoller + + // 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 WorkloadNetworksUpdateDNSZonePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksUpdateDNSZoneResponse, error) { + respType := WorkloadNetworksUpdateDNSZoneResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkDNSZone) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksUpdateDNSZonePollerResponse from the provided client and resume token. +func (l *WorkloadNetworksUpdateDNSZonePollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.UpdateDNSZone", token, client.pl, client.updateDNSZoneHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksUpdateDNSZonePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksUpdateDNSZoneResponse contains the response from method WorkloadNetworks.UpdateDNSZone. +type WorkloadNetworksUpdateDNSZoneResponse struct { + WorkloadNetworksUpdateDNSZoneResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksUpdateDNSZoneResult contains the result from method WorkloadNetworks.UpdateDNSZone. +type WorkloadNetworksUpdateDNSZoneResult struct { + WorkloadNetworkDNSZone +} + +// WorkloadNetworksUpdateDhcpPollerResponse contains the response from method WorkloadNetworks.UpdateDhcp. +type WorkloadNetworksUpdateDhcpPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksUpdateDhcpPoller + + // 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 WorkloadNetworksUpdateDhcpPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksUpdateDhcpResponse, error) { + respType := WorkloadNetworksUpdateDhcpResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkDhcp) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksUpdateDhcpPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksUpdateDhcpPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.UpdateDhcp", token, client.pl, client.updateDhcpHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksUpdateDhcpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksUpdateDhcpResponse contains the response from method WorkloadNetworks.UpdateDhcp. +type WorkloadNetworksUpdateDhcpResponse struct { + WorkloadNetworksUpdateDhcpResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksUpdateDhcpResult contains the result from method WorkloadNetworks.UpdateDhcp. +type WorkloadNetworksUpdateDhcpResult struct { + WorkloadNetworkDhcp +} + +// WorkloadNetworksUpdatePortMirroringPollerResponse contains the response from method WorkloadNetworks.UpdatePortMirroring. +type WorkloadNetworksUpdatePortMirroringPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksUpdatePortMirroringPoller + + // 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 WorkloadNetworksUpdatePortMirroringPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksUpdatePortMirroringResponse, error) { + respType := WorkloadNetworksUpdatePortMirroringResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkPortMirroring) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksUpdatePortMirroringPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksUpdatePortMirroringPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.UpdatePortMirroring", token, client.pl, client.updatePortMirroringHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksUpdatePortMirroringPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksUpdatePortMirroringResponse contains the response from method WorkloadNetworks.UpdatePortMirroring. +type WorkloadNetworksUpdatePortMirroringResponse struct { + WorkloadNetworksUpdatePortMirroringResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksUpdatePortMirroringResult contains the result from method WorkloadNetworks.UpdatePortMirroring. +type WorkloadNetworksUpdatePortMirroringResult struct { + WorkloadNetworkPortMirroring +} + +// WorkloadNetworksUpdateSegmentsPollerResponse contains the response from method WorkloadNetworks.UpdateSegments. +type WorkloadNetworksUpdateSegmentsPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksUpdateSegmentsPoller + + // 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 WorkloadNetworksUpdateSegmentsPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksUpdateSegmentsResponse, error) { + respType := WorkloadNetworksUpdateSegmentsResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkSegment) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksUpdateSegmentsPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksUpdateSegmentsPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.UpdateSegments", token, client.pl, client.updateSegmentsHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksUpdateSegmentsPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksUpdateSegmentsResponse contains the response from method WorkloadNetworks.UpdateSegments. +type WorkloadNetworksUpdateSegmentsResponse struct { + WorkloadNetworksUpdateSegmentsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksUpdateSegmentsResult contains the result from method WorkloadNetworks.UpdateSegments. +type WorkloadNetworksUpdateSegmentsResult struct { + WorkloadNetworkSegment +} + +// WorkloadNetworksUpdateVMGroupPollerResponse contains the response from method WorkloadNetworks.UpdateVMGroup. +type WorkloadNetworksUpdateVMGroupPollerResponse struct { + // Poller contains an initialized poller. + Poller *WorkloadNetworksUpdateVMGroupPoller + + // 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 WorkloadNetworksUpdateVMGroupPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WorkloadNetworksUpdateVMGroupResponse, error) { + respType := WorkloadNetworksUpdateVMGroupResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.WorkloadNetworkVMGroup) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a WorkloadNetworksUpdateVMGroupPollerResponse from the provided client and resume token. +func (l *WorkloadNetworksUpdateVMGroupPollerResponse) Resume(ctx context.Context, client *WorkloadNetworksClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("WorkloadNetworksClient.UpdateVMGroup", token, client.pl, client.updateVMGroupHandleError) + if err != nil { + return err + } + poller := &WorkloadNetworksUpdateVMGroupPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// WorkloadNetworksUpdateVMGroupResponse contains the response from method WorkloadNetworks.UpdateVMGroup. +type WorkloadNetworksUpdateVMGroupResponse struct { + WorkloadNetworksUpdateVMGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkloadNetworksUpdateVMGroupResult contains the result from method WorkloadNetworks.UpdateVMGroup. +type WorkloadNetworksUpdateVMGroupResult struct { + WorkloadNetworkVMGroup +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_scriptcmdlets_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_scriptcmdlets_client.go new file mode 100644 index 000000000000..3d7d4f9428ff --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_scriptcmdlets_client.go @@ -0,0 +1,182 @@ +//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 armavs + +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" +) + +// ScriptCmdletsClient contains the methods for the ScriptCmdlets group. +// Don't use this type directly, use NewScriptCmdletsClient() instead. +type ScriptCmdletsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewScriptCmdletsClient creates a new instance of ScriptCmdletsClient with the specified values. +func NewScriptCmdletsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ScriptCmdletsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ScriptCmdletsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Return information about a script cmdlet resource in a specific package on a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptCmdletsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, scriptCmdletName string, options *ScriptCmdletsGetOptions) (ScriptCmdletsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, scriptPackageName, scriptCmdletName, options) + if err != nil { + return ScriptCmdletsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptCmdletsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptCmdletsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ScriptCmdletsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, scriptCmdletName string, options *ScriptCmdletsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptPackageName == "" { + return nil, errors.New("parameter scriptPackageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptPackageName}", url.PathEscape(scriptPackageName)) + if scriptCmdletName == "" { + return nil, errors.New("parameter scriptCmdletName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptCmdletName}", url.PathEscape(scriptCmdletName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScriptCmdletsClient) getHandleResponse(resp *http.Response) (ScriptCmdletsGetResponse, error) { + result := ScriptCmdletsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptCmdlet); err != nil { + return ScriptCmdletsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ScriptCmdletsClient) 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 - List script cmdlet resources available for a private cloud to create a script execution resource on a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptCmdletsClient) List(resourceGroupName string, privateCloudName string, scriptPackageName string, options *ScriptCmdletsListOptions) *ScriptCmdletsListPager { + return &ScriptCmdletsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, scriptPackageName, options) + }, + advancer: func(ctx context.Context, resp ScriptCmdletsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ScriptCmdletsList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ScriptCmdletsClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, options *ScriptCmdletsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptPackageName == "" { + return nil, errors.New("parameter scriptPackageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptPackageName}", url.PathEscape(scriptPackageName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ScriptCmdletsClient) listHandleResponse(resp *http.Response) (ScriptCmdletsListResponse, error) { + result := ScriptCmdletsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptCmdletsList); err != nil { + return ScriptCmdletsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ScriptCmdletsClient) 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/avs/armavs/zz_generated_scriptexecutions_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_scriptexecutions_client.go new file mode 100644 index 000000000000..0415e7ca719e --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_scriptexecutions_client.go @@ -0,0 +1,406 @@ +//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 armavs + +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" +) + +// ScriptExecutionsClient contains the methods for the ScriptExecutions group. +// Don't use this type directly, use NewScriptExecutionsClient() instead. +type ScriptExecutionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewScriptExecutionsClient creates a new instance of ScriptExecutionsClient with the specified values. +func NewScriptExecutionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ScriptExecutionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ScriptExecutionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a script execution in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution ScriptExecution, options *ScriptExecutionsBeginCreateOrUpdateOptions) (ScriptExecutionsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, privateCloudName, scriptExecutionName, scriptExecution, options) + if err != nil { + return ScriptExecutionsCreateOrUpdatePollerResponse{}, err + } + result := ScriptExecutionsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ScriptExecutionsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ScriptExecutionsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ScriptExecutionsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a script execution in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution ScriptExecution, options *ScriptExecutionsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, privateCloudName, scriptExecutionName, scriptExecution, 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 *ScriptExecutionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution ScriptExecution, options *ScriptExecutionsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptExecutionName == "" { + return nil, errors.New("parameter scriptExecutionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptExecutionName}", url.PathEscape(scriptExecutionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, scriptExecution) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ScriptExecutionsClient) 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 - Cancel a ScriptExecution in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) BeginDelete(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsBeginDeleteOptions) (ScriptExecutionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, privateCloudName, scriptExecutionName, options) + if err != nil { + return ScriptExecutionsDeletePollerResponse{}, err + } + result := ScriptExecutionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ScriptExecutionsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return ScriptExecutionsDeletePollerResponse{}, err + } + result.Poller = &ScriptExecutionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Cancel a ScriptExecution in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) deleteOperation(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, privateCloudName, scriptExecutionName, 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 *ScriptExecutionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptExecutionName == "" { + return nil, errors.New("parameter scriptExecutionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptExecutionName}", url.PathEscape(scriptExecutionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ScriptExecutionsClient) 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 - Get an script execution by name in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsGetOptions) (ScriptExecutionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, scriptExecutionName, options) + if err != nil { + return ScriptExecutionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptExecutionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptExecutionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ScriptExecutionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptExecutionName == "" { + return nil, errors.New("parameter scriptExecutionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptExecutionName}", url.PathEscape(scriptExecutionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScriptExecutionsClient) getHandleResponse(resp *http.Response) (ScriptExecutionsGetResponse, error) { + result := ScriptExecutionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptExecution); err != nil { + return ScriptExecutionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ScriptExecutionsClient) 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) +} + +// GetExecutionLogs - Return the logs for a script execution resource +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) GetExecutionLogs(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsGetExecutionLogsOptions) (ScriptExecutionsGetExecutionLogsResponse, error) { + req, err := client.getExecutionLogsCreateRequest(ctx, resourceGroupName, privateCloudName, scriptExecutionName, options) + if err != nil { + return ScriptExecutionsGetExecutionLogsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptExecutionsGetExecutionLogsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptExecutionsGetExecutionLogsResponse{}, client.getExecutionLogsHandleError(resp) + } + return client.getExecutionLogsHandleResponse(resp) +} + +// getExecutionLogsCreateRequest creates the GetExecutionLogs request. +func (client *ScriptExecutionsClient) getExecutionLogsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsGetExecutionLogsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptExecutionName == "" { + return nil, errors.New("parameter scriptExecutionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptExecutionName}", url.PathEscape(scriptExecutionName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.ScriptOutputStreamType != nil { + return req, runtime.MarshalAsJSON(req, options.ScriptOutputStreamType) + } + return req, nil +} + +// getExecutionLogsHandleResponse handles the GetExecutionLogs response. +func (client *ScriptExecutionsClient) getExecutionLogsHandleResponse(resp *http.Response) (ScriptExecutionsGetExecutionLogsResponse, error) { + result := ScriptExecutionsGetExecutionLogsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptExecution); err != nil { + return ScriptExecutionsGetExecutionLogsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getExecutionLogsHandleError handles the GetExecutionLogs error response. +func (client *ScriptExecutionsClient) getExecutionLogsHandleError(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 - List script executions in a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptExecutionsClient) List(resourceGroupName string, privateCloudName string, options *ScriptExecutionsListOptions) *ScriptExecutionsListPager { + return &ScriptExecutionsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp ScriptExecutionsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ScriptExecutionsList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ScriptExecutionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *ScriptExecutionsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ScriptExecutionsClient) listHandleResponse(resp *http.Response) (ScriptExecutionsListResponse, error) { + result := ScriptExecutionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptExecutionsList); err != nil { + return ScriptExecutionsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ScriptExecutionsClient) 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/avs/armavs/zz_generated_scriptpackages_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_scriptpackages_client.go new file mode 100644 index 000000000000..684331f048df --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_scriptpackages_client.go @@ -0,0 +1,174 @@ +//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 armavs + +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" +) + +// ScriptPackagesClient contains the methods for the ScriptPackages group. +// Don't use this type directly, use NewScriptPackagesClient() instead. +type ScriptPackagesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewScriptPackagesClient creates a new instance of ScriptPackagesClient with the specified values. +func NewScriptPackagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ScriptPackagesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ScriptPackagesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get a script package available to run on a private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptPackagesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, options *ScriptPackagesGetOptions) (ScriptPackagesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, scriptPackageName, options) + if err != nil { + return ScriptPackagesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ScriptPackagesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ScriptPackagesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ScriptPackagesClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, options *ScriptPackagesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if scriptPackageName == "" { + return nil, errors.New("parameter scriptPackageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptPackageName}", url.PathEscape(scriptPackageName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScriptPackagesClient) getHandleResponse(resp *http.Response) (ScriptPackagesGetResponse, error) { + result := ScriptPackagesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptPackage); err != nil { + return ScriptPackagesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ScriptPackagesClient) 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 - List script packages available to run on the private cloud +// If the operation fails it returns the *CloudError error type. +func (client *ScriptPackagesClient) List(resourceGroupName string, privateCloudName string, options *ScriptPackagesListOptions) *ScriptPackagesListPager { + return &ScriptPackagesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp ScriptPackagesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ScriptPackagesList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ScriptPackagesClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *ScriptPackagesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ScriptPackagesClient) listHandleResponse(resp *http.Response) (ScriptPackagesListResponse, error) { + result := ScriptPackagesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptPackagesList); err != nil { + return ScriptPackagesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ScriptPackagesClient) 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/avs/armavs/zz_generated_time_rfc3339.go b/sdk/resourcemanager/avs/armavs/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..27f75909de0d --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/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 armavs + +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 +} diff --git a/sdk/resourcemanager/avs/armavs/zz_generated_virtualmachines_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_virtualmachines_client.go new file mode 100644 index 000000000000..8842be5c827b --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_virtualmachines_client.go @@ -0,0 +1,266 @@ +//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 armavs + +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" +) + +// VirtualMachinesClient contains the methods for the VirtualMachines group. +// Don't use this type directly, use NewVirtualMachinesClient() instead. +type VirtualMachinesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVirtualMachinesClient creates a new instance of VirtualMachinesClient with the specified values. +func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VirtualMachinesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VirtualMachinesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get a virtual machine by id in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, virtualMachineID string, options *VirtualMachinesGetOptions) (VirtualMachinesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, virtualMachineID, options) + if err != nil { + return VirtualMachinesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachinesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachinesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, virtualMachineID string, options *VirtualMachinesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if virtualMachineID == "" { + return nil, errors.New("parameter virtualMachineID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineId}", url.PathEscape(virtualMachineID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (VirtualMachinesGetResponse, error) { + result := VirtualMachinesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachine); err != nil { + return VirtualMachinesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *VirtualMachinesClient) 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 - List of virtual machines in a private cloud cluster +// If the operation fails it returns the *CloudError error type. +func (client *VirtualMachinesClient) List(resourceGroupName string, privateCloudName string, clusterName string, options *VirtualMachinesListOptions) *VirtualMachinesListPager { + return &VirtualMachinesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, options) + }, + advancer: func(ctx context.Context, resp VirtualMachinesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.VirtualMachinesList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *VirtualMachinesClient) listCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, options *VirtualMachinesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VirtualMachinesClient) listHandleResponse(resp *http.Response) (VirtualMachinesListResponse, error) { + result := VirtualMachinesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachinesList); err != nil { + return VirtualMachinesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *VirtualMachinesClient) 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) +} + +// BeginRestrictMovement - Enable or disable DRS-driven VM movement restriction +// If the operation fails it returns the *CloudError error type. +func (client *VirtualMachinesClient) BeginRestrictMovement(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, virtualMachineID string, restrictMovement VirtualMachineRestrictMovement, options *VirtualMachinesBeginRestrictMovementOptions) (VirtualMachinesRestrictMovementPollerResponse, error) { + resp, err := client.restrictMovement(ctx, resourceGroupName, privateCloudName, clusterName, virtualMachineID, restrictMovement, options) + if err != nil { + return VirtualMachinesRestrictMovementPollerResponse{}, err + } + result := VirtualMachinesRestrictMovementPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VirtualMachinesClient.RestrictMovement", "", resp, client.pl, client.restrictMovementHandleError) + if err != nil { + return VirtualMachinesRestrictMovementPollerResponse{}, err + } + result.Poller = &VirtualMachinesRestrictMovementPoller{ + pt: pt, + } + return result, nil +} + +// RestrictMovement - Enable or disable DRS-driven VM movement restriction +// If the operation fails it returns the *CloudError error type. +func (client *VirtualMachinesClient) restrictMovement(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, virtualMachineID string, restrictMovement VirtualMachineRestrictMovement, options *VirtualMachinesBeginRestrictMovementOptions) (*http.Response, error) { + req, err := client.restrictMovementCreateRequest(ctx, resourceGroupName, privateCloudName, clusterName, virtualMachineID, restrictMovement, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, client.restrictMovementHandleError(resp) + } + return resp, nil +} + +// restrictMovementCreateRequest creates the RestrictMovement request. +func (client *VirtualMachinesClient) restrictMovementCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, virtualMachineID string, restrictMovement VirtualMachineRestrictMovement, options *VirtualMachinesBeginRestrictMovementOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if virtualMachineID == "" { + return nil, errors.New("parameter virtualMachineID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineId}", url.PathEscape(virtualMachineID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, restrictMovement) +} + +// restrictMovementHandleError handles the RestrictMovement error response. +func (client *VirtualMachinesClient) restrictMovementHandleError(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/avs/armavs/zz_generated_workloadnetworks_client.go b/sdk/resourcemanager/avs/armavs/zz_generated_workloadnetworks_client.go new file mode 100644 index 000000000000..3ee56cf910b8 --- /dev/null +++ b/sdk/resourcemanager/avs/armavs/zz_generated_workloadnetworks_client.go @@ -0,0 +1,2822 @@ +//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 armavs + +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" +) + +// WorkloadNetworksClient contains the methods for the WorkloadNetworks group. +// Don't use this type directly, use NewWorkloadNetworksClient() instead. +type WorkloadNetworksClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewWorkloadNetworksClient creates a new instance of WorkloadNetworksClient with the specified values. +func NewWorkloadNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *WorkloadNetworksClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &WorkloadNetworksClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateDNSService - Create a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService, options *WorkloadNetworksBeginCreateDNSServiceOptions) (WorkloadNetworksCreateDNSServicePollerResponse, error) { + resp, err := client.createDNSService(ctx, resourceGroupName, privateCloudName, dnsServiceID, workloadNetworkDNSService, options) + if err != nil { + return WorkloadNetworksCreateDNSServicePollerResponse{}, err + } + result := WorkloadNetworksCreateDNSServicePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreateDNSService", "", resp, client.pl, client.createDNSServiceHandleError) + if err != nil { + return WorkloadNetworksCreateDNSServicePollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreateDNSServicePoller{ + pt: pt, + } + return result, nil +} + +// CreateDNSService - Create a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService, options *WorkloadNetworksBeginCreateDNSServiceOptions) (*http.Response, error) { + req, err := client.createDNSServiceCreateRequest(ctx, resourceGroupName, privateCloudName, dnsServiceID, workloadNetworkDNSService, 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.createDNSServiceHandleError(resp) + } + return resp, nil +} + +// createDNSServiceCreateRequest creates the CreateDNSService request. +func (client *WorkloadNetworksClient) createDNSServiceCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService, options *WorkloadNetworksBeginCreateDNSServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dnsServiceID == "" { + return nil, errors.New("parameter dnsServiceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsServiceId}", url.PathEscape(dnsServiceID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkDNSService) +} + +// createDNSServiceHandleError handles the CreateDNSService error response. +func (client *WorkloadNetworksClient) createDNSServiceHandleError(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) +} + +// BeginCreateDNSZone - Create a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone, options *WorkloadNetworksBeginCreateDNSZoneOptions) (WorkloadNetworksCreateDNSZonePollerResponse, error) { + resp, err := client.createDNSZone(ctx, resourceGroupName, privateCloudName, dnsZoneID, workloadNetworkDNSZone, options) + if err != nil { + return WorkloadNetworksCreateDNSZonePollerResponse{}, err + } + result := WorkloadNetworksCreateDNSZonePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreateDNSZone", "", resp, client.pl, client.createDNSZoneHandleError) + if err != nil { + return WorkloadNetworksCreateDNSZonePollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreateDNSZonePoller{ + pt: pt, + } + return result, nil +} + +// CreateDNSZone - Create a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone, options *WorkloadNetworksBeginCreateDNSZoneOptions) (*http.Response, error) { + req, err := client.createDNSZoneCreateRequest(ctx, resourceGroupName, privateCloudName, dnsZoneID, workloadNetworkDNSZone, 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.createDNSZoneHandleError(resp) + } + return resp, nil +} + +// createDNSZoneCreateRequest creates the CreateDNSZone request. +func (client *WorkloadNetworksClient) createDNSZoneCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone, options *WorkloadNetworksBeginCreateDNSZoneOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dnsZoneID == "" { + return nil, errors.New("parameter dnsZoneID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsZoneId}", url.PathEscape(dnsZoneID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkDNSZone) +} + +// createDNSZoneHandleError handles the CreateDNSZone error response. +func (client *WorkloadNetworksClient) createDNSZoneHandleError(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) +} + +// BeginCreateDhcp - Create dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp, options *WorkloadNetworksBeginCreateDhcpOptions) (WorkloadNetworksCreateDhcpPollerResponse, error) { + resp, err := client.createDhcp(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp, options) + if err != nil { + return WorkloadNetworksCreateDhcpPollerResponse{}, err + } + result := WorkloadNetworksCreateDhcpPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreateDhcp", "", resp, client.pl, client.createDhcpHandleError) + if err != nil { + return WorkloadNetworksCreateDhcpPollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreateDhcpPoller{ + pt: pt, + } + return result, nil +} + +// CreateDhcp - Create dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp, options *WorkloadNetworksBeginCreateDhcpOptions) (*http.Response, error) { + req, err := client.createDhcpCreateRequest(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp, 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.createDhcpHandleError(resp) + } + return resp, nil +} + +// createDhcpCreateRequest creates the CreateDhcp request. +func (client *WorkloadNetworksClient) createDhcpCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp, options *WorkloadNetworksBeginCreateDhcpOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dhcpID == "" { + return nil, errors.New("parameter dhcpID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dhcpId}", url.PathEscape(dhcpID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkDhcp) +} + +// createDhcpHandleError handles the CreateDhcp error response. +func (client *WorkloadNetworksClient) createDhcpHandleError(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) +} + +// BeginCreatePortMirroring - Create a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring, options *WorkloadNetworksBeginCreatePortMirroringOptions) (WorkloadNetworksCreatePortMirroringPollerResponse, error) { + resp, err := client.createPortMirroring(ctx, resourceGroupName, privateCloudName, portMirroringID, workloadNetworkPortMirroring, options) + if err != nil { + return WorkloadNetworksCreatePortMirroringPollerResponse{}, err + } + result := WorkloadNetworksCreatePortMirroringPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreatePortMirroring", "", resp, client.pl, client.createPortMirroringHandleError) + if err != nil { + return WorkloadNetworksCreatePortMirroringPollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreatePortMirroringPoller{ + pt: pt, + } + return result, nil +} + +// CreatePortMirroring - Create a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createPortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring, options *WorkloadNetworksBeginCreatePortMirroringOptions) (*http.Response, error) { + req, err := client.createPortMirroringCreateRequest(ctx, resourceGroupName, privateCloudName, portMirroringID, workloadNetworkPortMirroring, 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.createPortMirroringHandleError(resp) + } + return resp, nil +} + +// createPortMirroringCreateRequest creates the CreatePortMirroring request. +func (client *WorkloadNetworksClient) createPortMirroringCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring, options *WorkloadNetworksBeginCreatePortMirroringOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if portMirroringID == "" { + return nil, errors.New("parameter portMirroringID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portMirroringId}", url.PathEscape(portMirroringID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkPortMirroring) +} + +// createPortMirroringHandleError handles the CreatePortMirroring error response. +func (client *WorkloadNetworksClient) createPortMirroringHandleError(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) +} + +// BeginCreatePublicIP - Create a Public IP Block by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreatePublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, workloadNetworkPublicIP WorkloadNetworkPublicIP, options *WorkloadNetworksBeginCreatePublicIPOptions) (WorkloadNetworksCreatePublicIPPollerResponse, error) { + resp, err := client.createPublicIP(ctx, resourceGroupName, privateCloudName, publicIPID, workloadNetworkPublicIP, options) + if err != nil { + return WorkloadNetworksCreatePublicIPPollerResponse{}, err + } + result := WorkloadNetworksCreatePublicIPPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreatePublicIP", "", resp, client.pl, client.createPublicIPHandleError) + if err != nil { + return WorkloadNetworksCreatePublicIPPollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreatePublicIPPoller{ + pt: pt, + } + return result, nil +} + +// CreatePublicIP - Create a Public IP Block by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createPublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, workloadNetworkPublicIP WorkloadNetworkPublicIP, options *WorkloadNetworksBeginCreatePublicIPOptions) (*http.Response, error) { + req, err := client.createPublicIPCreateRequest(ctx, resourceGroupName, privateCloudName, publicIPID, workloadNetworkPublicIP, 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.createPublicIPHandleError(resp) + } + return resp, nil +} + +// createPublicIPCreateRequest creates the CreatePublicIP request. +func (client *WorkloadNetworksClient) createPublicIPCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, workloadNetworkPublicIP WorkloadNetworkPublicIP, options *WorkloadNetworksBeginCreatePublicIPOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if publicIPID == "" { + return nil, errors.New("parameter publicIPID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{publicIPId}", url.PathEscape(publicIPID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkPublicIP) +} + +// createPublicIPHandleError handles the CreatePublicIP error response. +func (client *WorkloadNetworksClient) createPublicIPHandleError(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) +} + +// BeginCreateSegments - Create a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment, options *WorkloadNetworksBeginCreateSegmentsOptions) (WorkloadNetworksCreateSegmentsPollerResponse, error) { + resp, err := client.createSegments(ctx, resourceGroupName, privateCloudName, segmentID, workloadNetworkSegment, options) + if err != nil { + return WorkloadNetworksCreateSegmentsPollerResponse{}, err + } + result := WorkloadNetworksCreateSegmentsPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreateSegments", "", resp, client.pl, client.createSegmentsHandleError) + if err != nil { + return WorkloadNetworksCreateSegmentsPollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreateSegmentsPoller{ + pt: pt, + } + return result, nil +} + +// CreateSegments - Create a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment, options *WorkloadNetworksBeginCreateSegmentsOptions) (*http.Response, error) { + req, err := client.createSegmentsCreateRequest(ctx, resourceGroupName, privateCloudName, segmentID, workloadNetworkSegment, 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.createSegmentsHandleError(resp) + } + return resp, nil +} + +// createSegmentsCreateRequest creates the CreateSegments request. +func (client *WorkloadNetworksClient) createSegmentsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment, options *WorkloadNetworksBeginCreateSegmentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if segmentID == "" { + return nil, errors.New("parameter segmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{segmentId}", url.PathEscape(segmentID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkSegment) +} + +// createSegmentsHandleError handles the CreateSegments error response. +func (client *WorkloadNetworksClient) createSegmentsHandleError(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) +} + +// BeginCreateVMGroup - Create a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginCreateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup, options *WorkloadNetworksBeginCreateVMGroupOptions) (WorkloadNetworksCreateVMGroupPollerResponse, error) { + resp, err := client.createVMGroup(ctx, resourceGroupName, privateCloudName, vmGroupID, workloadNetworkVMGroup, options) + if err != nil { + return WorkloadNetworksCreateVMGroupPollerResponse{}, err + } + result := WorkloadNetworksCreateVMGroupPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.CreateVMGroup", "", resp, client.pl, client.createVMGroupHandleError) + if err != nil { + return WorkloadNetworksCreateVMGroupPollerResponse{}, err + } + result.Poller = &WorkloadNetworksCreateVMGroupPoller{ + pt: pt, + } + return result, nil +} + +// CreateVMGroup - Create a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) createVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup, options *WorkloadNetworksBeginCreateVMGroupOptions) (*http.Response, error) { + req, err := client.createVMGroupCreateRequest(ctx, resourceGroupName, privateCloudName, vmGroupID, workloadNetworkVMGroup, 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.createVMGroupHandleError(resp) + } + return resp, nil +} + +// createVMGroupCreateRequest creates the CreateVMGroup request. +func (client *WorkloadNetworksClient) createVMGroupCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup, options *WorkloadNetworksBeginCreateVMGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if vmGroupID == "" { + return nil, errors.New("parameter vmGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmGroupId}", url.PathEscape(vmGroupID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkVMGroup) +} + +// createVMGroupHandleError handles the CreateVMGroup error response. +func (client *WorkloadNetworksClient) createVMGroupHandleError(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) +} + +// BeginDeleteDNSService - Delete a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeleteDNSService(ctx context.Context, resourceGroupName string, dnsServiceID string, privateCloudName string, options *WorkloadNetworksBeginDeleteDNSServiceOptions) (WorkloadNetworksDeleteDNSServicePollerResponse, error) { + resp, err := client.deleteDNSService(ctx, resourceGroupName, dnsServiceID, privateCloudName, options) + if err != nil { + return WorkloadNetworksDeleteDNSServicePollerResponse{}, err + } + result := WorkloadNetworksDeleteDNSServicePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeleteDNSService", "", resp, client.pl, client.deleteDNSServiceHandleError) + if err != nil { + return WorkloadNetworksDeleteDNSServicePollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeleteDNSServicePoller{ + pt: pt, + } + return result, nil +} + +// DeleteDNSService - Delete a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deleteDNSService(ctx context.Context, resourceGroupName string, dnsServiceID string, privateCloudName string, options *WorkloadNetworksBeginDeleteDNSServiceOptions) (*http.Response, error) { + req, err := client.deleteDNSServiceCreateRequest(ctx, resourceGroupName, dnsServiceID, privateCloudName, 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.deleteDNSServiceHandleError(resp) + } + return resp, nil +} + +// deleteDNSServiceCreateRequest creates the DeleteDNSService request. +func (client *WorkloadNetworksClient) deleteDNSServiceCreateRequest(ctx context.Context, resourceGroupName string, dnsServiceID string, privateCloudName string, options *WorkloadNetworksBeginDeleteDNSServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}" + 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 dnsServiceID == "" { + return nil, errors.New("parameter dnsServiceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsServiceId}", url.PathEscape(dnsServiceID)) + if privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteDNSServiceHandleError handles the DeleteDNSService error response. +func (client *WorkloadNetworksClient) deleteDNSServiceHandleError(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) +} + +// BeginDeleteDNSZone - Delete a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeleteDNSZone(ctx context.Context, resourceGroupName string, dnsZoneID string, privateCloudName string, options *WorkloadNetworksBeginDeleteDNSZoneOptions) (WorkloadNetworksDeleteDNSZonePollerResponse, error) { + resp, err := client.deleteDNSZone(ctx, resourceGroupName, dnsZoneID, privateCloudName, options) + if err != nil { + return WorkloadNetworksDeleteDNSZonePollerResponse{}, err + } + result := WorkloadNetworksDeleteDNSZonePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeleteDNSZone", "", resp, client.pl, client.deleteDNSZoneHandleError) + if err != nil { + return WorkloadNetworksDeleteDNSZonePollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeleteDNSZonePoller{ + pt: pt, + } + return result, nil +} + +// DeleteDNSZone - Delete a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deleteDNSZone(ctx context.Context, resourceGroupName string, dnsZoneID string, privateCloudName string, options *WorkloadNetworksBeginDeleteDNSZoneOptions) (*http.Response, error) { + req, err := client.deleteDNSZoneCreateRequest(ctx, resourceGroupName, dnsZoneID, privateCloudName, 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.deleteDNSZoneHandleError(resp) + } + return resp, nil +} + +// deleteDNSZoneCreateRequest creates the DeleteDNSZone request. +func (client *WorkloadNetworksClient) deleteDNSZoneCreateRequest(ctx context.Context, resourceGroupName string, dnsZoneID string, privateCloudName string, options *WorkloadNetworksBeginDeleteDNSZoneOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}" + 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 dnsZoneID == "" { + return nil, errors.New("parameter dnsZoneID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsZoneId}", url.PathEscape(dnsZoneID)) + if privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteDNSZoneHandleError handles the DeleteDNSZone error response. +func (client *WorkloadNetworksClient) deleteDNSZoneHandleError(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) +} + +// BeginDeleteDhcp - Delete dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeleteDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, options *WorkloadNetworksBeginDeleteDhcpOptions) (WorkloadNetworksDeleteDhcpPollerResponse, error) { + resp, err := client.deleteDhcp(ctx, resourceGroupName, privateCloudName, dhcpID, options) + if err != nil { + return WorkloadNetworksDeleteDhcpPollerResponse{}, err + } + result := WorkloadNetworksDeleteDhcpPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeleteDhcp", "", resp, client.pl, client.deleteDhcpHandleError) + if err != nil { + return WorkloadNetworksDeleteDhcpPollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeleteDhcpPoller{ + pt: pt, + } + return result, nil +} + +// DeleteDhcp - Delete dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deleteDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, options *WorkloadNetworksBeginDeleteDhcpOptions) (*http.Response, error) { + req, err := client.deleteDhcpCreateRequest(ctx, resourceGroupName, privateCloudName, dhcpID, 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.deleteDhcpHandleError(resp) + } + return resp, nil +} + +// deleteDhcpCreateRequest creates the DeleteDhcp request. +func (client *WorkloadNetworksClient) deleteDhcpCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, options *WorkloadNetworksBeginDeleteDhcpOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dhcpID == "" { + return nil, errors.New("parameter dhcpID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dhcpId}", url.PathEscape(dhcpID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteDhcpHandleError handles the DeleteDhcp error response. +func (client *WorkloadNetworksClient) deleteDhcpHandleError(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) +} + +// BeginDeletePortMirroring - Delete a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeletePortMirroring(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string, options *WorkloadNetworksBeginDeletePortMirroringOptions) (WorkloadNetworksDeletePortMirroringPollerResponse, error) { + resp, err := client.deletePortMirroring(ctx, resourceGroupName, portMirroringID, privateCloudName, options) + if err != nil { + return WorkloadNetworksDeletePortMirroringPollerResponse{}, err + } + result := WorkloadNetworksDeletePortMirroringPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeletePortMirroring", "", resp, client.pl, client.deletePortMirroringHandleError) + if err != nil { + return WorkloadNetworksDeletePortMirroringPollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeletePortMirroringPoller{ + pt: pt, + } + return result, nil +} + +// DeletePortMirroring - Delete a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deletePortMirroring(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string, options *WorkloadNetworksBeginDeletePortMirroringOptions) (*http.Response, error) { + req, err := client.deletePortMirroringCreateRequest(ctx, resourceGroupName, portMirroringID, privateCloudName, 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.deletePortMirroringHandleError(resp) + } + return resp, nil +} + +// deletePortMirroringCreateRequest creates the DeletePortMirroring request. +func (client *WorkloadNetworksClient) deletePortMirroringCreateRequest(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string, options *WorkloadNetworksBeginDeletePortMirroringOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}" + 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 portMirroringID == "" { + return nil, errors.New("parameter portMirroringID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portMirroringId}", url.PathEscape(portMirroringID)) + if privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deletePortMirroringHandleError handles the DeletePortMirroring error response. +func (client *WorkloadNetworksClient) deletePortMirroringHandleError(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) +} + +// BeginDeletePublicIP - Delete a Public IP Block by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeletePublicIP(ctx context.Context, resourceGroupName string, publicIPID string, privateCloudName string, options *WorkloadNetworksBeginDeletePublicIPOptions) (WorkloadNetworksDeletePublicIPPollerResponse, error) { + resp, err := client.deletePublicIP(ctx, resourceGroupName, publicIPID, privateCloudName, options) + if err != nil { + return WorkloadNetworksDeletePublicIPPollerResponse{}, err + } + result := WorkloadNetworksDeletePublicIPPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeletePublicIP", "", resp, client.pl, client.deletePublicIPHandleError) + if err != nil { + return WorkloadNetworksDeletePublicIPPollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeletePublicIPPoller{ + pt: pt, + } + return result, nil +} + +// DeletePublicIP - Delete a Public IP Block by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deletePublicIP(ctx context.Context, resourceGroupName string, publicIPID string, privateCloudName string, options *WorkloadNetworksBeginDeletePublicIPOptions) (*http.Response, error) { + req, err := client.deletePublicIPCreateRequest(ctx, resourceGroupName, publicIPID, privateCloudName, 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.deletePublicIPHandleError(resp) + } + return resp, nil +} + +// deletePublicIPCreateRequest creates the DeletePublicIP request. +func (client *WorkloadNetworksClient) deletePublicIPCreateRequest(ctx context.Context, resourceGroupName string, publicIPID string, privateCloudName string, options *WorkloadNetworksBeginDeletePublicIPOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}" + 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 publicIPID == "" { + return nil, errors.New("parameter publicIPID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{publicIPId}", url.PathEscape(publicIPID)) + if privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deletePublicIPHandleError handles the DeletePublicIP error response. +func (client *WorkloadNetworksClient) deletePublicIPHandleError(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) +} + +// BeginDeleteSegment - Delete a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeleteSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, options *WorkloadNetworksBeginDeleteSegmentOptions) (WorkloadNetworksDeleteSegmentPollerResponse, error) { + resp, err := client.deleteSegment(ctx, resourceGroupName, privateCloudName, segmentID, options) + if err != nil { + return WorkloadNetworksDeleteSegmentPollerResponse{}, err + } + result := WorkloadNetworksDeleteSegmentPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeleteSegment", "", resp, client.pl, client.deleteSegmentHandleError) + if err != nil { + return WorkloadNetworksDeleteSegmentPollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeleteSegmentPoller{ + pt: pt, + } + return result, nil +} + +// DeleteSegment - Delete a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deleteSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, options *WorkloadNetworksBeginDeleteSegmentOptions) (*http.Response, error) { + req, err := client.deleteSegmentCreateRequest(ctx, resourceGroupName, privateCloudName, segmentID, 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.deleteSegmentHandleError(resp) + } + return resp, nil +} + +// deleteSegmentCreateRequest creates the DeleteSegment request. +func (client *WorkloadNetworksClient) deleteSegmentCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, options *WorkloadNetworksBeginDeleteSegmentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if segmentID == "" { + return nil, errors.New("parameter segmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{segmentId}", url.PathEscape(segmentID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteSegmentHandleError handles the DeleteSegment error response. +func (client *WorkloadNetworksClient) deleteSegmentHandleError(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) +} + +// BeginDeleteVMGroup - Delete a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginDeleteVMGroup(ctx context.Context, resourceGroupName string, vmGroupID string, privateCloudName string, options *WorkloadNetworksBeginDeleteVMGroupOptions) (WorkloadNetworksDeleteVMGroupPollerResponse, error) { + resp, err := client.deleteVMGroup(ctx, resourceGroupName, vmGroupID, privateCloudName, options) + if err != nil { + return WorkloadNetworksDeleteVMGroupPollerResponse{}, err + } + result := WorkloadNetworksDeleteVMGroupPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.DeleteVMGroup", "", resp, client.pl, client.deleteVMGroupHandleError) + if err != nil { + return WorkloadNetworksDeleteVMGroupPollerResponse{}, err + } + result.Poller = &WorkloadNetworksDeleteVMGroupPoller{ + pt: pt, + } + return result, nil +} + +// DeleteVMGroup - Delete a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) deleteVMGroup(ctx context.Context, resourceGroupName string, vmGroupID string, privateCloudName string, options *WorkloadNetworksBeginDeleteVMGroupOptions) (*http.Response, error) { + req, err := client.deleteVMGroupCreateRequest(ctx, resourceGroupName, vmGroupID, privateCloudName, 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.deleteVMGroupHandleError(resp) + } + return resp, nil +} + +// deleteVMGroupCreateRequest creates the DeleteVMGroup request. +func (client *WorkloadNetworksClient) deleteVMGroupCreateRequest(ctx context.Context, resourceGroupName string, vmGroupID string, privateCloudName string, options *WorkloadNetworksBeginDeleteVMGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}" + 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 vmGroupID == "" { + return nil, errors.New("parameter vmGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmGroupId}", url.PathEscape(vmGroupID)) + if privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteVMGroupHandleError handles the DeleteVMGroup error response. +func (client *WorkloadNetworksClient) deleteVMGroupHandleError(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) +} + +// GetDNSService - Get a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, options *WorkloadNetworksGetDNSServiceOptions) (WorkloadNetworksGetDNSServiceResponse, error) { + req, err := client.getDNSServiceCreateRequest(ctx, resourceGroupName, privateCloudName, dnsServiceID, options) + if err != nil { + return WorkloadNetworksGetDNSServiceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetDNSServiceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetDNSServiceResponse{}, client.getDNSServiceHandleError(resp) + } + return client.getDNSServiceHandleResponse(resp) +} + +// getDNSServiceCreateRequest creates the GetDNSService request. +func (client *WorkloadNetworksClient) getDNSServiceCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, options *WorkloadNetworksGetDNSServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dnsServiceID == "" { + return nil, errors.New("parameter dnsServiceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsServiceId}", url.PathEscape(dnsServiceID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getDNSServiceHandleResponse handles the GetDNSService response. +func (client *WorkloadNetworksClient) getDNSServiceHandleResponse(resp *http.Response) (WorkloadNetworksGetDNSServiceResponse, error) { + result := WorkloadNetworksGetDNSServiceResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkDNSService); err != nil { + return WorkloadNetworksGetDNSServiceResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getDNSServiceHandleError handles the GetDNSService error response. +func (client *WorkloadNetworksClient) getDNSServiceHandleError(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) +} + +// GetDNSZone - Get a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, options *WorkloadNetworksGetDNSZoneOptions) (WorkloadNetworksGetDNSZoneResponse, error) { + req, err := client.getDNSZoneCreateRequest(ctx, resourceGroupName, privateCloudName, dnsZoneID, options) + if err != nil { + return WorkloadNetworksGetDNSZoneResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetDNSZoneResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetDNSZoneResponse{}, client.getDNSZoneHandleError(resp) + } + return client.getDNSZoneHandleResponse(resp) +} + +// getDNSZoneCreateRequest creates the GetDNSZone request. +func (client *WorkloadNetworksClient) getDNSZoneCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, options *WorkloadNetworksGetDNSZoneOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dnsZoneID == "" { + return nil, errors.New("parameter dnsZoneID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsZoneId}", url.PathEscape(dnsZoneID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getDNSZoneHandleResponse handles the GetDNSZone response. +func (client *WorkloadNetworksClient) getDNSZoneHandleResponse(resp *http.Response) (WorkloadNetworksGetDNSZoneResponse, error) { + result := WorkloadNetworksGetDNSZoneResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkDNSZone); err != nil { + return WorkloadNetworksGetDNSZoneResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getDNSZoneHandleError handles the GetDNSZone error response. +func (client *WorkloadNetworksClient) getDNSZoneHandleError(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) +} + +// GetDhcp - Get dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetDhcp(ctx context.Context, resourceGroupName string, dhcpID string, privateCloudName string, options *WorkloadNetworksGetDhcpOptions) (WorkloadNetworksGetDhcpResponse, error) { + req, err := client.getDhcpCreateRequest(ctx, resourceGroupName, dhcpID, privateCloudName, options) + if err != nil { + return WorkloadNetworksGetDhcpResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetDhcpResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetDhcpResponse{}, client.getDhcpHandleError(resp) + } + return client.getDhcpHandleResponse(resp) +} + +// getDhcpCreateRequest creates the GetDhcp request. +func (client *WorkloadNetworksClient) getDhcpCreateRequest(ctx context.Context, resourceGroupName string, dhcpID string, privateCloudName string, options *WorkloadNetworksGetDhcpOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}" + 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 dhcpID == "" { + return nil, errors.New("parameter dhcpID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dhcpId}", url.PathEscape(dhcpID)) + if privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getDhcpHandleResponse handles the GetDhcp response. +func (client *WorkloadNetworksClient) getDhcpHandleResponse(resp *http.Response) (WorkloadNetworksGetDhcpResponse, error) { + result := WorkloadNetworksGetDhcpResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkDhcp); err != nil { + return WorkloadNetworksGetDhcpResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getDhcpHandleError handles the GetDhcp error response. +func (client *WorkloadNetworksClient) getDhcpHandleError(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) +} + +// GetGateway - Get a gateway by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetGateway(ctx context.Context, resourceGroupName string, privateCloudName string, gatewayID string, options *WorkloadNetworksGetGatewayOptions) (WorkloadNetworksGetGatewayResponse, error) { + req, err := client.getGatewayCreateRequest(ctx, resourceGroupName, privateCloudName, gatewayID, options) + if err != nil { + return WorkloadNetworksGetGatewayResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetGatewayResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetGatewayResponse{}, client.getGatewayHandleError(resp) + } + return client.getGatewayHandleResponse(resp) +} + +// getGatewayCreateRequest creates the GetGateway request. +func (client *WorkloadNetworksClient) getGatewayCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, gatewayID string, options *WorkloadNetworksGetGatewayOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getGatewayHandleResponse handles the GetGateway response. +func (client *WorkloadNetworksClient) getGatewayHandleResponse(resp *http.Response) (WorkloadNetworksGetGatewayResponse, error) { + result := WorkloadNetworksGetGatewayResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkGateway); err != nil { + return WorkloadNetworksGetGatewayResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getGatewayHandleError handles the GetGateway error response. +func (client *WorkloadNetworksClient) getGatewayHandleError(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) +} + +// GetPortMirroring - Get a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetPortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, options *WorkloadNetworksGetPortMirroringOptions) (WorkloadNetworksGetPortMirroringResponse, error) { + req, err := client.getPortMirroringCreateRequest(ctx, resourceGroupName, privateCloudName, portMirroringID, options) + if err != nil { + return WorkloadNetworksGetPortMirroringResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetPortMirroringResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetPortMirroringResponse{}, client.getPortMirroringHandleError(resp) + } + return client.getPortMirroringHandleResponse(resp) +} + +// getPortMirroringCreateRequest creates the GetPortMirroring request. +func (client *WorkloadNetworksClient) getPortMirroringCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, options *WorkloadNetworksGetPortMirroringOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if portMirroringID == "" { + return nil, errors.New("parameter portMirroringID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portMirroringId}", url.PathEscape(portMirroringID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getPortMirroringHandleResponse handles the GetPortMirroring response. +func (client *WorkloadNetworksClient) getPortMirroringHandleResponse(resp *http.Response) (WorkloadNetworksGetPortMirroringResponse, error) { + result := WorkloadNetworksGetPortMirroringResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkPortMirroring); err != nil { + return WorkloadNetworksGetPortMirroringResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getPortMirroringHandleError handles the GetPortMirroring error response. +func (client *WorkloadNetworksClient) getPortMirroringHandleError(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) +} + +// GetPublicIP - Get a Public IP Block by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetPublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, options *WorkloadNetworksGetPublicIPOptions) (WorkloadNetworksGetPublicIPResponse, error) { + req, err := client.getPublicIPCreateRequest(ctx, resourceGroupName, privateCloudName, publicIPID, options) + if err != nil { + return WorkloadNetworksGetPublicIPResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetPublicIPResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetPublicIPResponse{}, client.getPublicIPHandleError(resp) + } + return client.getPublicIPHandleResponse(resp) +} + +// getPublicIPCreateRequest creates the GetPublicIP request. +func (client *WorkloadNetworksClient) getPublicIPCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, options *WorkloadNetworksGetPublicIPOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if publicIPID == "" { + return nil, errors.New("parameter publicIPID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{publicIPId}", url.PathEscape(publicIPID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getPublicIPHandleResponse handles the GetPublicIP response. +func (client *WorkloadNetworksClient) getPublicIPHandleResponse(resp *http.Response) (WorkloadNetworksGetPublicIPResponse, error) { + result := WorkloadNetworksGetPublicIPResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkPublicIP); err != nil { + return WorkloadNetworksGetPublicIPResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getPublicIPHandleError handles the GetPublicIP error response. +func (client *WorkloadNetworksClient) getPublicIPHandleError(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) +} + +// GetSegment - Get a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, options *WorkloadNetworksGetSegmentOptions) (WorkloadNetworksGetSegmentResponse, error) { + req, err := client.getSegmentCreateRequest(ctx, resourceGroupName, privateCloudName, segmentID, options) + if err != nil { + return WorkloadNetworksGetSegmentResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetSegmentResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetSegmentResponse{}, client.getSegmentHandleError(resp) + } + return client.getSegmentHandleResponse(resp) +} + +// getSegmentCreateRequest creates the GetSegment request. +func (client *WorkloadNetworksClient) getSegmentCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, options *WorkloadNetworksGetSegmentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if segmentID == "" { + return nil, errors.New("parameter segmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{segmentId}", url.PathEscape(segmentID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getSegmentHandleResponse handles the GetSegment response. +func (client *WorkloadNetworksClient) getSegmentHandleResponse(resp *http.Response) (WorkloadNetworksGetSegmentResponse, error) { + result := WorkloadNetworksGetSegmentResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkSegment); err != nil { + return WorkloadNetworksGetSegmentResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getSegmentHandleError handles the GetSegment error response. +func (client *WorkloadNetworksClient) getSegmentHandleError(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) +} + +// GetVMGroup - Get a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, options *WorkloadNetworksGetVMGroupOptions) (WorkloadNetworksGetVMGroupResponse, error) { + req, err := client.getVMGroupCreateRequest(ctx, resourceGroupName, privateCloudName, vmGroupID, options) + if err != nil { + return WorkloadNetworksGetVMGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetVMGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetVMGroupResponse{}, client.getVMGroupHandleError(resp) + } + return client.getVMGroupHandleResponse(resp) +} + +// getVMGroupCreateRequest creates the GetVMGroup request. +func (client *WorkloadNetworksClient) getVMGroupCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, options *WorkloadNetworksGetVMGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if vmGroupID == "" { + return nil, errors.New("parameter vmGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmGroupId}", url.PathEscape(vmGroupID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getVMGroupHandleResponse handles the GetVMGroup response. +func (client *WorkloadNetworksClient) getVMGroupHandleResponse(resp *http.Response) (WorkloadNetworksGetVMGroupResponse, error) { + result := WorkloadNetworksGetVMGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkVMGroup); err != nil { + return WorkloadNetworksGetVMGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getVMGroupHandleError handles the GetVMGroup error response. +func (client *WorkloadNetworksClient) getVMGroupHandleError(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) +} + +// GetVirtualMachine - Get a virtual machine by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) GetVirtualMachine(ctx context.Context, resourceGroupName string, privateCloudName string, virtualMachineID string, options *WorkloadNetworksGetVirtualMachineOptions) (WorkloadNetworksGetVirtualMachineResponse, error) { + req, err := client.getVirtualMachineCreateRequest(ctx, resourceGroupName, privateCloudName, virtualMachineID, options) + if err != nil { + return WorkloadNetworksGetVirtualMachineResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkloadNetworksGetVirtualMachineResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkloadNetworksGetVirtualMachineResponse{}, client.getVirtualMachineHandleError(resp) + } + return client.getVirtualMachineHandleResponse(resp) +} + +// getVirtualMachineCreateRequest creates the GetVirtualMachine request. +func (client *WorkloadNetworksClient) getVirtualMachineCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, virtualMachineID string, options *WorkloadNetworksGetVirtualMachineOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if virtualMachineID == "" { + return nil, errors.New("parameter virtualMachineID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineId}", url.PathEscape(virtualMachineID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getVirtualMachineHandleResponse handles the GetVirtualMachine response. +func (client *WorkloadNetworksClient) getVirtualMachineHandleResponse(resp *http.Response) (WorkloadNetworksGetVirtualMachineResponse, error) { + result := WorkloadNetworksGetVirtualMachineResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkVirtualMachine); err != nil { + return WorkloadNetworksGetVirtualMachineResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getVirtualMachineHandleError handles the GetVirtualMachine error response. +func (client *WorkloadNetworksClient) getVirtualMachineHandleError(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) +} + +// ListDNSServices - List of DNS services in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListDNSServices(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListDNSServicesOptions) *WorkloadNetworksListDNSServicesPager { + return &WorkloadNetworksListDNSServicesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listDNSServicesCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListDNSServicesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkDNSServicesList.NextLink) + }, + } +} + +// listDNSServicesCreateRequest creates the ListDNSServices request. +func (client *WorkloadNetworksClient) listDNSServicesCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListDNSServicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listDNSServicesHandleResponse handles the ListDNSServices response. +func (client *WorkloadNetworksClient) listDNSServicesHandleResponse(resp *http.Response) (WorkloadNetworksListDNSServicesResponse, error) { + result := WorkloadNetworksListDNSServicesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkDNSServicesList); err != nil { + return WorkloadNetworksListDNSServicesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listDNSServicesHandleError handles the ListDNSServices error response. +func (client *WorkloadNetworksClient) listDNSServicesHandleError(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) +} + +// ListDNSZones - List of DNS zones in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListDNSZones(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListDNSZonesOptions) *WorkloadNetworksListDNSZonesPager { + return &WorkloadNetworksListDNSZonesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listDNSZonesCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListDNSZonesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkDNSZonesList.NextLink) + }, + } +} + +// listDNSZonesCreateRequest creates the ListDNSZones request. +func (client *WorkloadNetworksClient) listDNSZonesCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListDNSZonesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listDNSZonesHandleResponse handles the ListDNSZones response. +func (client *WorkloadNetworksClient) listDNSZonesHandleResponse(resp *http.Response) (WorkloadNetworksListDNSZonesResponse, error) { + result := WorkloadNetworksListDNSZonesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkDNSZonesList); err != nil { + return WorkloadNetworksListDNSZonesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listDNSZonesHandleError handles the ListDNSZones error response. +func (client *WorkloadNetworksClient) listDNSZonesHandleError(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) +} + +// ListDhcp - List dhcp in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListDhcp(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListDhcpOptions) *WorkloadNetworksListDhcpPager { + return &WorkloadNetworksListDhcpPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listDhcpCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListDhcpResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkDhcpList.NextLink) + }, + } +} + +// listDhcpCreateRequest creates the ListDhcp request. +func (client *WorkloadNetworksClient) listDhcpCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListDhcpOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listDhcpHandleResponse handles the ListDhcp response. +func (client *WorkloadNetworksClient) listDhcpHandleResponse(resp *http.Response) (WorkloadNetworksListDhcpResponse, error) { + result := WorkloadNetworksListDhcpResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkDhcpList); err != nil { + return WorkloadNetworksListDhcpResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listDhcpHandleError handles the ListDhcp error response. +func (client *WorkloadNetworksClient) listDhcpHandleError(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) +} + +// ListGateways - List of gateways in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListGateways(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListGatewaysOptions) *WorkloadNetworksListGatewaysPager { + return &WorkloadNetworksListGatewaysPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listGatewaysCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListGatewaysResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkGatewayList.NextLink) + }, + } +} + +// listGatewaysCreateRequest creates the ListGateways request. +func (client *WorkloadNetworksClient) listGatewaysCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListGatewaysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listGatewaysHandleResponse handles the ListGateways response. +func (client *WorkloadNetworksClient) listGatewaysHandleResponse(resp *http.Response) (WorkloadNetworksListGatewaysResponse, error) { + result := WorkloadNetworksListGatewaysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkGatewayList); err != nil { + return WorkloadNetworksListGatewaysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listGatewaysHandleError handles the ListGateways error response. +func (client *WorkloadNetworksClient) listGatewaysHandleError(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) +} + +// ListPortMirroring - List of port mirroring profiles in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListPortMirroring(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListPortMirroringOptions) *WorkloadNetworksListPortMirroringPager { + return &WorkloadNetworksListPortMirroringPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listPortMirroringCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListPortMirroringResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkPortMirroringList.NextLink) + }, + } +} + +// listPortMirroringCreateRequest creates the ListPortMirroring request. +func (client *WorkloadNetworksClient) listPortMirroringCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListPortMirroringOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listPortMirroringHandleResponse handles the ListPortMirroring response. +func (client *WorkloadNetworksClient) listPortMirroringHandleResponse(resp *http.Response) (WorkloadNetworksListPortMirroringResponse, error) { + result := WorkloadNetworksListPortMirroringResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkPortMirroringList); err != nil { + return WorkloadNetworksListPortMirroringResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listPortMirroringHandleError handles the ListPortMirroring error response. +func (client *WorkloadNetworksClient) listPortMirroringHandleError(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) +} + +// ListPublicIPs - List of Public IP Blocks in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListPublicIPs(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListPublicIPsOptions) *WorkloadNetworksListPublicIPsPager { + return &WorkloadNetworksListPublicIPsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listPublicIPsCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListPublicIPsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkPublicIPsList.NextLink) + }, + } +} + +// listPublicIPsCreateRequest creates the ListPublicIPs request. +func (client *WorkloadNetworksClient) listPublicIPsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListPublicIPsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listPublicIPsHandleResponse handles the ListPublicIPs response. +func (client *WorkloadNetworksClient) listPublicIPsHandleResponse(resp *http.Response) (WorkloadNetworksListPublicIPsResponse, error) { + result := WorkloadNetworksListPublicIPsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkPublicIPsList); err != nil { + return WorkloadNetworksListPublicIPsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listPublicIPsHandleError handles the ListPublicIPs error response. +func (client *WorkloadNetworksClient) listPublicIPsHandleError(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) +} + +// ListSegments - List of segments in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListSegments(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListSegmentsOptions) *WorkloadNetworksListSegmentsPager { + return &WorkloadNetworksListSegmentsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listSegmentsCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListSegmentsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkSegmentsList.NextLink) + }, + } +} + +// listSegmentsCreateRequest creates the ListSegments request. +func (client *WorkloadNetworksClient) listSegmentsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListSegmentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listSegmentsHandleResponse handles the ListSegments response. +func (client *WorkloadNetworksClient) listSegmentsHandleResponse(resp *http.Response) (WorkloadNetworksListSegmentsResponse, error) { + result := WorkloadNetworksListSegmentsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkSegmentsList); err != nil { + return WorkloadNetworksListSegmentsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listSegmentsHandleError handles the ListSegments error response. +func (client *WorkloadNetworksClient) listSegmentsHandleError(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) +} + +// ListVMGroups - List of vm groups in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListVMGroups(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListVMGroupsOptions) *WorkloadNetworksListVMGroupsPager { + return &WorkloadNetworksListVMGroupsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listVMGroupsCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListVMGroupsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkVMGroupsList.NextLink) + }, + } +} + +// listVMGroupsCreateRequest creates the ListVMGroups request. +func (client *WorkloadNetworksClient) listVMGroupsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListVMGroupsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listVMGroupsHandleResponse handles the ListVMGroups response. +func (client *WorkloadNetworksClient) listVMGroupsHandleResponse(resp *http.Response) (WorkloadNetworksListVMGroupsResponse, error) { + result := WorkloadNetworksListVMGroupsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkVMGroupsList); err != nil { + return WorkloadNetworksListVMGroupsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listVMGroupsHandleError handles the ListVMGroups error response. +func (client *WorkloadNetworksClient) listVMGroupsHandleError(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) +} + +// ListVirtualMachines - List of virtual machines in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) ListVirtualMachines(resourceGroupName string, privateCloudName string, options *WorkloadNetworksListVirtualMachinesOptions) *WorkloadNetworksListVirtualMachinesPager { + return &WorkloadNetworksListVirtualMachinesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listVirtualMachinesCreateRequest(ctx, resourceGroupName, privateCloudName, options) + }, + advancer: func(ctx context.Context, resp WorkloadNetworksListVirtualMachinesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.WorkloadNetworkVirtualMachinesList.NextLink) + }, + } +} + +// listVirtualMachinesCreateRequest creates the ListVirtualMachines request. +func (client *WorkloadNetworksClient) listVirtualMachinesCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, options *WorkloadNetworksListVirtualMachinesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listVirtualMachinesHandleResponse handles the ListVirtualMachines response. +func (client *WorkloadNetworksClient) listVirtualMachinesHandleResponse(resp *http.Response) (WorkloadNetworksListVirtualMachinesResponse, error) { + result := WorkloadNetworksListVirtualMachinesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadNetworkVirtualMachinesList); err != nil { + return WorkloadNetworksListVirtualMachinesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listVirtualMachinesHandleError handles the ListVirtualMachines error response. +func (client *WorkloadNetworksClient) listVirtualMachinesHandleError(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) +} + +// BeginUpdateDNSService - Create or update a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginUpdateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService, options *WorkloadNetworksBeginUpdateDNSServiceOptions) (WorkloadNetworksUpdateDNSServicePollerResponse, error) { + resp, err := client.updateDNSService(ctx, resourceGroupName, privateCloudName, dnsServiceID, workloadNetworkDNSService, options) + if err != nil { + return WorkloadNetworksUpdateDNSServicePollerResponse{}, err + } + result := WorkloadNetworksUpdateDNSServicePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.UpdateDNSService", "", resp, client.pl, client.updateDNSServiceHandleError) + if err != nil { + return WorkloadNetworksUpdateDNSServicePollerResponse{}, err + } + result.Poller = &WorkloadNetworksUpdateDNSServicePoller{ + pt: pt, + } + return result, nil +} + +// UpdateDNSService - Create or update a DNS service by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) updateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService, options *WorkloadNetworksBeginUpdateDNSServiceOptions) (*http.Response, error) { + req, err := client.updateDNSServiceCreateRequest(ctx, resourceGroupName, privateCloudName, dnsServiceID, workloadNetworkDNSService, 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.updateDNSServiceHandleError(resp) + } + return resp, nil +} + +// updateDNSServiceCreateRequest creates the UpdateDNSService request. +func (client *WorkloadNetworksClient) updateDNSServiceCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dnsServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService, options *WorkloadNetworksBeginUpdateDNSServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dnsServiceID == "" { + return nil, errors.New("parameter dnsServiceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsServiceId}", url.PathEscape(dnsServiceID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkDNSService) +} + +// updateDNSServiceHandleError handles the UpdateDNSService error response. +func (client *WorkloadNetworksClient) updateDNSServiceHandleError(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) +} + +// BeginUpdateDNSZone - Create or update a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginUpdateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone, options *WorkloadNetworksBeginUpdateDNSZoneOptions) (WorkloadNetworksUpdateDNSZonePollerResponse, error) { + resp, err := client.updateDNSZone(ctx, resourceGroupName, privateCloudName, dnsZoneID, workloadNetworkDNSZone, options) + if err != nil { + return WorkloadNetworksUpdateDNSZonePollerResponse{}, err + } + result := WorkloadNetworksUpdateDNSZonePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.UpdateDNSZone", "", resp, client.pl, client.updateDNSZoneHandleError) + if err != nil { + return WorkloadNetworksUpdateDNSZonePollerResponse{}, err + } + result.Poller = &WorkloadNetworksUpdateDNSZonePoller{ + pt: pt, + } + return result, nil +} + +// UpdateDNSZone - Create or update a DNS zone by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) updateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone, options *WorkloadNetworksBeginUpdateDNSZoneOptions) (*http.Response, error) { + req, err := client.updateDNSZoneCreateRequest(ctx, resourceGroupName, privateCloudName, dnsZoneID, workloadNetworkDNSZone, 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.updateDNSZoneHandleError(resp) + } + return resp, nil +} + +// updateDNSZoneCreateRequest creates the UpdateDNSZone request. +func (client *WorkloadNetworksClient) updateDNSZoneCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dnsZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone, options *WorkloadNetworksBeginUpdateDNSZoneOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dnsZoneID == "" { + return nil, errors.New("parameter dnsZoneID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dnsZoneId}", url.PathEscape(dnsZoneID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkDNSZone) +} + +// updateDNSZoneHandleError handles the UpdateDNSZone error response. +func (client *WorkloadNetworksClient) updateDNSZoneHandleError(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) +} + +// BeginUpdateDhcp - Create or update dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginUpdateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp, options *WorkloadNetworksBeginUpdateDhcpOptions) (WorkloadNetworksUpdateDhcpPollerResponse, error) { + resp, err := client.updateDhcp(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp, options) + if err != nil { + return WorkloadNetworksUpdateDhcpPollerResponse{}, err + } + result := WorkloadNetworksUpdateDhcpPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.UpdateDhcp", "", resp, client.pl, client.updateDhcpHandleError) + if err != nil { + return WorkloadNetworksUpdateDhcpPollerResponse{}, err + } + result.Poller = &WorkloadNetworksUpdateDhcpPoller{ + pt: pt, + } + return result, nil +} + +// UpdateDhcp - Create or update dhcp by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) updateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp, options *WorkloadNetworksBeginUpdateDhcpOptions) (*http.Response, error) { + req, err := client.updateDhcpCreateRequest(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp, 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.updateDhcpHandleError(resp) + } + return resp, nil +} + +// updateDhcpCreateRequest creates the UpdateDhcp request. +func (client *WorkloadNetworksClient) updateDhcpCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp, options *WorkloadNetworksBeginUpdateDhcpOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if dhcpID == "" { + return nil, errors.New("parameter dhcpID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dhcpId}", url.PathEscape(dhcpID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkDhcp) +} + +// updateDhcpHandleError handles the UpdateDhcp error response. +func (client *WorkloadNetworksClient) updateDhcpHandleError(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) +} + +// BeginUpdatePortMirroring - Create or update a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginUpdatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring, options *WorkloadNetworksBeginUpdatePortMirroringOptions) (WorkloadNetworksUpdatePortMirroringPollerResponse, error) { + resp, err := client.updatePortMirroring(ctx, resourceGroupName, privateCloudName, portMirroringID, workloadNetworkPortMirroring, options) + if err != nil { + return WorkloadNetworksUpdatePortMirroringPollerResponse{}, err + } + result := WorkloadNetworksUpdatePortMirroringPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.UpdatePortMirroring", "", resp, client.pl, client.updatePortMirroringHandleError) + if err != nil { + return WorkloadNetworksUpdatePortMirroringPollerResponse{}, err + } + result.Poller = &WorkloadNetworksUpdatePortMirroringPoller{ + pt: pt, + } + return result, nil +} + +// UpdatePortMirroring - Create or update a port mirroring profile by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) updatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring, options *WorkloadNetworksBeginUpdatePortMirroringOptions) (*http.Response, error) { + req, err := client.updatePortMirroringCreateRequest(ctx, resourceGroupName, privateCloudName, portMirroringID, workloadNetworkPortMirroring, 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.updatePortMirroringHandleError(resp) + } + return resp, nil +} + +// updatePortMirroringCreateRequest creates the UpdatePortMirroring request. +func (client *WorkloadNetworksClient) updatePortMirroringCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring, options *WorkloadNetworksBeginUpdatePortMirroringOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if portMirroringID == "" { + return nil, errors.New("parameter portMirroringID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portMirroringId}", url.PathEscape(portMirroringID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkPortMirroring) +} + +// updatePortMirroringHandleError handles the UpdatePortMirroring error response. +func (client *WorkloadNetworksClient) updatePortMirroringHandleError(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) +} + +// BeginUpdateSegments - Create or update a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginUpdateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment, options *WorkloadNetworksBeginUpdateSegmentsOptions) (WorkloadNetworksUpdateSegmentsPollerResponse, error) { + resp, err := client.updateSegments(ctx, resourceGroupName, privateCloudName, segmentID, workloadNetworkSegment, options) + if err != nil { + return WorkloadNetworksUpdateSegmentsPollerResponse{}, err + } + result := WorkloadNetworksUpdateSegmentsPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.UpdateSegments", "", resp, client.pl, client.updateSegmentsHandleError) + if err != nil { + return WorkloadNetworksUpdateSegmentsPollerResponse{}, err + } + result.Poller = &WorkloadNetworksUpdateSegmentsPoller{ + pt: pt, + } + return result, nil +} + +// UpdateSegments - Create or update a segment by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) updateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment, options *WorkloadNetworksBeginUpdateSegmentsOptions) (*http.Response, error) { + req, err := client.updateSegmentsCreateRequest(ctx, resourceGroupName, privateCloudName, segmentID, workloadNetworkSegment, 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.updateSegmentsHandleError(resp) + } + return resp, nil +} + +// updateSegmentsCreateRequest creates the UpdateSegments request. +func (client *WorkloadNetworksClient) updateSegmentsCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment, options *WorkloadNetworksBeginUpdateSegmentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if segmentID == "" { + return nil, errors.New("parameter segmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{segmentId}", url.PathEscape(segmentID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkSegment) +} + +// updateSegmentsHandleError handles the UpdateSegments error response. +func (client *WorkloadNetworksClient) updateSegmentsHandleError(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) +} + +// BeginUpdateVMGroup - Create or update a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) BeginUpdateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup, options *WorkloadNetworksBeginUpdateVMGroupOptions) (WorkloadNetworksUpdateVMGroupPollerResponse, error) { + resp, err := client.updateVMGroup(ctx, resourceGroupName, privateCloudName, vmGroupID, workloadNetworkVMGroup, options) + if err != nil { + return WorkloadNetworksUpdateVMGroupPollerResponse{}, err + } + result := WorkloadNetworksUpdateVMGroupPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("WorkloadNetworksClient.UpdateVMGroup", "", resp, client.pl, client.updateVMGroupHandleError) + if err != nil { + return WorkloadNetworksUpdateVMGroupPollerResponse{}, err + } + result.Poller = &WorkloadNetworksUpdateVMGroupPoller{ + pt: pt, + } + return result, nil +} + +// UpdateVMGroup - Create or update a vm group by id in a private cloud workload network. +// If the operation fails it returns the *CloudError error type. +func (client *WorkloadNetworksClient) updateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup, options *WorkloadNetworksBeginUpdateVMGroupOptions) (*http.Response, error) { + req, err := client.updateVMGroupCreateRequest(ctx, resourceGroupName, privateCloudName, vmGroupID, workloadNetworkVMGroup, 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.updateVMGroupHandleError(resp) + } + return resp, nil +} + +// updateVMGroupCreateRequest creates the UpdateVMGroup request. +func (client *WorkloadNetworksClient) updateVMGroupCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, vmGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup, options *WorkloadNetworksBeginUpdateVMGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}" + 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 privateCloudName == "" { + return nil, errors.New("parameter privateCloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateCloudName}", url.PathEscape(privateCloudName)) + if vmGroupID == "" { + return nil, errors.New("parameter vmGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmGroupId}", url.PathEscape(vmGroupID)) + 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-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, workloadNetworkVMGroup) +} + +// updateVMGroupHandleError handles the UpdateVMGroup error response. +func (client *WorkloadNetworksClient) updateVMGroupHandleError(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) +}