From 4a950d8e8429270d7d67136870ca19a372e92e8a Mon Sep 17 00:00:00 2001 From: Jiahui Peng <46921893+Alancere@users.noreply.github.com> Date: Tue, 7 Dec 2021 17:31:20 +0800 Subject: [PATCH] [Release] sdk/resourcemanager/labservices/armlabservices/0.1.0 generation from spec commit: cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8 (#16438) --- .../labservices/armlabservices/CHANGELOG.md | 5 + .../labservices/armlabservices/LICENSE.txt | 21 + .../labservices/armlabservices/README.md | 75 + .../labservices/armlabservices/autorest.md | 13 + .../labservices/armlabservices/build.go | 7 + .../labservices/armlabservices/ci.yml | 27 + .../labservices/armlabservices/go.mod | 9 + .../labservices/armlabservices/go.sum | 45 + .../armlabservices/go_mod_tidy_hack.go | 13 + ...ze_generated_example_images_client_test.go | 107 + ..._generated_example_labplans_client_test.go | 210 ++ .../ze_generated_example_labs_client_test.go | 244 +++ ...ed_example_operationresults_client_test.go | 34 + ...enerated_example_operations_client_test.go | 33 + ...generated_example_schedules_client_test.go | 144 ++ .../ze_generated_example_skus_client_test.go | 33 + ...ze_generated_example_usages_client_test.go | 37 + .../ze_generated_example_users_client_test.go | 166 ++ ...ted_example_virtualmachines_client_test.go | 174 ++ .../armlabservices/zz_generated_constants.go | 623 ++++++ .../armlabservices/zz_generated_date_type.go | 59 + .../zz_generated_images_client.go | 315 +++ .../zz_generated_labplans_client.go | 529 +++++ .../zz_generated_labs_client.go | 603 ++++++ .../armlabservices/zz_generated_models.go | 1740 +++++++++++++++++ .../zz_generated_operationresults_client.go | 104 + .../zz_generated_operations_client.go | 89 + .../armlabservices/zz_generated_pagers.go | 611 ++++++ .../armlabservices/zz_generated_pollers.go | 832 ++++++++ .../zz_generated_response_types.go | 1190 +++++++++++ .../zz_generated_schedules_client.go | 395 ++++ .../zz_generated_skus_client.go | 100 + .../zz_generated_time_rfc3339.go | 85 + .../zz_generated_usages_client.go | 104 + .../zz_generated_users_client.go | 497 +++++ .../zz_generated_virtualmachines_client.go | 579 ++++++ 36 files changed, 9852 insertions(+) create mode 100644 sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md create mode 100644 sdk/resourcemanager/labservices/armlabservices/LICENSE.txt create mode 100644 sdk/resourcemanager/labservices/armlabservices/README.md create mode 100644 sdk/resourcemanager/labservices/armlabservices/autorest.md create mode 100644 sdk/resourcemanager/labservices/armlabservices/build.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ci.yml create mode 100644 sdk/resourcemanager/labservices/armlabservices/go.mod create mode 100644 sdk/resourcemanager/labservices/armlabservices/go.sum create mode 100644 sdk/resourcemanager/labservices/armlabservices/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_images_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labplans_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labs_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_operationresults_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_operations_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_schedules_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_skus_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_usages_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_users_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/ze_generated_example_virtualmachines_client_test.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_constants.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_date_type.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_images_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_labplans_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_labs_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_models.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_operationresults_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_schedules_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_skus_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_time_rfc3339.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_usages_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_users_client.go create mode 100644 sdk/resourcemanager/labservices/armlabservices/zz_generated_virtualmachines_client.go diff --git a/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md b/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md new file mode 100644 index 000000000000..925a954ff70d --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-07) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/labservices/armlabservices/LICENSE.txt b/sdk/resourcemanager/labservices/armlabservices/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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/labservices/armlabservices/README.md b/sdk/resourcemanager/labservices/armlabservices/README.md new file mode 100644 index 000000000000..126432836e23 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/README.md @@ -0,0 +1,75 @@ +# Azure Lab Services Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices) + +The `armlabservices` module provides operations for working with Azure Lab Services. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/labservices/armlabservices) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Lab Services module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Lab Services. 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 Lab Services 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 := armlabservices.NewLabPlansClient(, 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 := armlabservices.NewLabPlansClient(, 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 `Lab Services` 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/labservices/armlabservices/autorest.md b/sdk/resourcemanager/labservices/armlabservices/autorest.md new file mode 100644 index 000000000000..5bba14027291 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8/specification/labservices/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8/specification/labservices/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/labservices/armlabservices/build.go b/sdk/resourcemanager/labservices/armlabservices/build.go new file mode 100644 index 000000000000..017b439690b3 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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/labservices/armlabservices + +package armlabservices diff --git a/sdk/resourcemanager/labservices/armlabservices/ci.yml b/sdk/resourcemanager/labservices/armlabservices/ci.yml new file mode 100644 index 000000000000..f0a6d00f0202 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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/labservices/armlabservices/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/labservices/armlabservices/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/labservices/armlabservices' diff --git a/sdk/resourcemanager/labservices/armlabservices/go.mod b/sdk/resourcemanager/labservices/armlabservices/go.mod new file mode 100644 index 000000000000..52df5ee44d74 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.0.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/labservices/armlabservices/go.sum b/sdk/resourcemanager/labservices/armlabservices/go.sum new file mode 100644 index 000000000000..ac069c64ed64 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible h1:vVRJhSSTwhIHQTzTjqoZCItFJeBwfdNSqHcgGV10FHQ= +github.com/Azure/azure-sdk-for-go v60.0.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/labservices/armlabservices/go_mod_tidy_hack.go b/sdk/resourcemanager/labservices/armlabservices/go_mod_tidy_hack.go new file mode 100644 index 000000000000..805177241e6e --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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 armlabservices + +// 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/labservices/armlabservices/ze_generated_example_images_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_images_client_test.go new file mode 100644 index 000000000000..95a01a65f1d4 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_images_client_test.go @@ -0,0 +1,107 @@ +//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 armlabservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Images/listImages.json +func ExampleImagesClient_ListByLabPlan() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewImagesClient("", cred, nil) + pager := client.ListByLabPlan("", + "", + &armlabservices.ImagesListByLabPlanOptions{Filter: 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("Image.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Images/getImage.json +func ExampleImagesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewImagesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Image.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Images/putImage.json +func ExampleImagesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewImagesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armlabservices.Image{ + Properties: &armlabservices.ImageProperties{ + ImageUpdateProperties: armlabservices.ImageUpdateProperties{ + EnabledState: armlabservices.EnableStateEnabled.ToPtr(), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Image.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Images/patchImage.json +func ExampleImagesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewImagesClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + "", + armlabservices.ImageUpdate{ + Properties: &armlabservices.ImageUpdateProperties{ + EnabledState: armlabservices.EnableStateEnabled.ToPtr(), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Image.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labplans_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labplans_client_test.go new file mode 100644 index 000000000000..2027235f8978 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labplans_client_test.go @@ -0,0 +1,210 @@ +//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 armlabservices_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/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/listLabPlans.json +func ExampleLabPlansClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", cred, nil) + pager := client.ListBySubscription(&armlabservices.LabPlansListBySubscriptionOptions{Filter: 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("LabPlan.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/listResourceGroupLabPlans.json +func ExampleLabPlansClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", cred, nil) + pager := client.ListByResourceGroup("", + 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("LabPlan.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/getLabPlan.json +func ExampleLabPlansClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("LabPlan.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/putLabPlan.json +func ExampleLabPlansClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armlabservices.LabPlan{ + TrackedResource: armlabservices.TrackedResource{ + Location: to.StringPtr(""), + }, + Properties: &armlabservices.LabPlanProperties{ + LabPlanUpdateProperties: armlabservices.LabPlanUpdateProperties{ + DefaultAutoShutdownProfile: &armlabservices.AutoShutdownProfile{ + DisconnectDelay: to.StringPtr(""), + IdleDelay: to.StringPtr(""), + NoConnectDelay: to.StringPtr(""), + ShutdownOnDisconnect: armlabservices.EnableStateEnabled.ToPtr(), + ShutdownOnIdle: armlabservices.ShutdownOnIdleModeUserAbsence.ToPtr(), + ShutdownWhenNotConnected: armlabservices.EnableStateEnabled.ToPtr(), + }, + DefaultConnectionProfile: &armlabservices.ConnectionProfile{ + ClientRdpAccess: armlabservices.ConnectionTypePublic.ToPtr(), + ClientSSHAccess: armlabservices.ConnectionTypePublic.ToPtr(), + WebRdpAccess: armlabservices.ConnectionTypeNone.ToPtr(), + WebSSHAccess: armlabservices.ConnectionTypeNone.ToPtr(), + }, + DefaultNetworkProfile: &armlabservices.LabPlanNetworkProfile{ + SubnetID: to.StringPtr(""), + }, + SharedGalleryID: to.StringPtr(""), + SupportInfo: &armlabservices.SupportInfo{ + Email: to.StringPtr(""), + Instructions: to.StringPtr(""), + Phone: to.StringPtr(""), + URL: 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("LabPlan.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/patchLabPlan.json +func ExampleLabPlansClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", cred, nil) + poller, err := client.BeginUpdate(ctx, + "", + "", + armlabservices.LabPlanUpdate{ + Properties: &armlabservices.LabPlanUpdateProperties{ + DefaultConnectionProfile: &armlabservices.ConnectionProfile{ + ClientRdpAccess: armlabservices.ConnectionTypePublic.ToPtr(), + ClientSSHAccess: armlabservices.ConnectionTypePublic.ToPtr(), + WebRdpAccess: armlabservices.ConnectionTypeNone.ToPtr(), + WebSSHAccess: armlabservices.ConnectionTypeNone.ToPtr(), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("LabPlan.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/deleteLabPlan.json +func ExampleLabPlansClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabPlans/saveImageVirtualMachine.json +func ExampleLabPlansClient_BeginSaveImage() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabPlansClient("", cred, nil) + poller, err := client.BeginSaveImage(ctx, + "", + "", + armlabservices.SaveImageBody{ + Name: to.StringPtr(""), + LabVirtualMachineID: to.StringPtr(""), + }, + 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/labservices/armlabservices/ze_generated_example_labs_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labs_client_test.go new file mode 100644 index 000000000000..bc3e21365e8e --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_labs_client_test.go @@ -0,0 +1,244 @@ +//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 armlabservices_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/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/listLabs.json +func ExampleLabsClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("", cred, nil) + pager := client.ListBySubscription(&armlabservices.LabsListBySubscriptionOptions{Filter: 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("Lab.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/listResourceGroupLabs.json +func ExampleLabsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("", cred, nil) + pager := client.ListByResourceGroup("", + 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("Lab.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/getLab.json +func ExampleLabsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Lab.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/putLab.json +func ExampleLabsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armlabservices.Lab{ + TrackedResource: armlabservices.TrackedResource{ + Location: to.StringPtr(""), + }, + Properties: &armlabservices.LabProperties{ + LabUpdateProperties: armlabservices.LabUpdateProperties{ + Description: to.StringPtr(""), + AutoShutdownProfile: &armlabservices.AutoShutdownProfile{ + DisconnectDelay: to.StringPtr(""), + IdleDelay: to.StringPtr(""), + NoConnectDelay: to.StringPtr(""), + ShutdownOnDisconnect: armlabservices.EnableStateEnabled.ToPtr(), + ShutdownOnIdle: armlabservices.ShutdownOnIdleModeUserAbsence.ToPtr(), + ShutdownWhenNotConnected: armlabservices.EnableStateEnabled.ToPtr(), + }, + ConnectionProfile: &armlabservices.ConnectionProfile{ + ClientRdpAccess: armlabservices.ConnectionTypePublic.ToPtr(), + ClientSSHAccess: armlabservices.ConnectionTypePublic.ToPtr(), + WebRdpAccess: armlabservices.ConnectionTypeNone.ToPtr(), + WebSSHAccess: armlabservices.ConnectionTypeNone.ToPtr(), + }, + LabPlanID: to.StringPtr(""), + SecurityProfile: &armlabservices.SecurityProfile{ + OpenAccess: armlabservices.EnableStateDisabled.ToPtr(), + }, + Title: to.StringPtr(""), + VirtualMachineProfile: &armlabservices.VirtualMachineProfile{ + AdditionalCapabilities: &armlabservices.VirtualMachineAdditionalCapabilities{ + InstallGpuDrivers: armlabservices.EnableStateDisabled.ToPtr(), + }, + AdminUser: &armlabservices.Credentials{ + Username: to.StringPtr("<username>"), + }, + CreateOption: armlabservices.CreateOptionTemplateVM.ToPtr(), + ImageReference: &armlabservices.ImageReference{ + Offer: to.StringPtr("<offer>"), + Publisher: to.StringPtr("<publisher>"), + SKU: to.StringPtr("<sku>"), + Version: to.StringPtr("<version>"), + }, + SKU: &armlabservices.SKU{ + Name: to.StringPtr("<name>"), + }, + UsageQuota: to.StringPtr("<usage-quota>"), + UseSharedPassword: armlabservices.EnableStateDisabled.ToPtr(), + }, + }, + NetworkProfile: &armlabservices.LabNetworkProfile{ + SubnetID: to.StringPtr("<subnet-id>"), + }, + State: armlabservices.LabStateDraft.ToPtr(), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Lab.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/patchLab.json +func ExampleLabsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("<subscription-id>", cred, nil) + poller, err := client.BeginUpdate(ctx, + "<resource-group-name>", + "<lab-name>", + armlabservices.LabUpdate{ + Properties: &armlabservices.LabUpdateProperties{ + SecurityProfile: &armlabservices.SecurityProfile{ + OpenAccess: armlabservices.EnableStateEnabled.ToPtr(), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Lab.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/deleteLab.json +func ExampleLabsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("<subscription-id>", cred, nil) + poller, err := client.BeginDelete(ctx, + "<resource-group-name>", + "<lab-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/publishLab.json +func ExampleLabsClient_BeginPublish() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("<subscription-id>", cred, nil) + poller, err := client.BeginPublish(ctx, + "<resource-group-name>", + "<lab-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Labs/syncLab.json +func ExampleLabsClient_BeginSyncGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewLabsClient("<subscription-id>", cred, nil) + poller, err := client.BeginSyncGroup(ctx, + "<resource-group-name>", + "<lab-name>", + 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/labservices/armlabservices/ze_generated_example_operationresults_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_operationresults_client_test.go new file mode 100644 index 000000000000..28183ac6163d --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_operationresults_client_test.go @@ -0,0 +1,34 @@ +//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 armlabservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/OperationResults/getOperationResult.json +func ExampleOperationResultsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewOperationResultsClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<operation-result-id>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("OperationResult.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_operations_client_test.go new file mode 100644 index 000000000000..76f5d4d39a02 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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 armlabservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/LabServices/listOperations.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 := armlabservices.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/labservices/armlabservices/ze_generated_example_schedules_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_schedules_client_test.go new file mode 100644 index 000000000000..f2442378f3cb --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_schedules_client_test.go @@ -0,0 +1,144 @@ +//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 armlabservices_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/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Schedules/listSchedule.json +func ExampleSchedulesClient_ListByLab() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewSchedulesClient("<subscription-id>", cred, nil) + pager := client.ListByLab("<resource-group-name>", + "<lab-name>", + &armlabservices.SchedulesListByLabOptions{Filter: 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("Schedule.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Schedules/getSchedule.json +func ExampleSchedulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewSchedulesClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<lab-name>", + "<schedule-name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Schedule.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Schedules/putSchedule.json +func ExampleSchedulesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewSchedulesClient("<subscription-id>", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "<resource-group-name>", + "<lab-name>", + "<schedule-name>", + armlabservices.Schedule{ + Properties: &armlabservices.ScheduleProperties{ + ScheduleUpdateProperties: armlabservices.ScheduleUpdateProperties{ + Notes: to.StringPtr("<notes>"), + RecurrencePattern: &armlabservices.RecurrencePattern{ + ExpirationDate: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14"); return t }()), + Frequency: armlabservices.RecurrenceFrequencyDaily.ToPtr(), + Interval: to.Int32Ptr(2), + }, + StartAt: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t }()), + StopAt: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t }()), + TimeZoneID: to.StringPtr("<time-zone-id>"), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Schedule.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Schedules/patchSchedule.json +func ExampleSchedulesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewSchedulesClient("<subscription-id>", cred, nil) + res, err := client.Update(ctx, + "<resource-group-name>", + "<lab-name>", + "<schedule-name>", + armlabservices.ScheduleUpdate{ + Properties: &armlabservices.ScheduleUpdateProperties{ + RecurrencePattern: &armlabservices.RecurrencePattern{ + ExpirationDate: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14"); return t }()), + Frequency: armlabservices.RecurrenceFrequencyDaily.ToPtr(), + Interval: to.Int32Ptr(2), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Schedule.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Schedules/deleteSchedule.json +func ExampleSchedulesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewSchedulesClient("<subscription-id>", cred, nil) + poller, err := client.BeginDelete(ctx, + "<resource-group-name>", + "<lab-name>", + "<schedule-name>", + 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/labservices/armlabservices/ze_generated_example_skus_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_skus_client_test.go new file mode 100644 index 000000000000..dbb141c4693b --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_skus_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 armlabservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Skus/listSkus.json +func ExampleSKUsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewSKUsClient("<subscription-id>", cred, nil) + pager := client.List(&armlabservices.SKUsListOptions{Filter: nil}) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + } +} diff --git a/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_usages_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_usages_client_test.go new file mode 100644 index 000000000000..cbeb30ce311c --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_usages_client_test.go @@ -0,0 +1,37 @@ +//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 armlabservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Usages/getUsages.json +func ExampleUsagesClient_ListByLocation() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsagesClient("<subscription-id>", cred, nil) + pager := client.ListByLocation("<location>", + &armlabservices.UsagesListByLocationOptions{Filter: 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("Usage.ID: %s\n", *v.ID) + } + } +} diff --git a/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_users_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_users_client_test.go new file mode 100644 index 000000000000..84c68e274dc3 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_users_client_test.go @@ -0,0 +1,166 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlabservices_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/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Users/listUser.json +func ExampleUsersClient_ListByLab() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsersClient("<subscription-id>", cred, nil) + pager := client.ListByLab("<resource-group-name>", + "<lab-name>", + &armlabservices.UsersListByLabOptions{Filter: 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("User.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Users/getUser.json +func ExampleUsersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsersClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<lab-name>", + "<user-name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("User.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Users/putUser.json +func ExampleUsersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsersClient("<subscription-id>", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "<resource-group-name>", + "<lab-name>", + "<user-name>", + armlabservices.User{ + Properties: &armlabservices.UserProperties{ + UserUpdateProperties: armlabservices.UserUpdateProperties{ + AdditionalUsageQuota: to.StringPtr("<additional-usage-quota>"), + }, + Email: to.StringPtr("<email>"), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("User.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Users/patchUser.json +func ExampleUsersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsersClient("<subscription-id>", cred, nil) + poller, err := client.BeginUpdate(ctx, + "<resource-group-name>", + "<lab-name>", + "<user-name>", + armlabservices.UserUpdate{ + Properties: &armlabservices.UserUpdateProperties{ + AdditionalUsageQuota: to.StringPtr("<additional-usage-quota>"), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("User.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Users/deleteUser.json +func ExampleUsersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsersClient("<subscription-id>", cred, nil) + poller, err := client.BeginDelete(ctx, + "<resource-group-name>", + "<lab-name>", + "<user-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/Users/inviteUser.json +func ExampleUsersClient_BeginInvite() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewUsersClient("<subscription-id>", cred, nil) + poller, err := client.BeginInvite(ctx, + "<resource-group-name>", + "<lab-name>", + "<user-name>", + armlabservices.InviteBody{ + Text: to.StringPtr("<text>"), + }, + 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/labservices/armlabservices/ze_generated_example_virtualmachines_client_test.go b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_virtualmachines_client_test.go new file mode 100644 index 000000000000..4e73a5a71f24 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/ze_generated_example_virtualmachines_client_test.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 armlabservices_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/labservices/armlabservices" +) + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/listVirtualMachine.json +func ExampleVirtualMachinesClient_ListByLab() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + pager := client.ListByLab("<resource-group-name>", + "<lab-name>", + &armlabservices.VirtualMachinesListByLabOptions{Filter: 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/getVirtualMachine.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 := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<lab-name>", + "<virtual-machine-name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VirtualMachine.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/startVirtualMachine.json +func ExampleVirtualMachinesClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + poller, err := client.BeginStart(ctx, + "<resource-group-name>", + "<lab-name>", + "<virtual-machine-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/stopVirtualMachine.json +func ExampleVirtualMachinesClient_BeginStop() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + poller, err := client.BeginStop(ctx, + "<resource-group-name>", + "<lab-name>", + "<virtual-machine-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/reimageVirtualMachine.json +func ExampleVirtualMachinesClient_BeginReimage() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + poller, err := client.BeginReimage(ctx, + "<resource-group-name>", + "<lab-name>", + "<virtual-machine-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/redeployVirtualMachine.json +func ExampleVirtualMachinesClient_BeginRedeploy() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + poller, err := client.BeginRedeploy(ctx, + "<resource-group-name>", + "<lab-name>", + "<virtual-machine-name>", + 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/labservices/resource-manager/Microsoft.LabServices/preview/2021-11-15-preview/examples/VirtualMachines/resetPasswordVirtualMachine.json +func ExampleVirtualMachinesClient_BeginResetPassword() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armlabservices.NewVirtualMachinesClient("<subscription-id>", cred, nil) + poller, err := client.BeginResetPassword(ctx, + "<resource-group-name>", + "<lab-name>", + "<virtual-machine-name>", + armlabservices.ResetPasswordBody{ + Password: to.StringPtr("<password>"), + Username: to.StringPtr("<username>"), + }, + 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/labservices/armlabservices/zz_generated_constants.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_constants.go new file mode 100644 index 000000000000..c1c46024f114 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_constants.go @@ -0,0 +1,623 @@ +//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 armlabservices + +const ( + module = "armlabservices" + version = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ToPtr returns a *ActionType pointing to the current value. +func (c ActionType) ToPtr() *ActionType { + return &c +} + +// ConnectionType - A connection type for access labs and VMs (Public, Private or None). +type ConnectionType string + +const ( + ConnectionTypePublic ConnectionType = "Public" + ConnectionTypePrivate ConnectionType = "Private" + ConnectionTypeNone ConnectionType = "None" +) + +// PossibleConnectionTypeValues returns the possible values for the ConnectionType const type. +func PossibleConnectionTypeValues() []ConnectionType { + return []ConnectionType{ + ConnectionTypePublic, + ConnectionTypePrivate, + ConnectionTypeNone, + } +} + +// ToPtr returns a *ConnectionType pointing to the current value. +func (c ConnectionType) ToPtr() *ConnectionType { + return &c +} + +// CreateOption - Indicates what lab virtual machines are created from. +type CreateOption string + +const ( + // CreateOptionImage - An image is used to create all lab user virtual machines. When this option is set, no template VM will be created. + CreateOptionImage CreateOption = "Image" + // CreateOptionTemplateVM - A template VM will be used to create all lab user virtual machines. + CreateOptionTemplateVM CreateOption = "TemplateVM" +) + +// PossibleCreateOptionValues returns the possible values for the CreateOption const type. +func PossibleCreateOptionValues() []CreateOption { + return []CreateOption{ + CreateOptionImage, + CreateOptionTemplateVM, + } +} + +// ToPtr returns a *CreateOption pointing to the current value. +func (c CreateOption) ToPtr() *CreateOption { + return &c +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// EnableState - Property enabled state. +type EnableState string + +const ( + EnableStateEnabled EnableState = "Enabled" + EnableStateDisabled EnableState = "Disabled" +) + +// PossibleEnableStateValues returns the possible values for the EnableState const type. +func PossibleEnableStateValues() []EnableState { + return []EnableState{ + EnableStateEnabled, + EnableStateDisabled, + } +} + +// ToPtr returns a *EnableState pointing to the current value. +func (c EnableState) ToPtr() *EnableState { + return &c +} + +// InvitationState - The lab user invitation state. +type InvitationState string + +const ( + // InvitationStateNotSent - The invitation has not been sent. + InvitationStateNotSent InvitationState = "NotSent" + // InvitationStateSending - Currently sending the invitation. + InvitationStateSending InvitationState = "Sending" + // InvitationStateSent - The invitation has been successfully sent. + InvitationStateSent InvitationState = "Sent" + // InvitationStateFailed - There was an error while sending the invitation. + InvitationStateFailed InvitationState = "Failed" +) + +// PossibleInvitationStateValues returns the possible values for the InvitationState const type. +func PossibleInvitationStateValues() []InvitationState { + return []InvitationState{ + InvitationStateNotSent, + InvitationStateSending, + InvitationStateSent, + InvitationStateFailed, + } +} + +// ToPtr returns a *InvitationState pointing to the current value. +func (c InvitationState) ToPtr() *InvitationState { + return &c +} + +// LabServicesSKUTier - The tier of the SKU. +type LabServicesSKUTier string + +const ( + LabServicesSKUTierPremium LabServicesSKUTier = "Premium" + LabServicesSKUTierStandard LabServicesSKUTier = "Standard" +) + +// PossibleLabServicesSKUTierValues returns the possible values for the LabServicesSKUTier const type. +func PossibleLabServicesSKUTierValues() []LabServicesSKUTier { + return []LabServicesSKUTier{ + LabServicesSKUTierPremium, + LabServicesSKUTierStandard, + } +} + +// ToPtr returns a *LabServicesSKUTier pointing to the current value. +func (c LabServicesSKUTier) ToPtr() *LabServicesSKUTier { + return &c +} + +// LabState - The state of a virtual machine. +type LabState string + +const ( + // LabStateDraft - The lab is currently in draft (has not been published). + LabStateDraft LabState = "Draft" + // LabStatePublishing - The lab is publishing. + LabStatePublishing LabState = "Publishing" + // LabStateScaling - The lab is scaling. + LabStateScaling LabState = "Scaling" + // LabStateSyncing - The lab is syncing users. + LabStateSyncing LabState = "Syncing" + // LabStatePublished - The lab has been published. + LabStatePublished LabState = "Published" +) + +// PossibleLabStateValues returns the possible values for the LabState const type. +func PossibleLabStateValues() []LabState { + return []LabState{ + LabStateDraft, + LabStatePublishing, + LabStateScaling, + LabStateSyncing, + LabStatePublished, + } +} + +// ToPtr returns a *LabState pointing to the current value. +func (c LabState) ToPtr() *LabState { + return &c +} + +// OperationStatus - The operation status +type OperationStatus string + +const ( + // OperationStatusNotStarted - The operation has been accepted but hasn't started. + OperationStatusNotStarted OperationStatus = "NotStarted" + // OperationStatusInProgress - The operation is running + OperationStatusInProgress OperationStatus = "InProgress" + // OperationStatusSucceeded - The operation Succeeded + OperationStatusSucceeded OperationStatus = "Succeeded" + // OperationStatusFailed - The operation failed + OperationStatusFailed OperationStatus = "Failed" + // OperationStatusCanceled - Not supported yet + OperationStatusCanceled OperationStatus = "Canceled" +) + +// PossibleOperationStatusValues returns the possible values for the OperationStatus const type. +func PossibleOperationStatusValues() []OperationStatus { + return []OperationStatus{ + OperationStatusNotStarted, + OperationStatusInProgress, + OperationStatusSucceeded, + OperationStatusFailed, + OperationStatusCanceled, + } +} + +// ToPtr returns a *OperationStatus pointing to the current value. +func (c OperationStatus) ToPtr() *OperationStatus { + return &c +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ToPtr returns a *Origin pointing to the current value. +func (c Origin) ToPtr() *Origin { + return &c +} + +// OsState - The operating system state. +type OsState string + +const ( + // OsStateGeneralized - Image does not contain any machine and user specific information. + OsStateGeneralized OsState = "Generalized" + // OsStateSpecialized - Image contains machine and user specific information. + OsStateSpecialized OsState = "Specialized" +) + +// PossibleOsStateValues returns the possible values for the OsState const type. +func PossibleOsStateValues() []OsState { + return []OsState{ + OsStateGeneralized, + OsStateSpecialized, + } +} + +// ToPtr returns a *OsState pointing to the current value. +func (c OsState) ToPtr() *OsState { + return &c +} + +// OsType - The operating system type. +type OsType string + +const ( + OsTypeWindows OsType = "Windows" + OsTypeLinux OsType = "Linux" +) + +// PossibleOsTypeValues returns the possible values for the OsType const type. +func PossibleOsTypeValues() []OsType { + return []OsType{ + OsTypeWindows, + OsTypeLinux, + } +} + +// ToPtr returns a *OsType pointing to the current value. +func (c OsType) ToPtr() *OsType { + return &c +} + +// ProvisioningState - Resource provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCreating - Resource is in the process of being created. + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateUpdating - New property values are being applied to the resource. + ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateDeleting - Resource is in the process of being deleted. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateSucceeded - Resource is in healthy state after creation or update operation. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateFailed - Previous operation on the resource has failed leaving resource in unhealthy state. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateLocked - The resource is locked and changes are currently blocked. This could be due to maintenance or a scheduled operation. The state + // will go back to succeeded once the locking operation has finished. + ProvisioningStateLocked ProvisioningState = "Locked" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCreating, + ProvisioningStateUpdating, + ProvisioningStateDeleting, + ProvisioningStateSucceeded, + ProvisioningStateFailed, + ProvisioningStateLocked, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// RecurrenceFrequency - Schedule recurrence frequencies. +type RecurrenceFrequency string + +const ( + // RecurrenceFrequencyDaily - Schedule will run every days. + RecurrenceFrequencyDaily RecurrenceFrequency = "Daily" + // RecurrenceFrequencyWeekly - Schedule will run every week on days specified in weekDays. + RecurrenceFrequencyWeekly RecurrenceFrequency = "Weekly" +) + +// PossibleRecurrenceFrequencyValues returns the possible values for the RecurrenceFrequency const type. +func PossibleRecurrenceFrequencyValues() []RecurrenceFrequency { + return []RecurrenceFrequency{ + RecurrenceFrequencyDaily, + RecurrenceFrequencyWeekly, + } +} + +// ToPtr returns a *RecurrenceFrequency pointing to the current value. +func (c RecurrenceFrequency) ToPtr() *RecurrenceFrequency { + return &c +} + +// RegistrationState - The user lab registration state. +type RegistrationState string + +const ( + // RegistrationStateRegistered - User has not yet registered with the lab. + RegistrationStateRegistered RegistrationState = "Registered" + // RegistrationStateNotRegistered - User has registered with the lab. + RegistrationStateNotRegistered RegistrationState = "NotRegistered" +) + +// PossibleRegistrationStateValues returns the possible values for the RegistrationState const type. +func PossibleRegistrationStateValues() []RegistrationState { + return []RegistrationState{ + RegistrationStateRegistered, + RegistrationStateNotRegistered, + } +} + +// ToPtr returns a *RegistrationState pointing to the current value. +func (c RegistrationState) ToPtr() *RegistrationState { + return &c +} + +// RestrictionReasonCode - The reason for the restriction. +type RestrictionReasonCode string + +const ( + RestrictionReasonCodeNotAvailableForSubscription RestrictionReasonCode = "NotAvailableForSubscription" + RestrictionReasonCodeQuotaID RestrictionReasonCode = "QuotaId" +) + +// PossibleRestrictionReasonCodeValues returns the possible values for the RestrictionReasonCode const type. +func PossibleRestrictionReasonCodeValues() []RestrictionReasonCode { + return []RestrictionReasonCode{ + RestrictionReasonCodeNotAvailableForSubscription, + RestrictionReasonCodeQuotaID, + } +} + +// ToPtr returns a *RestrictionReasonCode pointing to the current value. +func (c RestrictionReasonCode) ToPtr() *RestrictionReasonCode { + return &c +} + +// RestrictionType - The type of restriction. +type RestrictionType string + +const ( + RestrictionTypeLocation RestrictionType = "Location" +) + +// PossibleRestrictionTypeValues returns the possible values for the RestrictionType const type. +func PossibleRestrictionTypeValues() []RestrictionType { + return []RestrictionType{ + RestrictionTypeLocation, + } +} + +// ToPtr returns a *RestrictionType pointing to the current value. +func (c RestrictionType) ToPtr() *RestrictionType { + return &c +} + +// SKUTier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. +type SKUTier string + +const ( + SKUTierFree SKUTier = "Free" + SKUTierBasic SKUTier = "Basic" + SKUTierStandard SKUTier = "Standard" + SKUTierPremium SKUTier = "Premium" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierFree, + SKUTierBasic, + SKUTierStandard, + SKUTierPremium, + } +} + +// ToPtr returns a *SKUTier pointing to the current value. +func (c SKUTier) ToPtr() *SKUTier { + return &c +} + +// ScaleType - The localized name of the resource. +type ScaleType string + +const ( + // ScaleTypeAutomatic - The user is permitted to scale this SKU in and out. + ScaleTypeAutomatic ScaleType = "Automatic" + // ScaleTypeManual - The user must manually scale this SKU in and out. + ScaleTypeManual ScaleType = "Manual" + // ScaleTypeNone - The capacity is not adjustable in any way. + ScaleTypeNone ScaleType = "None" +) + +// PossibleScaleTypeValues returns the possible values for the ScaleType const type. +func PossibleScaleTypeValues() []ScaleType { + return []ScaleType{ + ScaleTypeAutomatic, + ScaleTypeManual, + ScaleTypeNone, + } +} + +// ToPtr returns a *ScaleType pointing to the current value. +func (c ScaleType) ToPtr() *ScaleType { + return &c +} + +// ShutdownOnIdleMode - Defines whether to shut down VM on idle and the criteria for idle detection. +type ShutdownOnIdleMode string + +const ( + // ShutdownOnIdleModeNone - The VM won't be shut down when it is idle. + ShutdownOnIdleModeNone ShutdownOnIdleMode = "None" + // ShutdownOnIdleModeUserAbsence - The VM will be considered as idle when there is no keyboard or mouse input. + ShutdownOnIdleModeUserAbsence ShutdownOnIdleMode = "UserAbsence" + // ShutdownOnIdleModeLowUsage - The VM will be considered as idle when user is absent and the resource (CPU and disk) consumption is low. + ShutdownOnIdleModeLowUsage ShutdownOnIdleMode = "LowUsage" +) + +// PossibleShutdownOnIdleModeValues returns the possible values for the ShutdownOnIdleMode const type. +func PossibleShutdownOnIdleModeValues() []ShutdownOnIdleMode { + return []ShutdownOnIdleMode{ + ShutdownOnIdleModeNone, + ShutdownOnIdleModeUserAbsence, + ShutdownOnIdleModeLowUsage, + } +} + +// ToPtr returns a *ShutdownOnIdleMode pointing to the current value. +func (c ShutdownOnIdleMode) ToPtr() *ShutdownOnIdleMode { + return &c +} + +// UsageUnit - The unit details. +type UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +// PossibleUsageUnitValues returns the possible values for the UsageUnit const type. +func PossibleUsageUnitValues() []UsageUnit { + return []UsageUnit{ + UsageUnitCount, + } +} + +// ToPtr returns a *UsageUnit pointing to the current value. +func (c UsageUnit) ToPtr() *UsageUnit { + return &c +} + +// VirtualMachineState - The state of a virtual machine. +type VirtualMachineState string + +const ( + // VirtualMachineStateStopped - The VM is currently stopped. + VirtualMachineStateStopped VirtualMachineState = "Stopped" + // VirtualMachineStateStarting - The VM is starting. + VirtualMachineStateStarting VirtualMachineState = "Starting" + // VirtualMachineStateRunning - The VM is running. + VirtualMachineStateRunning VirtualMachineState = "Running" + // VirtualMachineStateStopping - The VM is stopping. + VirtualMachineStateStopping VirtualMachineState = "Stopping" + // VirtualMachineStateResettingPassword - The VM password is being reset. + VirtualMachineStateResettingPassword VirtualMachineState = "ResettingPassword" + // VirtualMachineStateReimaging - The VM is being reimaged. + VirtualMachineStateReimaging VirtualMachineState = "Reimaging" + // VirtualMachineStateRedeploying - The VM is being redeployed. + VirtualMachineStateRedeploying VirtualMachineState = "Redeploying" +) + +// PossibleVirtualMachineStateValues returns the possible values for the VirtualMachineState const type. +func PossibleVirtualMachineStateValues() []VirtualMachineState { + return []VirtualMachineState{ + VirtualMachineStateStopped, + VirtualMachineStateStarting, + VirtualMachineStateRunning, + VirtualMachineStateStopping, + VirtualMachineStateResettingPassword, + VirtualMachineStateReimaging, + VirtualMachineStateRedeploying, + } +} + +// ToPtr returns a *VirtualMachineState pointing to the current value. +func (c VirtualMachineState) ToPtr() *VirtualMachineState { + return &c +} + +// VirtualMachineType - The type of the lab virtual machine. +type VirtualMachineType string + +const ( + // VirtualMachineTypeUser - A user VM + VirtualMachineTypeUser VirtualMachineType = "User" + // VirtualMachineTypeTemplate - A template VM + VirtualMachineTypeTemplate VirtualMachineType = "Template" +) + +// PossibleVirtualMachineTypeValues returns the possible values for the VirtualMachineType const type. +func PossibleVirtualMachineTypeValues() []VirtualMachineType { + return []VirtualMachineType{ + VirtualMachineTypeUser, + VirtualMachineTypeTemplate, + } +} + +// ToPtr returns a *VirtualMachineType pointing to the current value. +func (c VirtualMachineType) ToPtr() *VirtualMachineType { + return &c +} + +// WeekDay - Days of the week. +type WeekDay string + +const ( + // WeekDaySunday - Schedule will run on Sunday + WeekDaySunday WeekDay = "Sunday" + // WeekDayMonday - Schedule will run on Monday + WeekDayMonday WeekDay = "Monday" + // WeekDayTuesday - Schedule will run on Tuesday + WeekDayTuesday WeekDay = "Tuesday" + // WeekDayWednesday - Schedule will run on Wednesday + WeekDayWednesday WeekDay = "Wednesday" + // WeekDayThursday - Schedule will run on Thursday + WeekDayThursday WeekDay = "Thursday" + // WeekDayFriday - Schedule will run on Friday + WeekDayFriday WeekDay = "Friday" + // WeekDaySaturday - Schedule will run on Saturday + WeekDaySaturday WeekDay = "Saturday" +) + +// PossibleWeekDayValues returns the possible values for the WeekDay const type. +func PossibleWeekDayValues() []WeekDay { + return []WeekDay{ + WeekDaySunday, + WeekDayMonday, + WeekDayTuesday, + WeekDayWednesday, + WeekDayThursday, + WeekDayFriday, + WeekDaySaturday, + } +} + +// ToPtr returns a *WeekDay pointing to the current value. +func (c WeekDay) ToPtr() *WeekDay { + return &c +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_date_type.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_date_type.go new file mode 100644 index 000000000000..d2fb93a23de4 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_date_type.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 armlabservices + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "strings" + "time" +) + +const ( + fullDateJSON = `"2006-01-02"` + jsonFormat = `"%04d-%02d-%02d"` +) + +type dateType time.Time + +func (t dateType) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(jsonFormat, time.Time(t).Year(), time.Time(t).Month(), time.Time(t).Day())), nil +} + +func (d *dateType) UnmarshalJSON(data []byte) (err error) { + t, err := time.Parse(fullDateJSON, string(data)) + *d = (dateType)(t) + return err +} + +func populateDateType(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] = (*dateType)(t) +} + +func unpopulateDateType(data json.RawMessage, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateType + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_images_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_images_client.go new file mode 100644 index 000000000000..9721dfac5197 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_images_client.go @@ -0,0 +1,315 @@ +//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 armlabservices + +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" +) + +// ImagesClient contains the methods for the Images group. +// Don't use this type directly, use NewImagesClient() instead. +type ImagesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewImagesClient creates a new instance of ImagesClient with the specified values. +func NewImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ImagesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ImagesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Updates an image resource via PUT. Creating new resources via PUT will not function. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ImagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body Image, options *ImagesCreateOrUpdateOptions) (ImagesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labPlanName, imageName, body, options) + if err != nil { + return ImagesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImagesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ImagesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body Image, options *ImagesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ImagesClient) createOrUpdateHandleResponse(resp *http.Response) (ImagesCreateOrUpdateResponse, error) { + result := ImagesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Image); err != nil { + return ImagesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ImagesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets an image resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ImagesClient) Get(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, options *ImagesGetOptions) (ImagesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, labPlanName, imageName, options) + if err != nil { + return ImagesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImagesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ImagesClient) getCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, options *ImagesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ImagesClient) getHandleResponse(resp *http.Response) (ImagesGetResponse, error) { + result := ImagesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Image); err != nil { + return ImagesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ImagesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByLabPlan - Gets all images from galleries attached to a lab plan. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ImagesClient) ListByLabPlan(resourceGroupName string, labPlanName string, options *ImagesListByLabPlanOptions) *ImagesListByLabPlanPager { + return &ImagesListByLabPlanPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByLabPlanCreateRequest(ctx, resourceGroupName, labPlanName, options) + }, + advancer: func(ctx context.Context, resp ImagesListByLabPlanResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedImages.NextLink) + }, + } +} + +// listByLabPlanCreateRequest creates the ListByLabPlan request. +func (client *ImagesClient) listByLabPlanCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, options *ImagesListByLabPlanOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + 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-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByLabPlanHandleResponse handles the ListByLabPlan response. +func (client *ImagesClient) listByLabPlanHandleResponse(resp *http.Response) (ImagesListByLabPlanResponse, error) { + result := ImagesListByLabPlanResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedImages); err != nil { + return ImagesListByLabPlanResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByLabPlanHandleError handles the ListByLabPlan error response. +func (client *ImagesClient) listByLabPlanHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updates an image resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ImagesClient) Update(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body ImageUpdate, options *ImagesUpdateOptions) (ImagesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, labPlanName, imageName, body, options) + if err != nil { + return ImagesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImagesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ImagesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body ImageUpdate, options *ImagesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleResponse handles the Update response. +func (client *ImagesClient) updateHandleResponse(resp *http.Response) (ImagesUpdateResponse, error) { + result := ImagesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Image); err != nil { + return ImagesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ImagesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_labplans_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_labplans_client.go new file mode 100644 index 000000000000..9f5fc66d73e8 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_labplans_client.go @@ -0,0 +1,529 @@ +//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 armlabservices + +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" +) + +// LabPlansClient contains the methods for the LabPlans group. +// Don't use this type directly, use NewLabPlansClient() instead. +type LabPlansClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLabPlansClient creates a new instance of LabPlansClient with the specified values. +func NewLabPlansClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LabPlansClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LabPlansClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Operation to create or update a Lab Plan resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlan, options *LabPlansBeginCreateOrUpdateOptions) (LabPlansCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, labPlanName, body, options) + if err != nil { + return LabPlansCreateOrUpdatePollerResponse{}, err + } + result := LabPlansCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabPlansClient.CreateOrUpdate", "original-uri", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return LabPlansCreateOrUpdatePollerResponse{}, err + } + result.Poller = &LabPlansCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Operation to create or update a Lab Plan resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) createOrUpdate(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlan, options *LabPlansBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labPlanName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LabPlansClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlan, options *LabPlansBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LabPlansClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Operation to delete a Lab Plan resource. Deleting a lab plan does not delete labs associated with a lab plan, nor does it delete shared +// images added to a gallery via the lab plan permission container. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) BeginDelete(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansBeginDeleteOptions) (LabPlansDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, labPlanName, options) + if err != nil { + return LabPlansDeletePollerResponse{}, err + } + result := LabPlansDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabPlansClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return LabPlansDeletePollerResponse{}, err + } + result.Poller = &LabPlansDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Operation to delete a Lab Plan resource. Deleting a lab plan does not delete labs associated with a lab plan, nor does it delete shared images +// added to a gallery via the lab plan permission container. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) deleteOperation(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, labPlanName, 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 *LabPlansClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LabPlansClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Retrieves the properties of a Lab Plan. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) Get(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansGetOptions) (LabPlansGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, labPlanName, options) + if err != nil { + return LabPlansGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LabPlansGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LabPlansGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LabPlansClient) getCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LabPlansClient) getHandleResponse(resp *http.Response) (LabPlansGetResponse, error) { + result := LabPlansGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LabPlan); err != nil { + return LabPlansGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LabPlansClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Returns a list of all lab plans for a subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) ListByResourceGroup(resourceGroupName string, options *LabPlansListByResourceGroupOptions) *LabPlansListByResourceGroupPager { + return &LabPlansListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp LabPlansListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedLabPlans.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *LabPlansClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *LabPlansListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans" + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *LabPlansClient) listByResourceGroupHandleResponse(resp *http.Response) (LabPlansListByResourceGroupResponse, error) { + result := LabPlansListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedLabPlans); err != nil { + return LabPlansListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *LabPlansClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Returns a list of all lab plans within a subscription +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) ListBySubscription(options *LabPlansListBySubscriptionOptions) *LabPlansListBySubscriptionPager { + return &LabPlansListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp LabPlansListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedLabPlans.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *LabPlansClient) listBySubscriptionCreateRequest(ctx context.Context, options *LabPlansListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labPlans" + 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-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *LabPlansClient) listBySubscriptionHandleResponse(resp *http.Response) (LabPlansListBySubscriptionResponse, error) { + result := LabPlansListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedLabPlans); err != nil { + return LabPlansListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *LabPlansClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginSaveImage - Saves an image from a lab VM to the attached shared image gallery. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) BeginSaveImage(ctx context.Context, resourceGroupName string, labPlanName string, body SaveImageBody, options *LabPlansBeginSaveImageOptions) (LabPlansSaveImagePollerResponse, error) { + resp, err := client.saveImage(ctx, resourceGroupName, labPlanName, body, options) + if err != nil { + return LabPlansSaveImagePollerResponse{}, err + } + result := LabPlansSaveImagePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabPlansClient.SaveImage", "location", resp, client.pl, client.saveImageHandleError) + if err != nil { + return LabPlansSaveImagePollerResponse{}, err + } + result.Poller = &LabPlansSaveImagePoller{ + pt: pt, + } + return result, nil +} + +// SaveImage - Saves an image from a lab VM to the attached shared image gallery. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) saveImage(ctx context.Context, resourceGroupName string, labPlanName string, body SaveImageBody, options *LabPlansBeginSaveImageOptions) (*http.Response, error) { + req, err := client.saveImageCreateRequest(ctx, resourceGroupName, labPlanName, body, 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.saveImageHandleError(resp) + } + return resp, nil +} + +// saveImageCreateRequest creates the SaveImage request. +func (client *LabPlansClient) saveImageCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, body SaveImageBody, options *LabPlansBeginSaveImageOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/saveImage" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// saveImageHandleError handles the SaveImage error response. +func (client *LabPlansClient) saveImageHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Operation to update a Lab Plan resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) BeginUpdate(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlanUpdate, options *LabPlansBeginUpdateOptions) (LabPlansUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, labPlanName, body, options) + if err != nil { + return LabPlansUpdatePollerResponse{}, err + } + result := LabPlansUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabPlansClient.Update", "location", resp, client.pl, client.updateHandleError) + if err != nil { + return LabPlansUpdatePollerResponse{}, err + } + result.Poller = &LabPlansUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Operation to update a Lab Plan resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabPlansClient) update(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlanUpdate, options *LabPlansBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, labPlanName, body, 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 *LabPlansClient) updateCreateRequest(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlanUpdate, options *LabPlansBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}" + 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 labPlanName == "" { + return nil, errors.New("parameter labPlanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labPlanName}", url.PathEscape(labPlanName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleError handles the Update error response. +func (client *LabPlansClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_labs_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_labs_client.go new file mode 100644 index 000000000000..f234d92481f9 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_labs_client.go @@ -0,0 +1,603 @@ +//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 armlabservices + +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" +) + +// LabsClient contains the methods for the Labs group. +// Don't use this type directly, use NewLabsClient() instead. +type LabsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLabsClient creates a new instance of LabsClient with the specified values. +func NewLabsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LabsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LabsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Operation to create or update a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, body Lab, options *LabsBeginCreateOrUpdateOptions) (LabsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, body, options) + if err != nil { + return LabsCreateOrUpdatePollerResponse{}, err + } + result := LabsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabsClient.CreateOrUpdate", "original-uri", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return LabsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &LabsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Operation to create or update a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, body Lab, options *LabsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LabsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, labName string, body Lab, options *LabsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LabsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Operation to delete a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginDeleteOptions) (LabsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, labName, options) + if err != nil { + return LabsDeletePollerResponse{}, err + } + result := LabsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabsClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return LabsDeletePollerResponse{}, err + } + result.Poller = &LabsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Operation to delete a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, 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 *LabsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LabsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Returns the properties of a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) Get(ctx context.Context, resourceGroupName string, labName string, options *LabsGetOptions) (LabsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, labName, options) + if err != nil { + return LabsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LabsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LabsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LabsClient) getCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *LabsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LabsClient) getHandleResponse(resp *http.Response) (LabsGetResponse, error) { + result := LabsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Lab); err != nil { + return LabsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LabsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Returns a list of all labs in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) ListByResourceGroup(resourceGroupName string, options *LabsListByResourceGroupOptions) *LabsListByResourceGroupPager { + return &LabsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp LabsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedLabs.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *LabsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *LabsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs" + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *LabsClient) listByResourceGroupHandleResponse(resp *http.Response) (LabsListByResourceGroupResponse, error) { + result := LabsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedLabs); err != nil { + return LabsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *LabsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Returns a list of all labs for a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) ListBySubscription(options *LabsListBySubscriptionOptions) *LabsListBySubscriptionPager { + return &LabsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp LabsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedLabs.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *LabsClient) listBySubscriptionCreateRequest(ctx context.Context, options *LabsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labs" + 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-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *LabsClient) listBySubscriptionHandleResponse(resp *http.Response) (LabsListBySubscriptionResponse, error) { + result := LabsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedLabs); err != nil { + return LabsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *LabsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginPublish - Publish or re-publish a lab. This will create or update all lab resources, such as virtual machines. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) BeginPublish(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginPublishOptions) (LabsPublishPollerResponse, error) { + resp, err := client.publish(ctx, resourceGroupName, labName, options) + if err != nil { + return LabsPublishPollerResponse{}, err + } + result := LabsPublishPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabsClient.Publish", "location", resp, client.pl, client.publishHandleError) + if err != nil { + return LabsPublishPollerResponse{}, err + } + result.Poller = &LabsPublishPoller{ + pt: pt, + } + return result, nil +} + +// Publish - Publish or re-publish a lab. This will create or update all lab resources, such as virtual machines. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) publish(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginPublishOptions) (*http.Response, error) { + req, err := client.publishCreateRequest(ctx, resourceGroupName, labName, 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.publishHandleError(resp) + } + return resp, nil +} + +// publishCreateRequest creates the Publish request. +func (client *LabsClient) publishCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginPublishOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/publish" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// publishHandleError handles the Publish error response. +func (client *LabsClient) publishHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginSyncGroup - Action used to manually kick off an AAD group sync job. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) BeginSyncGroup(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginSyncGroupOptions) (LabsSyncGroupPollerResponse, error) { + resp, err := client.syncGroup(ctx, resourceGroupName, labName, options) + if err != nil { + return LabsSyncGroupPollerResponse{}, err + } + result := LabsSyncGroupPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabsClient.SyncGroup", "location", resp, client.pl, client.syncGroupHandleError) + if err != nil { + return LabsSyncGroupPollerResponse{}, err + } + result.Poller = &LabsSyncGroupPoller{ + pt: pt, + } + return result, nil +} + +// SyncGroup - Action used to manually kick off an AAD group sync job. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) syncGroup(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginSyncGroupOptions) (*http.Response, error) { + req, err := client.syncGroupCreateRequest(ctx, resourceGroupName, labName, 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.syncGroupHandleError(resp) + } + return resp, nil +} + +// syncGroupCreateRequest creates the SyncGroup request. +func (client *LabsClient) syncGroupCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *LabsBeginSyncGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/syncGroup" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// syncGroupHandleError handles the SyncGroup error response. +func (client *LabsClient) syncGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Operation to update a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) BeginUpdate(ctx context.Context, resourceGroupName string, labName string, body LabUpdate, options *LabsBeginUpdateOptions) (LabsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, labName, body, options) + if err != nil { + return LabsUpdatePollerResponse{}, err + } + result := LabsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LabsClient.Update", "location", resp, client.pl, client.updateHandleError) + if err != nil { + return LabsUpdatePollerResponse{}, err + } + result.Poller = &LabsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Operation to update a lab resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LabsClient) update(ctx context.Context, resourceGroupName string, labName string, body LabUpdate, options *LabsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, body, 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 *LabsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, labName string, body LabUpdate, options *LabsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleError handles the Update error response. +func (client *LabsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_models.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_models.go new file mode 100644 index 000000000000..86f584579d2a --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_models.go @@ -0,0 +1,1740 @@ +//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 armlabservices + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AutoShutdownProfile - Profile for how to handle shutting down virtual machines. +type AutoShutdownProfile struct { + // The amount of time a VM will stay running after a user disconnects if this behavior is enabled. + DisconnectDelay *string `json:"disconnectDelay,omitempty"` + + // The amount of time a VM will idle before it is shutdown if this behavior is enabled. + IdleDelay *string `json:"idleDelay,omitempty"` + + // The amount of time a VM will stay running before it is shutdown if no connection is made and this behavior is enabled. + NoConnectDelay *string `json:"noConnectDelay,omitempty"` + + // Whether shutdown on disconnect is enabled + ShutdownOnDisconnect *EnableState `json:"shutdownOnDisconnect,omitempty"` + + // Whether a VM will get shutdown when it has idled for a period of time. + ShutdownOnIdle *ShutdownOnIdleMode `json:"shutdownOnIdle,omitempty"` + + // Whether a VM will get shutdown when it hasn't been connected to after a period of time. + ShutdownWhenNotConnected *EnableState `json:"shutdownWhenNotConnected,omitempty"` +} + +// ConnectionProfile - Connection profile for how users connect to lab virtual machines. +type ConnectionProfile struct { + // The enabled access level for Client Access over RDP. + ClientRdpAccess *ConnectionType `json:"clientRdpAccess,omitempty"` + + // The enabled access level for Client Access over SSH. + ClientSSHAccess *ConnectionType `json:"clientSshAccess,omitempty"` + + // The enabled access level for Web Access over RDP. + WebRdpAccess *ConnectionType `json:"webRdpAccess,omitempty"` + + // The enabled access level for Web Access over SSH. + WebSSHAccess *ConnectionType `json:"webSshAccess,omitempty"` +} + +// Credentials for a user on a lab VM. +type Credentials struct { + // REQUIRED; The username to use when signing in to lab VMs. + Username *string `json:"username,omitempty"` + + // The password for the user. This is required for the TemplateVM createOption. + Password *string `json:"password,omitempty"` +} + +// 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"` +} + +// ErrorDetail - The error detail. +type ErrorDetail 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 []*ErrorDetail `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 ErrorDetail. +func (e ErrorDetail) 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) +} + +// 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.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error object. + InnerError *ErrorDetail `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// Image - Lab services virtual machine image +type Image struct { + ProxyResource + // REQUIRED; Image resource properties + Properties *ImageProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the image. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Image. +func (i Image) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + i.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + return json.Marshal(objectMap) +} + +// ImageProperties - Properties of an image resource. +type ImageProperties struct { + ImageUpdateProperties + // The available regions of the image in the shared gallery. + AvailableRegions []*string `json:"availableRegions,omitempty"` + + // READ-ONLY; The image author. + Author *string `json:"author,omitempty" azure:"ro"` + + // READ-ONLY; A description of the image. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The image display name. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; URL of the image icon. + IconURL *string `json:"iconUrl,omitempty" azure:"ro"` + + // READ-ONLY; The OS State of the image. + OSState *OsState `json:"osState,omitempty" azure:"ro"` + + // READ-ONLY; The OS Type of the image. + OSType *OsType `json:"osType,omitempty" azure:"ro"` + + // READ-ONLY; The ID of an offer associated with the image. + Offer *string `json:"offer,omitempty" azure:"ro"` + + // READ-ONLY; The ID of marketplace plan associated with the image (optional). + Plan *string `json:"plan,omitempty" azure:"ro"` + + // READ-ONLY; Current provisioning state of the image. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The ID of the publisher of the image. + Publisher *string `json:"publisher,omitempty" azure:"ro"` + + // READ-ONLY; The image SKU. + SKU *string `json:"sku,omitempty" azure:"ro"` + + // READ-ONLY; The ID for the image in the shared gallery. + SharedGalleryID *string `json:"sharedGalleryId,omitempty" azure:"ro"` + + // READ-ONLY; The status of image terms of use (enabled = accepted, disabled = not accepted). + TermsStatus *EnableState `json:"termsStatus,omitempty" azure:"ro"` + + // READ-ONLY; The image version. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImageProperties. +func (i ImageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + i.ImageUpdateProperties.marshalInternal(objectMap) + populate(objectMap, "author", i.Author) + populate(objectMap, "availableRegions", i.AvailableRegions) + populate(objectMap, "description", i.Description) + populate(objectMap, "displayName", i.DisplayName) + populate(objectMap, "iconUrl", i.IconURL) + populate(objectMap, "osState", i.OSState) + populate(objectMap, "osType", i.OSType) + populate(objectMap, "offer", i.Offer) + populate(objectMap, "plan", i.Plan) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "publisher", i.Publisher) + populate(objectMap, "sku", i.SKU) + populate(objectMap, "sharedGalleryId", i.SharedGalleryID) + populate(objectMap, "termsStatus", i.TermsStatus) + populate(objectMap, "version", i.Version) + return json.Marshal(objectMap) +} + +// ImageReference - Image reference information. Used in the virtual machine profile. +type ImageReference struct { + // Image resource ID + ID *string `json:"id,omitempty"` + + // The image offer if applicable. + Offer *string `json:"offer,omitempty"` + + // The image publisher + Publisher *string `json:"publisher,omitempty"` + + // The image SKU + SKU *string `json:"sku,omitempty"` + + // The image version specified on creation. + Version *string `json:"version,omitempty"` + + // READ-ONLY; The actual version of the image after use. + ExactVersion *string `json:"exactVersion,omitempty" azure:"ro"` +} + +// ImageUpdate - Lab services virtual machine image for updates. +type ImageUpdate struct { + // Image resource properties + Properties *ImageUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImageUpdate. +func (i ImageUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// ImageUpdateProperties - Properties of an image resource update +type ImageUpdateProperties struct { + // Is the image enabled + EnabledState *EnableState `json:"enabledState,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImageUpdateProperties. +func (i ImageUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + i.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (i ImageUpdateProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "enabledState", i.EnabledState) +} + +// ImagesCreateOrUpdateOptions contains the optional parameters for the Images.CreateOrUpdate method. +type ImagesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ImagesGetOptions contains the optional parameters for the Images.Get method. +type ImagesGetOptions struct { + // placeholder for future optional parameters +} + +// ImagesListByLabPlanOptions contains the optional parameters for the Images.ListByLabPlan method. +type ImagesListByLabPlanOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// ImagesUpdateOptions contains the optional parameters for the Images.Update method. +type ImagesUpdateOptions struct { + // placeholder for future optional parameters +} + +// InviteBody - Body for a user invite request +type InviteBody struct { + // Custom text for the invite email. + Text *string `json:"text,omitempty"` +} + +// Lab - The lab resource. +type Lab struct { + TrackedResource + // REQUIRED; Lab resource properties + Properties *LabProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the lab. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Lab. +func (l Lab) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + return json.Marshal(objectMap) +} + +// LabNetworkProfile - Profile for how to handle networking for Labs. +type LabNetworkProfile struct { + // The external load balancer resource id + LoadBalancerID *string `json:"loadBalancerId,omitempty"` + + // The external public IP resource id + PublicIPID *string `json:"publicIpId,omitempty"` + + // The external subnet resource id + SubnetID *string `json:"subnetId,omitempty"` +} + +// LabPlan - Lab Plans act as a permission container for creating labs via labs.azure.com. Additionally, they can provide a set of default configurations +// that will apply at the time of creating a lab, but these +// defaults can still be overwritten. +type LabPlan struct { + TrackedResource + // REQUIRED; Lab plan resource properties + Properties *LabPlanProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the lab plan. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabPlan. +func (l LabPlan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + return json.Marshal(objectMap) +} + +// LabPlanNetworkProfile - Profile for how to handle networking for Lab Plans. +type LabPlanNetworkProfile struct { + // The external subnet resource id + SubnetID *string `json:"subnetId,omitempty"` +} + +// LabPlanProperties - Lab plan resource properties +type LabPlanProperties struct { + LabPlanUpdateProperties + // READ-ONLY; Current provisioning state of the lab plan. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabPlanProperties. +func (l LabPlanProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.LabPlanUpdateProperties.marshalInternal(objectMap) + populate(objectMap, "provisioningState", l.ProvisioningState) + return json.Marshal(objectMap) +} + +// LabPlanUpdate - Contains lab configuration and default settings. This variant is used for PATCH. +type LabPlanUpdate struct { + TrackedResourceUpdate + // Lab plan resource update properties + Properties *LabPlanUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabPlanUpdate. +func (l LabPlanUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.TrackedResourceUpdate.marshalInternal(objectMap) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LabPlanUpdateProperties - Lab plan resource properties for updates +type LabPlanUpdateProperties struct { + // The allowed regions for the lab creator to use when creating labs using this lab plan. + AllowedRegions []*string `json:"allowedRegions,omitempty"` + + // The default lab shutdown profile. This can be changed on a lab resource and only provides a default profile. + DefaultAutoShutdownProfile *AutoShutdownProfile `json:"defaultAutoShutdownProfile,omitempty"` + + // The default lab connection profile. This can be changed on a lab resource and only provides a default profile. + DefaultConnectionProfile *ConnectionProfile `json:"defaultConnectionProfile,omitempty"` + + // The lab plan network profile. To enforce lab network policies they must be defined here and cannot be changed when there are existing labs associated + // with this lab plan. + DefaultNetworkProfile *LabPlanNetworkProfile `json:"defaultNetworkProfile,omitempty"` + + // Base Url of the lms instance this lab plan can link lab rosters against. + LinkedLmsInstance *string `json:"linkedLmsInstance,omitempty"` + + // Resource ID of the Shared Image Gallery attached to this lab plan. When saving a lab template virtual machine image it will be persisted in this gallery. + // Shared images from the gallery can be made + // available to use when creating new labs. + SharedGalleryID *string `json:"sharedGalleryId,omitempty"` + + // Support contact information and instructions for users of the lab plan. This information is displayed to lab owners and virtual machine users for all + // labs in the lab plan. + SupportInfo *SupportInfo `json:"supportInfo,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabPlanUpdateProperties. +func (l LabPlanUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (l LabPlanUpdateProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "allowedRegions", l.AllowedRegions) + populate(objectMap, "defaultAutoShutdownProfile", l.DefaultAutoShutdownProfile) + populate(objectMap, "defaultConnectionProfile", l.DefaultConnectionProfile) + populate(objectMap, "defaultNetworkProfile", l.DefaultNetworkProfile) + populate(objectMap, "linkedLmsInstance", l.LinkedLmsInstance) + populate(objectMap, "sharedGalleryId", l.SharedGalleryID) + populate(objectMap, "supportInfo", l.SupportInfo) +} + +// LabPlansBeginCreateOrUpdateOptions contains the optional parameters for the LabPlans.BeginCreateOrUpdate method. +type LabPlansBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LabPlansBeginDeleteOptions contains the optional parameters for the LabPlans.BeginDelete method. +type LabPlansBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// LabPlansBeginSaveImageOptions contains the optional parameters for the LabPlans.BeginSaveImage method. +type LabPlansBeginSaveImageOptions struct { + // placeholder for future optional parameters +} + +// LabPlansBeginUpdateOptions contains the optional parameters for the LabPlans.BeginUpdate method. +type LabPlansBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// LabPlansGetOptions contains the optional parameters for the LabPlans.Get method. +type LabPlansGetOptions struct { + // placeholder for future optional parameters +} + +// LabPlansListByResourceGroupOptions contains the optional parameters for the LabPlans.ListByResourceGroup method. +type LabPlansListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// LabPlansListBySubscriptionOptions contains the optional parameters for the LabPlans.ListBySubscription method. +type LabPlansListBySubscriptionOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// LabProperties - Properties of a lab resource. +type LabProperties struct { + LabUpdateProperties + // The network profile for the lab, typically applied via a lab plan. This profile cannot be modified once a lab has been created. + NetworkProfile *LabNetworkProfile `json:"networkProfile,omitempty"` + + // READ-ONLY; Current provisioning state of the lab. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The lab state. + State *LabState `json:"state,omitempty" azure:"ro"` +} + +// LabServicesSKU - Azure Lab Services resource SKUs +type LabServicesSKU struct { + // The scale out/in options of the SKU. + Capacity *LabServicesSKUCapacity `json:"capacity,omitempty"` + + // READ-ONLY; The capabilities of the SKU. + Capabilities []*LabServicesSKUCapabilities `json:"capabilities,omitempty" azure:"ro"` + + // READ-ONLY; Metadata for retrieving price info of a lab services SKUs. + Costs []*LabServicesSKUCost `json:"costs,omitempty" azure:"ro"` + + // READ-ONLY; The family of the SKU. + Family *string `json:"family,omitempty" azure:"ro"` + + // READ-ONLY; List of locations that are available for a size. + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; The name of the SKU. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The lab services resource type. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; Restrictions of a lab services SKUs. + Restrictions []*LabServicesSKURestrictions `json:"restrictions,omitempty" azure:"ro"` + + // READ-ONLY; The SKU size. + Size *string `json:"size,omitempty" azure:"ro"` + + // READ-ONLY; The tier of the SKU. + Tier *LabServicesSKUTier `json:"tier,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabServicesSKU. +func (l LabServicesSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capabilities", l.Capabilities) + populate(objectMap, "capacity", l.Capacity) + populate(objectMap, "costs", l.Costs) + populate(objectMap, "family", l.Family) + populate(objectMap, "locations", l.Locations) + populate(objectMap, "name", l.Name) + populate(objectMap, "resourceType", l.ResourceType) + populate(objectMap, "restrictions", l.Restrictions) + populate(objectMap, "size", l.Size) + populate(objectMap, "tier", l.Tier) + return json.Marshal(objectMap) +} + +// LabServicesSKUCapabilities - The array of capabilities of a lab services SKU. +type LabServicesSKUCapabilities struct { + // READ-ONLY; The name of the capability for a SKU. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The value of the capability for a SKU. + Value *string `json:"value,omitempty" azure:"ro"` +} + +// LabServicesSKUCapacity - The scale out/in options of the SKU. +type LabServicesSKUCapacity struct { + // READ-ONLY; The default capacity for this resource. + Default *int64 `json:"default,omitempty" azure:"ro"` + + // READ-ONLY; The highest permitted capacity for this resource. + Maximum *int64 `json:"maximum,omitempty" azure:"ro"` + + // READ-ONLY; The lowest permitted capacity for this resource. + Minimum *int64 `json:"minimum,omitempty" azure:"ro"` + + // READ-ONLY; The localized name of the resource. + ScaleType *ScaleType `json:"scaleType,omitempty" azure:"ro"` +} + +// LabServicesSKUCost - The array of costs of a lab services SKU. +type LabServicesSKUCost struct { + // READ-ONLY; The extended unit. + ExtendedUnit *string `json:"extendedUnit,omitempty" azure:"ro"` + + // READ-ONLY; The meter id. + MeterID *string `json:"meterId,omitempty" azure:"ro"` + + // READ-ONLY; The quantity of units charged. + Quantity *float32 `json:"quantity,omitempty" azure:"ro"` +} + +// LabServicesSKURestrictions - The restriction details. +type LabServicesSKURestrictions struct { + // READ-ONLY; The reason for the restriction. + ReasonCode *RestrictionReasonCode `json:"reasonCode,omitempty" azure:"ro"` + + // READ-ONLY; The type of restriction. + Type *RestrictionType `json:"type,omitempty" azure:"ro"` + + // READ-ONLY; The values of the restriction. + Values []*string `json:"values,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabServicesSKURestrictions. +func (l LabServicesSKURestrictions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reasonCode", l.ReasonCode) + populate(objectMap, "type", l.Type) + populate(objectMap, "values", l.Values) + return json.Marshal(objectMap) +} + +// LabUpdate - The lab resource for updates. +type LabUpdate struct { + TrackedResourceUpdate + // Lab resource properties + Properties *LabUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LabUpdate. +func (l LabUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.TrackedResourceUpdate.marshalInternal(objectMap) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LabUpdateProperties - Properties of a lab resource used for updates. +type LabUpdateProperties struct { + // The resource auto shutdown configuration for the lab. This controls whether actions are taken on resources that are sitting idle. + AutoShutdownProfile *AutoShutdownProfile `json:"autoShutdownProfile,omitempty"` + + // The connection profile for the lab. This controls settings such as web access to lab resources or whether RDP or SSH ports are open. + ConnectionProfile *ConnectionProfile `json:"connectionProfile,omitempty"` + + // The description of the lab. + Description *string `json:"description,omitempty"` + + // The ID of the lab plan. Used during resource creation to provide defaults and acts as a permission container when creating a lab via labs.azure.com. + // Setting a labPlanId on an existing lab provides + // organization.. + LabPlanID *string `json:"labPlanId,omitempty"` + + // The lab user list management profile. + RosterProfile *RosterProfile `json:"rosterProfile,omitempty"` + + // The lab security profile. + SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"` + + // The title of the lab. + Title *string `json:"title,omitempty"` + + // The profile used for creating lab virtual machines. + VirtualMachineProfile *VirtualMachineProfile `json:"virtualMachineProfile,omitempty"` +} + +// LabsBeginCreateOrUpdateOptions contains the optional parameters for the Labs.BeginCreateOrUpdate method. +type LabsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LabsBeginDeleteOptions contains the optional parameters for the Labs.BeginDelete method. +type LabsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// LabsBeginPublishOptions contains the optional parameters for the Labs.BeginPublish method. +type LabsBeginPublishOptions struct { + // placeholder for future optional parameters +} + +// LabsBeginSyncGroupOptions contains the optional parameters for the Labs.BeginSyncGroup method. +type LabsBeginSyncGroupOptions struct { + // placeholder for future optional parameters +} + +// LabsBeginUpdateOptions contains the optional parameters for the Labs.BeginUpdate method. +type LabsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// LabsGetOptions contains the optional parameters for the Labs.Get method. +type LabsGetOptions struct { + // placeholder for future optional parameters +} + +// LabsListByResourceGroupOptions contains the optional parameters for the Labs.ListByResourceGroup method. +type LabsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// LabsListBySubscriptionOptions contains the optional parameters for the Labs.ListBySubscription method. +type LabsListBySubscriptionOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// ListUsagesResult - List of Core Usages. +type ListUsagesResult struct { + // READ-ONLY; The link to get the next page of Usage result. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of Usages. + Value []*Usage `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ListUsagesResult. +func (l ListUsagesResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual + // Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationResult - A long running operation result +type OperationResult struct { + // REQUIRED; The operation status + Status *OperationStatus `json:"status,omitempty"` + + // End time + EndTime *time.Time `json:"endTime,omitempty"` + + // The error for a failure if the operation failed. + Error *ErrorDetail `json:"error,omitempty"` + + // Percent completion + PercentComplete *float32 `json:"percentComplete,omitempty"` + + // Start time + StartTime *time.Time `json:"startTime,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationResult. +func (o OperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "percentComplete", o.PercentComplete) + populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. +func (o *OperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulateTimeRFC3339(val, &o.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &o.Name) + delete(rawMsg, key) + case "percentComplete": + err = unpopulate(val, &o.PercentComplete) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &o.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// OperationResultsGetOptions contains the optional parameters for the OperationResults.Get method. +type OperationResultsGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PagedImages - Paged list of Lab services virtual machine images. +type PagedImages struct { + // READ-ONLY; The link to get the next page of image results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of virtual machine images. + Value []*Image `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedImages. +func (p PagedImages) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PagedLabPlans - Paged list of lab plans. +type PagedLabPlans struct { + // READ-ONLY; The link to get the next page of lab plan results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of lab plans. + Value []*LabPlan `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedLabPlans. +func (p PagedLabPlans) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PagedLabServicesSKUs - Paged list of lab services skus. +type PagedLabServicesSKUs struct { + // READ-ONLY; The link to get the next page of sku results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of sku results. + Value []*LabServicesSKU `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedLabServicesSKUs. +func (p PagedLabServicesSKUs) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PagedLabs - Paged list of labs. +type PagedLabs struct { + // READ-ONLY; The link to get the next page of image results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of lab results. + Value []*Lab `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedLabs. +func (p PagedLabs) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PagedSchedules - Paged list of schedules. +type PagedSchedules struct { + // READ-ONLY; The link to get the next page of schedule results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of schedule results. + Value []*Schedule `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedSchedules. +func (p PagedSchedules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PagedUsers - Paged list of users. +type PagedUsers struct { + // READ-ONLY; The link to get the next page of image results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of user results. + Value []*User `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedUsers. +func (p PagedUsers) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PagedVirtualMachines - Paged list of lab services virtual machines. +type PagedVirtualMachines struct { + // READ-ONLY; The link to get the next page of virtual machine results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of virtual machine results. + Value []*VirtualMachine `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PagedVirtualMachines. +func (p PagedVirtualMachines) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal(objectMap map[string]interface{}) { + p.Resource.marshalInternal(objectMap) +} + +// RecurrencePattern - Recurrence pattern of a lab schedule. +type RecurrencePattern struct { + // REQUIRED; When the recurrence will expire. This date is inclusive. + ExpirationDate *time.Time `json:"expirationDate,omitempty"` + + // REQUIRED; The frequency of the recurrence. + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + + // The interval to invoke the schedule on. For example, interval = 2 and RecurrenceFrequency.Daily will run every 2 days. When no interval is supplied, + // an interval of 1 is used. + Interval *int32 `json:"interval,omitempty"` + + // The week days the schedule runs. Used for when the Frequency is set to Weekly. + WeekDays []*WeekDay `json:"weekDays,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecurrencePattern. +func (r RecurrencePattern) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateDateType(objectMap, "expirationDate", r.ExpirationDate) + populate(objectMap, "frequency", r.Frequency) + populate(objectMap, "interval", r.Interval) + populate(objectMap, "weekDays", r.WeekDays) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecurrencePattern. +func (r *RecurrencePattern) 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 "expirationDate": + err = unpopulateDateType(val, &r.ExpirationDate) + delete(rawMsg, key) + case "frequency": + err = unpopulate(val, &r.Frequency) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, &r.Interval) + delete(rawMsg, key) + case "weekDays": + err = unpopulate(val, &r.WeekDays) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ResetPasswordBody - Body of a reset password request. +type ResetPasswordBody struct { + // REQUIRED; The password + Password *string `json:"password,omitempty"` + + // REQUIRED; The user whose password is being reset + Username *string `json:"username,omitempty"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// RosterProfile - The lab user list management profile. +type RosterProfile struct { + // The AAD group ID which this lab roster is populated from. Having this set enables AAD sync mode. + ActiveDirectoryGroupID *string `json:"activeDirectoryGroupId,omitempty"` + + // The base URI identifying the lms instance. + LmsInstance *string `json:"lmsInstance,omitempty"` + + // The unique id of the azure lab services tool in the lms. + LtiClientID *string `json:"ltiClientId,omitempty"` + + // The unique context identifier for the lab in the lms. + LtiContextID *string `json:"ltiContextId,omitempty"` + + // The uri of the names and roles service endpoint on the lms for the class attached to this lab. + LtiRosterEndpoint *string `json:"ltiRosterEndpoint,omitempty"` +} + +// SKU - The resource model definition representing SKU +type SKU struct { + // REQUIRED; The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string `json:"name,omitempty"` + + // If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. + Capacity *int32 `json:"capacity,omitempty"` + + // If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + + // The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string `json:"size,omitempty"` + + // This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. + Tier *SKUTier `json:"tier,omitempty"` +} + +// SKUsListOptions contains the optional parameters for the SKUs.List method. +type SKUsListOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// SaveImageBody - Body for the save image POST +type SaveImageBody struct { + // The ID of the lab virtual machine you want to save an image from. + LabVirtualMachineID *string `json:"labVirtualMachineId,omitempty"` + + // The name for the image we create. + Name *string `json:"name,omitempty"` +} + +// Schedule for automatically turning virtual machines in a lab on and off at specified times. +type Schedule struct { + ProxyResource + // REQUIRED; Schedule resource properties + Properties *ScheduleProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the schedule. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Schedule. +func (s Schedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + return json.Marshal(objectMap) +} + +// ScheduleProperties - Schedule resource properties +type ScheduleProperties struct { + ScheduleUpdateProperties + // READ-ONLY; Current provisioning state of the schedule. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleProperties. +func (s ScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.ScheduleUpdateProperties.marshalInternal(objectMap) + populate(objectMap, "provisioningState", s.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleProperties. +func (s *ScheduleProperties) 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 "provisioningState": + err = unpopulate(val, &s.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.ScheduleUpdateProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ScheduleUpdate - Schedule for automatically turning virtual machines in a lab on and off at specified times. Used for updates. +type ScheduleUpdate struct { + // Schedule resource properties + Properties *ScheduleUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleUpdate. +func (s ScheduleUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// ScheduleUpdateProperties - Schedule resource properties used for updates. +type ScheduleUpdateProperties struct { + // Notes for this schedule. + Notes *string `json:"notes,omitempty"` + + // The recurrence pattern of the scheduled actions. + RecurrencePattern *RecurrencePattern `json:"recurrencePattern,omitempty"` + + // When lab user virtual machines will be started. Timestamp offsets will be ignored and timeZoneId is used instead. + StartAt *time.Time `json:"startAt,omitempty"` + + // When lab user virtual machines will be stopped. Timestamp offsets will be ignored and timeZoneId is used instead. + StopAt *time.Time `json:"stopAt,omitempty"` + + // The IANA timezone id for the schedule. + TimeZoneID *string `json:"timeZoneId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleUpdateProperties. +func (s ScheduleUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleUpdateProperties. +func (s *ScheduleUpdateProperties) 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 ScheduleUpdateProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "notes", s.Notes) + populate(objectMap, "recurrencePattern", s.RecurrencePattern) + populateTimeRFC3339(objectMap, "startAt", s.StartAt) + populateTimeRFC3339(objectMap, "stopAt", s.StopAt) + populate(objectMap, "timeZoneId", s.TimeZoneID) +} + +func (s *ScheduleUpdateProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "notes": + err = unpopulate(val, &s.Notes) + delete(rawMsg, key) + case "recurrencePattern": + err = unpopulate(val, &s.RecurrencePattern) + delete(rawMsg, key) + case "startAt": + err = unpopulateTimeRFC3339(val, &s.StartAt) + delete(rawMsg, key) + case "stopAt": + err = unpopulateTimeRFC3339(val, &s.StopAt) + delete(rawMsg, key) + case "timeZoneId": + err = unpopulate(val, &s.TimeZoneID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SchedulesBeginDeleteOptions contains the optional parameters for the Schedules.BeginDelete method. +type SchedulesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// SchedulesCreateOrUpdateOptions contains the optional parameters for the Schedules.CreateOrUpdate method. +type SchedulesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SchedulesGetOptions contains the optional parameters for the Schedules.Get method. +type SchedulesGetOptions struct { + // placeholder for future optional parameters +} + +// SchedulesListByLabOptions contains the optional parameters for the Schedules.ListByLab method. +type SchedulesListByLabOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// SchedulesUpdateOptions contains the optional parameters for the Schedules.Update method. +type SchedulesUpdateOptions struct { + // placeholder for future optional parameters +} + +// SecurityProfile - The lab security profile. +type SecurityProfile struct { + // Whether any user or only specified users can register to a lab. + OpenAccess *EnableState `json:"openAccess,omitempty"` + + // READ-ONLY; The registration code for the lab. + RegistrationCode *string `json:"registrationCode,omitempty" azure:"ro"` +} + +// SupportInfo - Support contact information and instructions. +type SupportInfo struct { + // Support contact email address. + Email *string `json:"email,omitempty"` + + // Support instructions. + Instructions *string `json:"instructions,omitempty"` + + // Support contact phone number. + Phone *string `json:"phone,omitempty"` + + // Support web address. + URL *string `json:"url,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +// TrackedResourceUpdate - Base tracked resource type for all PATCH updates. +type TrackedResourceUpdate struct { + // Resource tags. + Tags []*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResourceUpdate. +func (t TrackedResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResourceUpdate) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "tags", t.Tags) +} + +// Usage - The core usage details. +type Usage struct { + // The current usage. + CurrentValue *int64 `json:"currentValue,omitempty"` + + // The fully qualified arm resource id. + ID *string `json:"id,omitempty"` + + // The limit integer. + Limit *int64 `json:"limit,omitempty"` + + // The name. + Name *UsageName `json:"name,omitempty"` + + // The unit details. + Unit *UsageUnit `json:"unit,omitempty"` +} + +// UsageName - The Usage Names. +type UsageName struct { + // The localized name of the resource. + LocalizedValue *string `json:"localizedValue,omitempty"` + + // The name of the resource. + Value *string `json:"value,omitempty"` +} + +// UsagesListByLocationOptions contains the optional parameters for the Usages.ListByLocation method. +type UsagesListByLocationOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// User of a lab that can register for and use virtual machines within the lab. +type User struct { + ProxyResource + // REQUIRED; User resource properties + Properties *UserProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the user resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type User. +func (u User) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", u.Properties) + populate(objectMap, "systemData", u.SystemData) + return json.Marshal(objectMap) +} + +// UserProperties - User resource properties +type UserProperties struct { + UserUpdateProperties + // REQUIRED; Email address of the user. + Email *string `json:"email,omitempty"` + + // READ-ONLY; Display name of the user, for example user's full name. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Date and time when the invitation message was sent to the user. + InvitationSent *time.Time `json:"invitationSent,omitempty" azure:"ro"` + + // READ-ONLY; State of the invitation message for the user. + InvitationState *InvitationState `json:"invitationState,omitempty" azure:"ro"` + + // READ-ONLY; Current provisioning state of the user resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; State of the user's registration within the lab. + RegistrationState *RegistrationState `json:"registrationState,omitempty" azure:"ro"` + + // READ-ONLY; How long the user has used their virtual machines in this lab. + TotalUsage *string `json:"totalUsage,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserProperties. +func (u UserProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.UserUpdateProperties.marshalInternal(objectMap) + populate(objectMap, "displayName", u.DisplayName) + populate(objectMap, "email", u.Email) + populateTimeRFC3339(objectMap, "invitationSent", u.InvitationSent) + populate(objectMap, "invitationState", u.InvitationState) + populate(objectMap, "provisioningState", u.ProvisioningState) + populate(objectMap, "registrationState", u.RegistrationState) + populate(objectMap, "totalUsage", u.TotalUsage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserProperties. +func (u *UserProperties) 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 "displayName": + err = unpopulate(val, &u.DisplayName) + delete(rawMsg, key) + case "email": + err = unpopulate(val, &u.Email) + delete(rawMsg, key) + case "invitationSent": + err = unpopulateTimeRFC3339(val, &u.InvitationSent) + delete(rawMsg, key) + case "invitationState": + err = unpopulate(val, &u.InvitationState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &u.ProvisioningState) + delete(rawMsg, key) + case "registrationState": + err = unpopulate(val, &u.RegistrationState) + delete(rawMsg, key) + case "totalUsage": + err = unpopulate(val, &u.TotalUsage) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := u.UserUpdateProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// UserUpdate - User of a lab that can register for and use virtual machines within the lab. Used for updates. +type UserUpdate struct { + // User resource properties + Properties *UserUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserUpdate. +func (u UserUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", u.Properties) + return json.Marshal(objectMap) +} + +// UserUpdateProperties - User resource properties used for updates. +type UserUpdateProperties struct { + // The amount of usage quota time the user gets in addition to the lab usage quota. + AdditionalUsageQuota *string `json:"additionalUsageQuota,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserUpdateProperties. +func (u UserUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserUpdateProperties. +func (u *UserUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return u.unmarshalInternal(rawMsg) +} + +func (u UserUpdateProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "additionalUsageQuota", u.AdditionalUsageQuota) +} + +func (u *UserUpdateProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "additionalUsageQuota": + err = unpopulate(val, &u.AdditionalUsageQuota) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// UsersBeginCreateOrUpdateOptions contains the optional parameters for the Users.BeginCreateOrUpdate method. +type UsersBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// UsersBeginDeleteOptions contains the optional parameters for the Users.BeginDelete method. +type UsersBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// UsersBeginInviteOptions contains the optional parameters for the Users.BeginInvite method. +type UsersBeginInviteOptions struct { + // placeholder for future optional parameters +} + +// UsersBeginUpdateOptions contains the optional parameters for the Users.BeginUpdate method. +type UsersBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// UsersGetOptions contains the optional parameters for the Users.Get method. +type UsersGetOptions struct { + // placeholder for future optional parameters +} + +// UsersListByLabOptions contains the optional parameters for the Users.ListByLab method. +type UsersListByLabOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// VirtualMachine - A lab virtual machine resource. +type VirtualMachine struct { + ProxyResource + // REQUIRED; Virtual machine resource properties + Properties *VirtualMachineProperties `json:"properties,omitempty"` + + // READ-ONLY; System data of the Lab virtual machine. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// 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) + populate(objectMap, "systemData", v.SystemData) + return json.Marshal(objectMap) +} + +// VirtualMachineAdditionalCapabilities - The additional capabilities for a lab VM. +type VirtualMachineAdditionalCapabilities struct { + // Flag to pre-install dedicated GPU drivers. + InstallGpuDrivers *EnableState `json:"installGpuDrivers,omitempty"` +} + +// VirtualMachineConnectionProfile - The connection information for the virtual machine +type VirtualMachineConnectionProfile struct { + // READ-ONLY; The username used to log on to the virtual machine as admin. + AdminUsername *string `json:"adminUsername,omitempty" azure:"ro"` + + // READ-ONLY; The username used to log on to the virtual machine as non-admin, if one exists. + NonAdminUsername *string `json:"nonAdminUsername,omitempty" azure:"ro"` + + // READ-ONLY; The private IP address of the virtual machine. + PrivateIPAddress *string `json:"privateIpAddress,omitempty" azure:"ro"` + + // READ-ONLY; Port and host name separated by semicolon for connecting via RDP protocol to the virtual machine. + RdpAuthority *string `json:"rdpAuthority,omitempty" azure:"ro"` + + // READ-ONLY; URL for connecting via RDP protocol to the virtual machine in browser. + RdpInBrowserURL *string `json:"rdpInBrowserUrl,omitempty" azure:"ro"` + + // READ-ONLY; Port and host name separated by semicolon for connecting via SSH protocol to the virtual machine. + SSHAuthority *string `json:"sshAuthority,omitempty" azure:"ro"` + + // READ-ONLY; URL for connecting via SSH protocol to the virtual machine in browser. + SSHInBrowserURL *string `json:"sshInBrowserUrl,omitempty" azure:"ro"` +} + +// VirtualMachineProfile - The base virtual machine configuration for a lab. +type VirtualMachineProfile struct { + // REQUIRED; Credentials for the admin user on the VM. + AdminUser *Credentials `json:"adminUser,omitempty"` + + // REQUIRED; Indicates what lab virtual machines are created from. + CreateOption *CreateOption `json:"createOption,omitempty"` + + // REQUIRED; The image configuration for lab virtual machines. + ImageReference *ImageReference `json:"imageReference,omitempty"` + + // REQUIRED; The SKU for the lab. Defines the type of virtual machines used in the lab. + SKU *SKU `json:"sku,omitempty"` + + // REQUIRED; The initial quota alloted to each lab user. Must be a time span between 0 and 9999 hours. + UsageQuota *string `json:"usageQuota,omitempty"` + + // Additional VM capabilities. + AdditionalCapabilities *VirtualMachineAdditionalCapabilities `json:"additionalCapabilities,omitempty"` + + // Credentials for the non-admin user on the VM, if one exists. + NonAdminUser *Credentials `json:"nonAdminUser,omitempty"` + + // Enabling this option will use the same password for all user VMs. + UseSharedPassword *EnableState `json:"useSharedPassword,omitempty"` + + // READ-ONLY; The OS type of the image + OSType *OsType `json:"osType,omitempty" azure:"ro"` +} + +// VirtualMachineProperties - Virtual machine resource properties +type VirtualMachineProperties struct { + // READ-ONLY; The lab user ID (not the PUID!) of who claimed the virtual machine. + ClaimedByUserID *string `json:"claimedByUserId,omitempty" azure:"ro"` + + // READ-ONLY; Profile for information about connecting to the virtual machine. + ConnectionProfile *VirtualMachineConnectionProfile `json:"connectionProfile,omitempty" azure:"ro"` + + // READ-ONLY; Current provisioning state of the virtual machine. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The current state of the virtual machine + State *VirtualMachineState `json:"state,omitempty" azure:"ro"` + + // READ-ONLY; The type of this VM resource + VMType *VirtualMachineType `json:"vmType,omitempty" azure:"ro"` +} + +// VirtualMachinesBeginRedeployOptions contains the optional parameters for the VirtualMachines.BeginRedeploy method. +type VirtualMachinesBeginRedeployOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesBeginReimageOptions contains the optional parameters for the VirtualMachines.BeginReimage method. +type VirtualMachinesBeginReimageOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesBeginResetPasswordOptions contains the optional parameters for the VirtualMachines.BeginResetPassword method. +type VirtualMachinesBeginResetPasswordOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesBeginStartOptions contains the optional parameters for the VirtualMachines.BeginStart method. +type VirtualMachinesBeginStartOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesBeginStopOptions contains the optional parameters for the VirtualMachines.BeginStop method. +type VirtualMachinesBeginStopOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesGetOptions contains the optional parameters for the VirtualMachines.Get method. +type VirtualMachinesGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesListByLabOptions contains the optional parameters for the VirtualMachines.ListByLab method. +type VirtualMachinesListByLabOptions struct { + // The filter to apply to the operation. + Filter *string +} + +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/labservices/armlabservices/zz_generated_operationresults_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_operationresults_client.go new file mode 100644 index 000000000000..c051ee0ffa8d --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_operationresults_client.go @@ -0,0 +1,104 @@ +//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 armlabservices + +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" +) + +// OperationResultsClient contains the methods for the OperationResults group. +// Don't use this type directly, use NewOperationResultsClient() instead. +type OperationResultsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewOperationResultsClient creates a new instance of OperationResultsClient with the specified values. +func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *OperationResultsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationResultsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Returns an azure operation result. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationResultsClient) Get(ctx context.Context, operationResultID string, options *OperationResultsGetOptions) (OperationResultsGetResponse, error) { + req, err := client.getCreateRequest(ctx, operationResultID, options) + if err != nil { + return OperationResultsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationResultsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return OperationResultsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OperationResultsClient) getCreateRequest(ctx context.Context, operationResultID string, options *OperationResultsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/operationResults/{operationResultId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if operationResultID == "" { + return nil, errors.New("parameter operationResultID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationResultId}", url.PathEscape(operationResultID)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationResultsClient) getHandleResponse(resp *http.Response) (OperationResultsGetResponse, error) { + result := OperationResultsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationResult); err != nil { + return OperationResultsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OperationResultsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_operations_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_operations_client.go new file mode 100644 index 000000000000..ad07240203fd --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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 armlabservices + +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 - Returns a list of all operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.LabServices/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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, 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 := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_pagers.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_pagers.go new file mode 100644 index 000000000000..c61b5ad50f95 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_pagers.go @@ -0,0 +1,611 @@ +//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 armlabservices + +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" +) + +// ImagesListByLabPlanPager provides operations for iterating over paged responses. +type ImagesListByLabPlanPager struct { + client *ImagesClient + current ImagesListByLabPlanResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ImagesListByLabPlanResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ImagesListByLabPlanPager) 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 *ImagesListByLabPlanPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedImages.NextLink == nil || len(*p.current.PagedImages.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.listByLabPlanHandleError(resp) + return false + } + result, err := p.client.listByLabPlanHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ImagesListByLabPlanResponse page. +func (p *ImagesListByLabPlanPager) PageResponse() ImagesListByLabPlanResponse { + return p.current +} + +// LabPlansListByResourceGroupPager provides operations for iterating over paged responses. +type LabPlansListByResourceGroupPager struct { + client *LabPlansClient + current LabPlansListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LabPlansListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LabPlansListByResourceGroupPager) 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 *LabPlansListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedLabPlans.NextLink == nil || len(*p.current.PagedLabPlans.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LabPlansListByResourceGroupResponse page. +func (p *LabPlansListByResourceGroupPager) PageResponse() LabPlansListByResourceGroupResponse { + return p.current +} + +// LabPlansListBySubscriptionPager provides operations for iterating over paged responses. +type LabPlansListBySubscriptionPager struct { + client *LabPlansClient + current LabPlansListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LabPlansListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LabPlansListBySubscriptionPager) 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 *LabPlansListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedLabPlans.NextLink == nil || len(*p.current.PagedLabPlans.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LabPlansListBySubscriptionResponse page. +func (p *LabPlansListBySubscriptionPager) PageResponse() LabPlansListBySubscriptionResponse { + return p.current +} + +// LabsListByResourceGroupPager provides operations for iterating over paged responses. +type LabsListByResourceGroupPager struct { + client *LabsClient + current LabsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LabsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LabsListByResourceGroupPager) 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 *LabsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedLabs.NextLink == nil || len(*p.current.PagedLabs.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LabsListByResourceGroupResponse page. +func (p *LabsListByResourceGroupPager) PageResponse() LabsListByResourceGroupResponse { + return p.current +} + +// LabsListBySubscriptionPager provides operations for iterating over paged responses. +type LabsListBySubscriptionPager struct { + client *LabsClient + current LabsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LabsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LabsListBySubscriptionPager) 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 *LabsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedLabs.NextLink == nil || len(*p.current.PagedLabs.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LabsListBySubscriptionResponse page. +func (p *LabsListBySubscriptionPager) PageResponse() LabsListBySubscriptionResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// SKUsListPager provides operations for iterating over paged responses. +type SKUsListPager struct { + client *SKUsClient + current SKUsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, SKUsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *SKUsListPager) 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 *SKUsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedLabServicesSKUs.NextLink == nil || len(*p.current.PagedLabServicesSKUs.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 SKUsListResponse page. +func (p *SKUsListPager) PageResponse() SKUsListResponse { + return p.current +} + +// SchedulesListByLabPager provides operations for iterating over paged responses. +type SchedulesListByLabPager struct { + client *SchedulesClient + current SchedulesListByLabResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, SchedulesListByLabResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *SchedulesListByLabPager) 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 *SchedulesListByLabPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedSchedules.NextLink == nil || len(*p.current.PagedSchedules.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.listByLabHandleError(resp) + return false + } + result, err := p.client.listByLabHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current SchedulesListByLabResponse page. +func (p *SchedulesListByLabPager) PageResponse() SchedulesListByLabResponse { + return p.current +} + +// UsagesListByLocationPager provides operations for iterating over paged responses. +type UsagesListByLocationPager struct { + client *UsagesClient + current UsagesListByLocationResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, UsagesListByLocationResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *UsagesListByLocationPager) 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 *UsagesListByLocationPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ListUsagesResult.NextLink == nil || len(*p.current.ListUsagesResult.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.listByLocationHandleError(resp) + return false + } + result, err := p.client.listByLocationHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current UsagesListByLocationResponse page. +func (p *UsagesListByLocationPager) PageResponse() UsagesListByLocationResponse { + return p.current +} + +// UsersListByLabPager provides operations for iterating over paged responses. +type UsersListByLabPager struct { + client *UsersClient + current UsersListByLabResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, UsersListByLabResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *UsersListByLabPager) 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 *UsersListByLabPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedUsers.NextLink == nil || len(*p.current.PagedUsers.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.listByLabHandleError(resp) + return false + } + result, err := p.client.listByLabHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current UsersListByLabResponse page. +func (p *UsersListByLabPager) PageResponse() UsersListByLabResponse { + return p.current +} + +// VirtualMachinesListByLabPager provides operations for iterating over paged responses. +type VirtualMachinesListByLabPager struct { + client *VirtualMachinesClient + current VirtualMachinesListByLabResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, VirtualMachinesListByLabResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *VirtualMachinesListByLabPager) 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 *VirtualMachinesListByLabPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PagedVirtualMachines.NextLink == nil || len(*p.current.PagedVirtualMachines.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.listByLabHandleError(resp) + return false + } + result, err := p.client.listByLabHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current VirtualMachinesListByLabResponse page. +func (p *VirtualMachinesListByLabPager) PageResponse() VirtualMachinesListByLabResponse { + return p.current +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_pollers.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_pollers.go new file mode 100644 index 000000000000..a54c35889c6b --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_pollers.go @@ -0,0 +1,832 @@ +//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 armlabservices + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// LabPlansCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LabPlansCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabPlansCreateOrUpdatePoller) 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 *LabPlansCreateOrUpdatePoller) 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 LabPlansCreateOrUpdateResponse will be returned. +func (p *LabPlansCreateOrUpdatePoller) FinalResponse(ctx context.Context) (LabPlansCreateOrUpdateResponse, error) { + respType := LabPlansCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.LabPlan) + if err != nil { + return LabPlansCreateOrUpdateResponse{}, 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 *LabPlansCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabPlansDeletePoller provides polling facilities until the operation reaches a terminal state. +type LabPlansDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabPlansDeletePoller) 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 *LabPlansDeletePoller) 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 LabPlansDeleteResponse will be returned. +func (p *LabPlansDeletePoller) FinalResponse(ctx context.Context) (LabPlansDeleteResponse, error) { + respType := LabPlansDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LabPlansDeleteResponse{}, 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 *LabPlansDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabPlansSaveImagePoller provides polling facilities until the operation reaches a terminal state. +type LabPlansSaveImagePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabPlansSaveImagePoller) 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 *LabPlansSaveImagePoller) 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 LabPlansSaveImageResponse will be returned. +func (p *LabPlansSaveImagePoller) FinalResponse(ctx context.Context) (LabPlansSaveImageResponse, error) { + respType := LabPlansSaveImageResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LabPlansSaveImageResponse{}, 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 *LabPlansSaveImagePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabPlansUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LabPlansUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabPlansUpdatePoller) 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 *LabPlansUpdatePoller) 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 LabPlansUpdateResponse will be returned. +func (p *LabPlansUpdatePoller) FinalResponse(ctx context.Context) (LabPlansUpdateResponse, error) { + respType := LabPlansUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.LabPlan) + if err != nil { + return LabPlansUpdateResponse{}, 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 *LabPlansUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LabsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabsCreateOrUpdatePoller) 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 *LabsCreateOrUpdatePoller) 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 LabsCreateOrUpdateResponse will be returned. +func (p *LabsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (LabsCreateOrUpdateResponse, error) { + respType := LabsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Lab) + if err != nil { + return LabsCreateOrUpdateResponse{}, 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 *LabsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabsDeletePoller provides polling facilities until the operation reaches a terminal state. +type LabsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabsDeletePoller) 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 *LabsDeletePoller) 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 LabsDeleteResponse will be returned. +func (p *LabsDeletePoller) FinalResponse(ctx context.Context) (LabsDeleteResponse, error) { + respType := LabsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LabsDeleteResponse{}, 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 *LabsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabsPublishPoller provides polling facilities until the operation reaches a terminal state. +type LabsPublishPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabsPublishPoller) 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 *LabsPublishPoller) 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 LabsPublishResponse will be returned. +func (p *LabsPublishPoller) FinalResponse(ctx context.Context) (LabsPublishResponse, error) { + respType := LabsPublishResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LabsPublishResponse{}, 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 *LabsPublishPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabsSyncGroupPoller provides polling facilities until the operation reaches a terminal state. +type LabsSyncGroupPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabsSyncGroupPoller) 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 *LabsSyncGroupPoller) 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 LabsSyncGroupResponse will be returned. +func (p *LabsSyncGroupPoller) FinalResponse(ctx context.Context) (LabsSyncGroupResponse, error) { + respType := LabsSyncGroupResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LabsSyncGroupResponse{}, 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 *LabsSyncGroupPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LabsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LabsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LabsUpdatePoller) 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 *LabsUpdatePoller) 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 LabsUpdateResponse will be returned. +func (p *LabsUpdatePoller) FinalResponse(ctx context.Context) (LabsUpdateResponse, error) { + respType := LabsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Lab) + if err != nil { + return LabsUpdateResponse{}, 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 *LabsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// SchedulesDeletePoller provides polling facilities until the operation reaches a terminal state. +type SchedulesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *SchedulesDeletePoller) 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 *SchedulesDeletePoller) 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 SchedulesDeleteResponse will be returned. +func (p *SchedulesDeletePoller) FinalResponse(ctx context.Context) (SchedulesDeleteResponse, error) { + respType := SchedulesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return SchedulesDeleteResponse{}, 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 *SchedulesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// UsersCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type UsersCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *UsersCreateOrUpdatePoller) 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 *UsersCreateOrUpdatePoller) 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 UsersCreateOrUpdateResponse will be returned. +func (p *UsersCreateOrUpdatePoller) FinalResponse(ctx context.Context) (UsersCreateOrUpdateResponse, error) { + respType := UsersCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.User) + if err != nil { + return UsersCreateOrUpdateResponse{}, 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 *UsersCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// UsersDeletePoller provides polling facilities until the operation reaches a terminal state. +type UsersDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *UsersDeletePoller) 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 *UsersDeletePoller) 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 UsersDeleteResponse will be returned. +func (p *UsersDeletePoller) FinalResponse(ctx context.Context) (UsersDeleteResponse, error) { + respType := UsersDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return UsersDeleteResponse{}, 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 *UsersDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// UsersInvitePoller provides polling facilities until the operation reaches a terminal state. +type UsersInvitePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *UsersInvitePoller) 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 *UsersInvitePoller) 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 UsersInviteResponse will be returned. +func (p *UsersInvitePoller) FinalResponse(ctx context.Context) (UsersInviteResponse, error) { + respType := UsersInviteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return UsersInviteResponse{}, 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 *UsersInvitePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// UsersUpdatePoller provides polling facilities until the operation reaches a terminal state. +type UsersUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *UsersUpdatePoller) 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 *UsersUpdatePoller) 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 UsersUpdateResponse will be returned. +func (p *UsersUpdatePoller) FinalResponse(ctx context.Context) (UsersUpdateResponse, error) { + respType := UsersUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.User) + if err != nil { + return UsersUpdateResponse{}, 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 *UsersUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VirtualMachinesRedeployPoller provides polling facilities until the operation reaches a terminal state. +type VirtualMachinesRedeployPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VirtualMachinesRedeployPoller) 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 *VirtualMachinesRedeployPoller) 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 VirtualMachinesRedeployResponse will be returned. +func (p *VirtualMachinesRedeployPoller) FinalResponse(ctx context.Context) (VirtualMachinesRedeployResponse, error) { + respType := VirtualMachinesRedeployResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VirtualMachinesRedeployResponse{}, 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 *VirtualMachinesRedeployPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VirtualMachinesReimagePoller provides polling facilities until the operation reaches a terminal state. +type VirtualMachinesReimagePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VirtualMachinesReimagePoller) 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 *VirtualMachinesReimagePoller) 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 VirtualMachinesReimageResponse will be returned. +func (p *VirtualMachinesReimagePoller) FinalResponse(ctx context.Context) (VirtualMachinesReimageResponse, error) { + respType := VirtualMachinesReimageResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VirtualMachinesReimageResponse{}, 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 *VirtualMachinesReimagePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VirtualMachinesResetPasswordPoller provides polling facilities until the operation reaches a terminal state. +type VirtualMachinesResetPasswordPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VirtualMachinesResetPasswordPoller) 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 *VirtualMachinesResetPasswordPoller) 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 VirtualMachinesResetPasswordResponse will be returned. +func (p *VirtualMachinesResetPasswordPoller) FinalResponse(ctx context.Context) (VirtualMachinesResetPasswordResponse, error) { + respType := VirtualMachinesResetPasswordResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VirtualMachinesResetPasswordResponse{}, 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 *VirtualMachinesResetPasswordPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VirtualMachinesStartPoller provides polling facilities until the operation reaches a terminal state. +type VirtualMachinesStartPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VirtualMachinesStartPoller) 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 *VirtualMachinesStartPoller) 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 VirtualMachinesStartResponse will be returned. +func (p *VirtualMachinesStartPoller) FinalResponse(ctx context.Context) (VirtualMachinesStartResponse, error) { + respType := VirtualMachinesStartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VirtualMachinesStartResponse{}, 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 *VirtualMachinesStartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VirtualMachinesStopPoller provides polling facilities until the operation reaches a terminal state. +type VirtualMachinesStopPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VirtualMachinesStopPoller) 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 *VirtualMachinesStopPoller) 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 VirtualMachinesStopResponse will be returned. +func (p *VirtualMachinesStopPoller) FinalResponse(ctx context.Context) (VirtualMachinesStopResponse, error) { + respType := VirtualMachinesStopResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return VirtualMachinesStopResponse{}, 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 *VirtualMachinesStopPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_response_types.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_response_types.go new file mode 100644 index 000000000000..df9ebaacf8c3 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_response_types.go @@ -0,0 +1,1190 @@ +//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 armlabservices + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// ImagesCreateOrUpdateResponse contains the response from method Images.CreateOrUpdate. +type ImagesCreateOrUpdateResponse struct { + ImagesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImagesCreateOrUpdateResult contains the result from method Images.CreateOrUpdate. +type ImagesCreateOrUpdateResult struct { + Image +} + +// ImagesGetResponse contains the response from method Images.Get. +type ImagesGetResponse struct { + ImagesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImagesGetResult contains the result from method Images.Get. +type ImagesGetResult struct { + Image +} + +// ImagesListByLabPlanResponse contains the response from method Images.ListByLabPlan. +type ImagesListByLabPlanResponse struct { + ImagesListByLabPlanResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImagesListByLabPlanResult contains the result from method Images.ListByLabPlan. +type ImagesListByLabPlanResult struct { + PagedImages +} + +// ImagesUpdateResponse contains the response from method Images.Update. +type ImagesUpdateResponse struct { + ImagesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImagesUpdateResult contains the result from method Images.Update. +type ImagesUpdateResult struct { + Image +} + +// LabPlansCreateOrUpdatePollerResponse contains the response from method LabPlans.CreateOrUpdate. +type LabPlansCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabPlansCreateOrUpdatePoller + + // 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 LabPlansCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabPlansCreateOrUpdateResponse, error) { + respType := LabPlansCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.LabPlan) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabPlansCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *LabPlansCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *LabPlansClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabPlansClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &LabPlansCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabPlansCreateOrUpdateResponse contains the response from method LabPlans.CreateOrUpdate. +type LabPlansCreateOrUpdateResponse struct { + LabPlansCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansCreateOrUpdateResult contains the result from method LabPlans.CreateOrUpdate. +type LabPlansCreateOrUpdateResult struct { + LabPlan +} + +// LabPlansDeletePollerResponse contains the response from method LabPlans.Delete. +type LabPlansDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabPlansDeletePoller + + // 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 LabPlansDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabPlansDeleteResponse, error) { + respType := LabPlansDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabPlansDeletePollerResponse from the provided client and resume token. +func (l *LabPlansDeletePollerResponse) Resume(ctx context.Context, client *LabPlansClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabPlansClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &LabPlansDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabPlansDeleteResponse contains the response from method LabPlans.Delete. +type LabPlansDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansGetResponse contains the response from method LabPlans.Get. +type LabPlansGetResponse struct { + LabPlansGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansGetResult contains the result from method LabPlans.Get. +type LabPlansGetResult struct { + LabPlan +} + +// LabPlansListByResourceGroupResponse contains the response from method LabPlans.ListByResourceGroup. +type LabPlansListByResourceGroupResponse struct { + LabPlansListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansListByResourceGroupResult contains the result from method LabPlans.ListByResourceGroup. +type LabPlansListByResourceGroupResult struct { + PagedLabPlans +} + +// LabPlansListBySubscriptionResponse contains the response from method LabPlans.ListBySubscription. +type LabPlansListBySubscriptionResponse struct { + LabPlansListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansListBySubscriptionResult contains the result from method LabPlans.ListBySubscription. +type LabPlansListBySubscriptionResult struct { + PagedLabPlans +} + +// LabPlansSaveImagePollerResponse contains the response from method LabPlans.SaveImage. +type LabPlansSaveImagePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabPlansSaveImagePoller + + // 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 LabPlansSaveImagePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabPlansSaveImageResponse, error) { + respType := LabPlansSaveImageResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabPlansSaveImagePollerResponse from the provided client and resume token. +func (l *LabPlansSaveImagePollerResponse) Resume(ctx context.Context, client *LabPlansClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabPlansClient.SaveImage", token, client.pl, client.saveImageHandleError) + if err != nil { + return err + } + poller := &LabPlansSaveImagePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabPlansSaveImageResponse contains the response from method LabPlans.SaveImage. +type LabPlansSaveImageResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansUpdatePollerResponse contains the response from method LabPlans.Update. +type LabPlansUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabPlansUpdatePoller + + // 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 LabPlansUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabPlansUpdateResponse, error) { + respType := LabPlansUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.LabPlan) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabPlansUpdatePollerResponse from the provided client and resume token. +func (l *LabPlansUpdatePollerResponse) Resume(ctx context.Context, client *LabPlansClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabPlansClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &LabPlansUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabPlansUpdateResponse contains the response from method LabPlans.Update. +type LabPlansUpdateResponse struct { + LabPlansUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabPlansUpdateResult contains the result from method LabPlans.Update. +type LabPlansUpdateResult struct { + LabPlan +} + +// LabsCreateOrUpdatePollerResponse contains the response from method Labs.CreateOrUpdate. +type LabsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabsCreateOrUpdatePoller + + // 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 LabsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabsCreateOrUpdateResponse, error) { + respType := LabsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Lab) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *LabsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *LabsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &LabsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabsCreateOrUpdateResponse contains the response from method Labs.CreateOrUpdate. +type LabsCreateOrUpdateResponse struct { + LabsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsCreateOrUpdateResult contains the result from method Labs.CreateOrUpdate. +type LabsCreateOrUpdateResult struct { + Lab +} + +// LabsDeletePollerResponse contains the response from method Labs.Delete. +type LabsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabsDeletePoller + + // 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 LabsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabsDeleteResponse, error) { + respType := LabsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabsDeletePollerResponse from the provided client and resume token. +func (l *LabsDeletePollerResponse) Resume(ctx context.Context, client *LabsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &LabsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabsDeleteResponse contains the response from method Labs.Delete. +type LabsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsGetResponse contains the response from method Labs.Get. +type LabsGetResponse struct { + LabsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsGetResult contains the result from method Labs.Get. +type LabsGetResult struct { + Lab +} + +// LabsListByResourceGroupResponse contains the response from method Labs.ListByResourceGroup. +type LabsListByResourceGroupResponse struct { + LabsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsListByResourceGroupResult contains the result from method Labs.ListByResourceGroup. +type LabsListByResourceGroupResult struct { + PagedLabs +} + +// LabsListBySubscriptionResponse contains the response from method Labs.ListBySubscription. +type LabsListBySubscriptionResponse struct { + LabsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsListBySubscriptionResult contains the result from method Labs.ListBySubscription. +type LabsListBySubscriptionResult struct { + PagedLabs +} + +// LabsPublishPollerResponse contains the response from method Labs.Publish. +type LabsPublishPollerResponse struct { + // Poller contains an initialized poller. + Poller *LabsPublishPoller + + // 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 LabsPublishPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabsPublishResponse, error) { + respType := LabsPublishResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabsPublishPollerResponse from the provided client and resume token. +func (l *LabsPublishPollerResponse) Resume(ctx context.Context, client *LabsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabsClient.Publish", token, client.pl, client.publishHandleError) + if err != nil { + return err + } + poller := &LabsPublishPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabsPublishResponse contains the response from method Labs.Publish. +type LabsPublishResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsSyncGroupPollerResponse contains the response from method Labs.SyncGroup. +type LabsSyncGroupPollerResponse struct { + // Poller contains an initialized poller. + Poller *LabsSyncGroupPoller + + // 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 LabsSyncGroupPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabsSyncGroupResponse, error) { + respType := LabsSyncGroupResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabsSyncGroupPollerResponse from the provided client and resume token. +func (l *LabsSyncGroupPollerResponse) Resume(ctx context.Context, client *LabsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabsClient.SyncGroup", token, client.pl, client.syncGroupHandleError) + if err != nil { + return err + } + poller := &LabsSyncGroupPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabsSyncGroupResponse contains the response from method Labs.SyncGroup. +type LabsSyncGroupResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsUpdatePollerResponse contains the response from method Labs.Update. +type LabsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LabsUpdatePoller + + // 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 LabsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LabsUpdateResponse, error) { + respType := LabsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Lab) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LabsUpdatePollerResponse from the provided client and resume token. +func (l *LabsUpdatePollerResponse) Resume(ctx context.Context, client *LabsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LabsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &LabsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LabsUpdateResponse contains the response from method Labs.Update. +type LabsUpdateResponse struct { + LabsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LabsUpdateResult contains the result from method Labs.Update. +type LabsUpdateResult struct { + Lab +} + +// OperationResultsGetResponse contains the response from method OperationResults.Get. +type OperationResultsGetResponse struct { + OperationResultsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationResultsGetResult contains the result from method OperationResults.Get. +type OperationResultsGetResult struct { + OperationResult +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// SKUsListResponse contains the response from method SKUs.List. +type SKUsListResponse struct { + SKUsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SKUsListResult contains the result from method SKUs.List. +type SKUsListResult struct { + PagedLabServicesSKUs +} + +// SchedulesCreateOrUpdateResponse contains the response from method Schedules.CreateOrUpdate. +type SchedulesCreateOrUpdateResponse struct { + SchedulesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SchedulesCreateOrUpdateResult contains the result from method Schedules.CreateOrUpdate. +type SchedulesCreateOrUpdateResult struct { + Schedule +} + +// SchedulesDeletePollerResponse contains the response from method Schedules.Delete. +type SchedulesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *SchedulesDeletePoller + + // 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 SchedulesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (SchedulesDeleteResponse, error) { + respType := SchedulesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a SchedulesDeletePollerResponse from the provided client and resume token. +func (l *SchedulesDeletePollerResponse) Resume(ctx context.Context, client *SchedulesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("SchedulesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &SchedulesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// SchedulesDeleteResponse contains the response from method Schedules.Delete. +type SchedulesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SchedulesGetResponse contains the response from method Schedules.Get. +type SchedulesGetResponse struct { + SchedulesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SchedulesGetResult contains the result from method Schedules.Get. +type SchedulesGetResult struct { + Schedule +} + +// SchedulesListByLabResponse contains the response from method Schedules.ListByLab. +type SchedulesListByLabResponse struct { + SchedulesListByLabResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SchedulesListByLabResult contains the result from method Schedules.ListByLab. +type SchedulesListByLabResult struct { + PagedSchedules +} + +// SchedulesUpdateResponse contains the response from method Schedules.Update. +type SchedulesUpdateResponse struct { + SchedulesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SchedulesUpdateResult contains the result from method Schedules.Update. +type SchedulesUpdateResult struct { + Schedule +} + +// UsagesListByLocationResponse contains the response from method Usages.ListByLocation. +type UsagesListByLocationResponse struct { + UsagesListByLocationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsagesListByLocationResult contains the result from method Usages.ListByLocation. +type UsagesListByLocationResult struct { + ListUsagesResult +} + +// UsersCreateOrUpdatePollerResponse contains the response from method Users.CreateOrUpdate. +type UsersCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *UsersCreateOrUpdatePoller + + // 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 UsersCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (UsersCreateOrUpdateResponse, error) { + respType := UsersCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.User) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a UsersCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *UsersCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *UsersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("UsersClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &UsersCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// UsersCreateOrUpdateResponse contains the response from method Users.CreateOrUpdate. +type UsersCreateOrUpdateResponse struct { + UsersCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsersCreateOrUpdateResult contains the result from method Users.CreateOrUpdate. +type UsersCreateOrUpdateResult struct { + User +} + +// UsersDeletePollerResponse contains the response from method Users.Delete. +type UsersDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *UsersDeletePoller + + // 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 UsersDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (UsersDeleteResponse, error) { + respType := UsersDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a UsersDeletePollerResponse from the provided client and resume token. +func (l *UsersDeletePollerResponse) Resume(ctx context.Context, client *UsersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("UsersClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &UsersDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// UsersDeleteResponse contains the response from method Users.Delete. +type UsersDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsersGetResponse contains the response from method Users.Get. +type UsersGetResponse struct { + UsersGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsersGetResult contains the result from method Users.Get. +type UsersGetResult struct { + User +} + +// UsersInvitePollerResponse contains the response from method Users.Invite. +type UsersInvitePollerResponse struct { + // Poller contains an initialized poller. + Poller *UsersInvitePoller + + // 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 UsersInvitePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (UsersInviteResponse, error) { + respType := UsersInviteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a UsersInvitePollerResponse from the provided client and resume token. +func (l *UsersInvitePollerResponse) Resume(ctx context.Context, client *UsersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("UsersClient.Invite", token, client.pl, client.inviteHandleError) + if err != nil { + return err + } + poller := &UsersInvitePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// UsersInviteResponse contains the response from method Users.Invite. +type UsersInviteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsersListByLabResponse contains the response from method Users.ListByLab. +type UsersListByLabResponse struct { + UsersListByLabResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsersListByLabResult contains the result from method Users.ListByLab. +type UsersListByLabResult struct { + PagedUsers +} + +// UsersUpdatePollerResponse contains the response from method Users.Update. +type UsersUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *UsersUpdatePoller + + // 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 UsersUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (UsersUpdateResponse, error) { + respType := UsersUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.User) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a UsersUpdatePollerResponse from the provided client and resume token. +func (l *UsersUpdatePollerResponse) Resume(ctx context.Context, client *UsersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("UsersClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &UsersUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// UsersUpdateResponse contains the response from method Users.Update. +type UsersUpdateResponse struct { + UsersUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsersUpdateResult contains the result from method Users.Update. +type UsersUpdateResult struct { + User +} + +// 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 +} + +// VirtualMachinesListByLabResponse contains the response from method VirtualMachines.ListByLab. +type VirtualMachinesListByLabResponse struct { + VirtualMachinesListByLabResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesListByLabResult contains the result from method VirtualMachines.ListByLab. +type VirtualMachinesListByLabResult struct { + PagedVirtualMachines +} + +// VirtualMachinesRedeployPollerResponse contains the response from method VirtualMachines.Redeploy. +type VirtualMachinesRedeployPollerResponse struct { + // Poller contains an initialized poller. + Poller *VirtualMachinesRedeployPoller + + // 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 VirtualMachinesRedeployPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VirtualMachinesRedeployResponse, error) { + respType := VirtualMachinesRedeployResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VirtualMachinesRedeployPollerResponse from the provided client and resume token. +func (l *VirtualMachinesRedeployPollerResponse) Resume(ctx context.Context, client *VirtualMachinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VirtualMachinesClient.Redeploy", token, client.pl, client.redeployHandleError) + if err != nil { + return err + } + poller := &VirtualMachinesRedeployPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VirtualMachinesRedeployResponse contains the response from method VirtualMachines.Redeploy. +type VirtualMachinesRedeployResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesReimagePollerResponse contains the response from method VirtualMachines.Reimage. +type VirtualMachinesReimagePollerResponse struct { + // Poller contains an initialized poller. + Poller *VirtualMachinesReimagePoller + + // 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 VirtualMachinesReimagePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VirtualMachinesReimageResponse, error) { + respType := VirtualMachinesReimageResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VirtualMachinesReimagePollerResponse from the provided client and resume token. +func (l *VirtualMachinesReimagePollerResponse) Resume(ctx context.Context, client *VirtualMachinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VirtualMachinesClient.Reimage", token, client.pl, client.reimageHandleError) + if err != nil { + return err + } + poller := &VirtualMachinesReimagePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VirtualMachinesReimageResponse contains the response from method VirtualMachines.Reimage. +type VirtualMachinesReimageResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesResetPasswordPollerResponse contains the response from method VirtualMachines.ResetPassword. +type VirtualMachinesResetPasswordPollerResponse struct { + // Poller contains an initialized poller. + Poller *VirtualMachinesResetPasswordPoller + + // 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 VirtualMachinesResetPasswordPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VirtualMachinesResetPasswordResponse, error) { + respType := VirtualMachinesResetPasswordResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VirtualMachinesResetPasswordPollerResponse from the provided client and resume token. +func (l *VirtualMachinesResetPasswordPollerResponse) Resume(ctx context.Context, client *VirtualMachinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VirtualMachinesClient.ResetPassword", token, client.pl, client.resetPasswordHandleError) + if err != nil { + return err + } + poller := &VirtualMachinesResetPasswordPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VirtualMachinesResetPasswordResponse contains the response from method VirtualMachines.ResetPassword. +type VirtualMachinesResetPasswordResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesStartPollerResponse contains the response from method VirtualMachines.Start. +type VirtualMachinesStartPollerResponse struct { + // Poller contains an initialized poller. + Poller *VirtualMachinesStartPoller + + // 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 VirtualMachinesStartPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VirtualMachinesStartResponse, error) { + respType := VirtualMachinesStartResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VirtualMachinesStartPollerResponse from the provided client and resume token. +func (l *VirtualMachinesStartPollerResponse) Resume(ctx context.Context, client *VirtualMachinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VirtualMachinesClient.Start", token, client.pl, client.startHandleError) + if err != nil { + return err + } + poller := &VirtualMachinesStartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VirtualMachinesStartResponse contains the response from method VirtualMachines.Start. +type VirtualMachinesStartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VirtualMachinesStopPollerResponse contains the response from method VirtualMachines.Stop. +type VirtualMachinesStopPollerResponse struct { + // Poller contains an initialized poller. + Poller *VirtualMachinesStopPoller + + // 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 VirtualMachinesStopPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VirtualMachinesStopResponse, error) { + respType := VirtualMachinesStopResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VirtualMachinesStopPollerResponse from the provided client and resume token. +func (l *VirtualMachinesStopPollerResponse) Resume(ctx context.Context, client *VirtualMachinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VirtualMachinesClient.Stop", token, client.pl, client.stopHandleError) + if err != nil { + return err + } + poller := &VirtualMachinesStopPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VirtualMachinesStopResponse contains the response from method VirtualMachines.Stop. +type VirtualMachinesStopResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_schedules_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_schedules_client.go new file mode 100644 index 000000000000..4717c6dc427b --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_schedules_client.go @@ -0,0 +1,395 @@ +//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 armlabservices + +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" +) + +// SchedulesClient contains the methods for the Schedules group. +// Don't use this type directly, use NewSchedulesClient() instead. +type SchedulesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewSchedulesClient creates a new instance of SchedulesClient with the specified values. +func NewSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *SchedulesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &SchedulesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Operation to create or update a lab schedule. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body Schedule, options *SchedulesCreateOrUpdateOptions) (SchedulesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, scheduleName, body, options) + if err != nil { + return SchedulesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SchedulesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return SchedulesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SchedulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body Schedule, options *SchedulesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SchedulesClient) createOrUpdateHandleResponse(resp *http.Response) (SchedulesCreateOrUpdateResponse, error) { + result := SchedulesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Schedule); err != nil { + return SchedulesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *SchedulesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Operation to delete a schedule resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SchedulesClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesBeginDeleteOptions) (SchedulesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, labName, scheduleName, options) + if err != nil { + return SchedulesDeletePollerResponse{}, err + } + result := SchedulesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("SchedulesClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return SchedulesDeletePollerResponse{}, err + } + result.Poller = &SchedulesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Operation to delete a schedule resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SchedulesClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, scheduleName, 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 *SchedulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *SchedulesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Returns the properties of a lab Schedule. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SchedulesClient) Get(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesGetOptions) (SchedulesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, labName, scheduleName, options) + if err != nil { + return SchedulesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SchedulesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SchedulesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SchedulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SchedulesClient) getHandleResponse(resp *http.Response) (SchedulesGetResponse, error) { + result := SchedulesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Schedule); err != nil { + return SchedulesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SchedulesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByLab - Returns a list of all schedules for a lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SchedulesClient) ListByLab(resourceGroupName string, labName string, options *SchedulesListByLabOptions) *SchedulesListByLabPager { + return &SchedulesListByLabPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) + }, + advancer: func(ctx context.Context, resp SchedulesListByLabResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedSchedules.NextLink) + }, + } +} + +// listByLabCreateRequest creates the ListByLab request. +func (client *SchedulesClient) listByLabCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *SchedulesListByLabOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByLabHandleResponse handles the ListByLab response. +func (client *SchedulesClient) listByLabHandleResponse(resp *http.Response) (SchedulesListByLabResponse, error) { + result := SchedulesListByLabResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedSchedules); err != nil { + return SchedulesListByLabResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByLabHandleError handles the ListByLab error response. +func (client *SchedulesClient) listByLabHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Operation to update a lab schedule. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SchedulesClient) Update(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body ScheduleUpdate, options *SchedulesUpdateOptions) (SchedulesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, scheduleName, body, options) + if err != nil { + return SchedulesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SchedulesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SchedulesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *SchedulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body ScheduleUpdate, options *SchedulesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleResponse handles the Update response. +func (client *SchedulesClient) updateHandleResponse(resp *http.Response) (SchedulesUpdateResponse, error) { + result := SchedulesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Schedule); err != nil { + return SchedulesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *SchedulesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_skus_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_skus_client.go new file mode 100644 index 000000000000..d790d35edb1c --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_skus_client.go @@ -0,0 +1,100 @@ +//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 armlabservices + +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" +) + +// SKUsClient contains the methods for the SKUs group. +// Don't use this type directly, use NewSKUsClient() instead. +type SKUsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewSKUsClient creates a new instance of SKUsClient with the specified values. +func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *SKUsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &SKUsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Returns a list of all the Azure Lab Services resource SKUs. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SKUsClient) List(options *SKUsListOptions) *SKUsListPager { + return &SKUsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp SKUsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedLabServicesSKUs.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/skus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SKUsClient) listHandleResponse(resp *http.Response) (SKUsListResponse, error) { + result := SKUsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedLabServicesSKUs); err != nil { + return SKUsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *SKUsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_time_rfc3339.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..7e83c86e8e2c --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/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 armlabservices + +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/labservices/armlabservices/zz_generated_usages_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_usages_client.go new file mode 100644 index 000000000000..e607b1b1db75 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_usages_client.go @@ -0,0 +1,104 @@ +//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 armlabservices + +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" +) + +// UsagesClient contains the methods for the Usages group. +// Don't use this type directly, use NewUsagesClient() instead. +type UsagesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewUsagesClient creates a new instance of UsagesClient with the specified values. +func NewUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *UsagesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &UsagesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// ListByLocation - Returns list of usage per SKU family for the specified subscription in the specified region. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsagesClient) ListByLocation(location string, options *UsagesListByLocationOptions) *UsagesListByLocationPager { + return &UsagesListByLocationPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByLocationCreateRequest(ctx, location, options) + }, + advancer: func(ctx context.Context, resp UsagesListByLocationResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ListUsagesResult.NextLink) + }, + } +} + +// listByLocationCreateRequest creates the ListByLocation request. +func (client *UsagesClient) listByLocationCreateRequest(ctx context.Context, location string, options *UsagesListByLocationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/locations/{location}/usages" + 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.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByLocationHandleResponse handles the ListByLocation response. +func (client *UsagesClient) listByLocationHandleResponse(resp *http.Response) (UsagesListByLocationResponse, error) { + result := UsagesListByLocationResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ListUsagesResult); err != nil { + return UsagesListByLocationResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByLocationHandleError handles the ListByLocation error response. +func (client *UsagesClient) listByLocationHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_users_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_users_client.go new file mode 100644 index 000000000000..818d5d9fb2fa --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_users_client.go @@ -0,0 +1,497 @@ +//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 armlabservices + +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" +) + +// UsersClient contains the methods for the Users group. +// Don't use this type directly, use NewUsersClient() instead. +type UsersClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewUsersClient creates a new instance of UsersClient with the specified values. +func NewUsersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *UsersClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &UsersClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Operation to create or update a lab user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, body User, options *UsersBeginCreateOrUpdateOptions) (UsersCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, labName, userName, body, options) + if err != nil { + return UsersCreateOrUpdatePollerResponse{}, err + } + result := UsersCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("UsersClient.CreateOrUpdate", "original-uri", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return UsersCreateOrUpdatePollerResponse{}, err + } + result.Poller = &UsersCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Operation to create or update a lab user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, body User, options *UsersBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, labName, userName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *UsersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, labName string, userName string, body User, options *UsersBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if userName == "" { + return nil, errors.New("parameter userName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *UsersClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Operation to delete a user resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) BeginDelete(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersBeginDeleteOptions) (UsersDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, labName, userName, options) + if err != nil { + return UsersDeletePollerResponse{}, err + } + result := UsersDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("UsersClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return UsersDeletePollerResponse{}, err + } + result.Poller = &UsersDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Operation to delete a user resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, labName, userName, 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 *UsersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if userName == "" { + return nil, errors.New("parameter userName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *UsersClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Returns the properties of a lab user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersGetOptions) (UsersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, labName, userName, options) + if err != nil { + return UsersGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return UsersGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return UsersGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *UsersClient) getCreateRequest(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if userName == "" { + return nil, errors.New("parameter userName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *UsersClient) getHandleResponse(resp *http.Response) (UsersGetResponse, error) { + result := UsersGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.User); err != nil { + return UsersGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *UsersClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginInvite - Operation to invite a user to a lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) BeginInvite(ctx context.Context, resourceGroupName string, labName string, userName string, body InviteBody, options *UsersBeginInviteOptions) (UsersInvitePollerResponse, error) { + resp, err := client.invite(ctx, resourceGroupName, labName, userName, body, options) + if err != nil { + return UsersInvitePollerResponse{}, err + } + result := UsersInvitePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("UsersClient.Invite", "location", resp, client.pl, client.inviteHandleError) + if err != nil { + return UsersInvitePollerResponse{}, err + } + result.Poller = &UsersInvitePoller{ + pt: pt, + } + return result, nil +} + +// Invite - Operation to invite a user to a lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) invite(ctx context.Context, resourceGroupName string, labName string, userName string, body InviteBody, options *UsersBeginInviteOptions) (*http.Response, error) { + req, err := client.inviteCreateRequest(ctx, resourceGroupName, labName, userName, body, 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.inviteHandleError(resp) + } + return resp, nil +} + +// inviteCreateRequest creates the Invite request. +func (client *UsersClient) inviteCreateRequest(ctx context.Context, resourceGroupName string, labName string, userName string, body InviteBody, options *UsersBeginInviteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}/invite" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if userName == "" { + return nil, errors.New("parameter userName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// inviteHandleError handles the Invite error response. +func (client *UsersClient) inviteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByLab - Returns a list of all users for a lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) ListByLab(resourceGroupName string, labName string, options *UsersListByLabOptions) *UsersListByLabPager { + return &UsersListByLabPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) + }, + advancer: func(ctx context.Context, resp UsersListByLabResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedUsers.NextLink) + }, + } +} + +// listByLabCreateRequest creates the ListByLab request. +func (client *UsersClient) listByLabCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *UsersListByLabOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByLabHandleResponse handles the ListByLab response. +func (client *UsersClient) listByLabHandleResponse(resp *http.Response) (UsersListByLabResponse, error) { + result := UsersListByLabResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedUsers); err != nil { + return UsersListByLabResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByLabHandleError handles the ListByLab error response. +func (client *UsersClient) listByLabHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Operation to update a lab user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) BeginUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, body UserUpdate, options *UsersBeginUpdateOptions) (UsersUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, labName, userName, body, options) + if err != nil { + return UsersUpdatePollerResponse{}, err + } + result := UsersUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("UsersClient.Update", "location", resp, client.pl, client.updateHandleError) + if err != nil { + return UsersUpdatePollerResponse{}, err + } + result.Poller = &UsersUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Operation to update a lab user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UsersClient) update(ctx context.Context, resourceGroupName string, labName string, userName string, body UserUpdate, options *UsersBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, labName, userName, body, 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 *UsersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, labName string, userName string, body UserUpdate, options *UsersBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if userName == "" { + return nil, errors.New("parameter userName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userName}", url.PathEscape(userName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleError handles the Update error response. +func (client *UsersClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/labservices/armlabservices/zz_generated_virtualmachines_client.go b/sdk/resourcemanager/labservices/armlabservices/zz_generated_virtualmachines_client.go new file mode 100644 index 000000000000..3d0bb3b26d3c --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/zz_generated_virtualmachines_client.go @@ -0,0 +1,579 @@ +//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 armlabservices + +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 - Returns the properties for a lab virtual machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesGetOptions) (VirtualMachinesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, 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, labName string, virtualMachineName string, options *VirtualMachinesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + 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-11-15-preview") + 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 := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByLab - Returns a list of all virtual machines for a lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) ListByLab(resourceGroupName string, labName string, options *VirtualMachinesListByLabOptions) *VirtualMachinesListByLabPager { + return &VirtualMachinesListByLabPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) + }, + advancer: func(ctx context.Context, resp VirtualMachinesListByLabResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PagedVirtualMachines.NextLink) + }, + } +} + +// listByLabCreateRequest creates the ListByLab request. +func (client *VirtualMachinesClient) listByLabCreateRequest(ctx context.Context, resourceGroupName string, labName string, options *VirtualMachinesListByLabOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + 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-11-15-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByLabHandleResponse handles the ListByLab response. +func (client *VirtualMachinesClient) listByLabHandleResponse(resp *http.Response) (VirtualMachinesListByLabResponse, error) { + result := VirtualMachinesListByLabResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedVirtualMachines); err != nil { + return VirtualMachinesListByLabResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByLabHandleError handles the ListByLab error response. +func (client *VirtualMachinesClient) listByLabHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginRedeploy - Action to redeploy a lab virtual machine to a different compute node. For troubleshooting connectivity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) BeginRedeploy(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginRedeployOptions) (VirtualMachinesRedeployPollerResponse, error) { + resp, err := client.redeploy(ctx, resourceGroupName, labName, virtualMachineName, options) + if err != nil { + return VirtualMachinesRedeployPollerResponse{}, err + } + result := VirtualMachinesRedeployPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VirtualMachinesClient.Redeploy", "location", resp, client.pl, client.redeployHandleError) + if err != nil { + return VirtualMachinesRedeployPollerResponse{}, err + } + result.Poller = &VirtualMachinesRedeployPoller{ + pt: pt, + } + return result, nil +} + +// Redeploy - Action to redeploy a lab virtual machine to a different compute node. For troubleshooting connectivity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) redeploy(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginRedeployOptions) (*http.Response, error) { + req, err := client.redeployCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, 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.redeployHandleError(resp) + } + return resp, nil +} + +// redeployCreateRequest creates the Redeploy request. +func (client *VirtualMachinesClient) redeployCreateRequest(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginRedeployOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/redeploy" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// redeployHandleError handles the Redeploy error response. +func (client *VirtualMachinesClient) redeployHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginReimage - Re-image a lab virtual machine. The virtual machine will be deleted and recreated using the latest published snapshot of the reference +// environment of the lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) BeginReimage(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginReimageOptions) (VirtualMachinesReimagePollerResponse, error) { + resp, err := client.reimage(ctx, resourceGroupName, labName, virtualMachineName, options) + if err != nil { + return VirtualMachinesReimagePollerResponse{}, err + } + result := VirtualMachinesReimagePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VirtualMachinesClient.Reimage", "location", resp, client.pl, client.reimageHandleError) + if err != nil { + return VirtualMachinesReimagePollerResponse{}, err + } + result.Poller = &VirtualMachinesReimagePoller{ + pt: pt, + } + return result, nil +} + +// Reimage - Re-image a lab virtual machine. The virtual machine will be deleted and recreated using the latest published snapshot of the reference environment +// of the lab. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) reimage(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginReimageOptions) (*http.Response, error) { + req, err := client.reimageCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, 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.reimageHandleError(resp) + } + return resp, nil +} + +// reimageCreateRequest creates the Reimage request. +func (client *VirtualMachinesClient) reimageCreateRequest(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginReimageOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/reimage" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// reimageHandleError handles the Reimage error response. +func (client *VirtualMachinesClient) reimageHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginResetPassword - Resets a lab virtual machine password. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) BeginResetPassword(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, body ResetPasswordBody, options *VirtualMachinesBeginResetPasswordOptions) (VirtualMachinesResetPasswordPollerResponse, error) { + resp, err := client.resetPassword(ctx, resourceGroupName, labName, virtualMachineName, body, options) + if err != nil { + return VirtualMachinesResetPasswordPollerResponse{}, err + } + result := VirtualMachinesResetPasswordPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VirtualMachinesClient.ResetPassword", "location", resp, client.pl, client.resetPasswordHandleError) + if err != nil { + return VirtualMachinesResetPasswordPollerResponse{}, err + } + result.Poller = &VirtualMachinesResetPasswordPoller{ + pt: pt, + } + return result, nil +} + +// ResetPassword - Resets a lab virtual machine password. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) resetPassword(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, body ResetPasswordBody, options *VirtualMachinesBeginResetPasswordOptions) (*http.Response, error) { + req, err := client.resetPasswordCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, body, 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.resetPasswordHandleError(resp) + } + return resp, nil +} + +// resetPasswordCreateRequest creates the ResetPassword request. +func (client *VirtualMachinesClient) resetPasswordCreateRequest(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, body ResetPasswordBody, options *VirtualMachinesBeginResetPasswordOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/resetPassword" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// resetPasswordHandleError handles the ResetPassword error response. +func (client *VirtualMachinesClient) resetPasswordHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginStart - Action to start a lab virtual machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginStartOptions) (VirtualMachinesStartPollerResponse, error) { + resp, err := client.start(ctx, resourceGroupName, labName, virtualMachineName, options) + if err != nil { + return VirtualMachinesStartPollerResponse{}, err + } + result := VirtualMachinesStartPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VirtualMachinesClient.Start", "location", resp, client.pl, client.startHandleError) + if err != nil { + return VirtualMachinesStartPollerResponse{}, err + } + result.Poller = &VirtualMachinesStartPoller{ + pt: pt, + } + return result, nil +} + +// Start - Action to start a lab virtual machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginStartOptions) (*http.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.startHandleError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/start" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// startHandleError handles the Start error response. +func (client *VirtualMachinesClient) startHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginStop - Action to stop a lab virtual machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginStopOptions) (VirtualMachinesStopPollerResponse, error) { + resp, err := client.stop(ctx, resourceGroupName, labName, virtualMachineName, options) + if err != nil { + return VirtualMachinesStopPollerResponse{}, err + } + result := VirtualMachinesStopPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VirtualMachinesClient.Stop", "location", resp, client.pl, client.stopHandleError) + if err != nil { + return VirtualMachinesStopPollerResponse{}, err + } + result.Poller = &VirtualMachinesStopPoller{ + pt: pt, + } + return result, nil +} + +// Stop - Action to stop a lab virtual machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginStopOptions) (*http.Response, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.stopHandleError(resp) + } + return resp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesBeginStopOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/stop" + 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 labName == "" { + return nil, errors.New("parameter labName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{labName}", url.PathEscape(labName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + 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-11-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// stopHandleError handles the Stop error response. +func (client *VirtualMachinesClient) stopHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +}