diff --git a/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md b/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md new file mode 100644 index 000000000000..f1b16584ead1 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-04-21) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/scvmm/armscvmm/LICENSE.txt b/sdk/resourcemanager/scvmm/armscvmm/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/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/scvmm/armscvmm/README.md b/sdk/resourcemanager/scvmm/armscvmm/README.md new file mode 100644 index 000000000000..e96c1cf4e219 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/README.md @@ -0,0 +1,77 @@ +# Azure Scvmm Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm) + +The `armscvmm` module provides operations for working with Azure Scvmm. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/scvmm/armscvmm) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 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 Scvmm module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Scvmm. 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 Scvmm 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, err := armscvmm.NewCloudsClient(, 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{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armscvmm.NewCloudsClient(, 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 `Scvmm` 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/scvmm/armscvmm/autorest.md b/sdk/resourcemanager/scvmm/armscvmm/autorest.md new file mode 100644 index 000000000000..36c608874527 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/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/6cb07747e61d4068750cb2666ab1b32197037dbf/specification/scvmm/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/6cb07747e61d4068750cb2666ab1b32197037dbf/specification/scvmm/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/scvmm/armscvmm/build.go b/sdk/resourcemanager/scvmm/armscvmm/build.go new file mode 100644 index 000000000000..05aa90e90bcb --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/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/scvmm/armscvmm + +package armscvmm diff --git a/sdk/resourcemanager/scvmm/armscvmm/ci.yml b/sdk/resourcemanager/scvmm/armscvmm/ci.yml new file mode 100644 index 000000000000..068198b1d508 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ci.yml @@ -0,0 +1,28 @@ +# 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/scvmm/armscvmm/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/scvmm/armscvmm/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/scvmm/armscvmm' diff --git a/sdk/resourcemanager/scvmm/armscvmm/go.mod b/sdk/resourcemanager/scvmm/armscvmm/go.mod new file mode 100644 index 000000000000..e7803b18546d --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect + github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect + golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/scvmm/armscvmm/go.sum b/sdk/resourcemanager/scvmm/armscvmm/go.sum new file mode 100644 index 000000000000..56d1c32628ae --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/go.sum @@ -0,0 +1,53 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 h1:D7l5jspkc4kwBYRWoZE4DQnu6LVpLwDsMZjBKS4wZLQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0/go.mod h1:w5pDIZuawUmY3Bj4tVx3Xb8KS96ToB0j315w9rqpAg0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 h1:NVS/4LOQfkBpk+B1VopIzv1ptmYeEskA8w/3K/w7vjo= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0/go.mod h1:RG0cZndeZM17StwohYclmcXSr4oOJ8b1I5hB8llIc6Y= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= +github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +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/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +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-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +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 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +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= diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_availabilitysets_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_availabilitysets_client_test.go new file mode 100644 index 000000000000..caae98ef86c0 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_availabilitysets_client_test.go @@ -0,0 +1,186 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetAvailabilitySet.json +func ExampleAvailabilitySetsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewAvailabilitySetsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateAvailabilitySet.json +func ExampleAvailabilitySetsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewAvailabilitySetsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armscvmm.AvailabilitySet{ + ExtendedLocation: &armscvmm.ExtendedLocation{ + Name: to.Ptr(""), + Type: to.Ptr(""), + }, + Location: to.Ptr(""), + Properties: &armscvmm.AvailabilitySetProperties{ + AvailabilitySetName: to.Ptr(""), + VmmServerID: to.Ptr(""), + }, + }, + &armscvmm.AvailabilitySetsClientBeginCreateOrUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteAvailabilitySet.json +func ExampleAvailabilitySetsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewAvailabilitySetsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, + "", + "", + &armscvmm.AvailabilitySetsClientBeginDeleteOptions{Force: nil, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateAvailabilitySet.json +func ExampleAvailabilitySetsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewAvailabilitySetsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, + "", + "", + armscvmm.ResourcePatch{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, + &armscvmm.AvailabilitySetsClientBeginUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListAvailabilitySetsByResourceGroup.json +func ExampleAvailabilitySetsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewAvailabilitySetsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListAvailabilitySetsBySubscription.json +func ExampleAvailabilitySetsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewAvailabilitySetsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_clouds_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_clouds_client_test.go new file mode 100644 index 000000000000..c616410875a8 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_clouds_client_test.go @@ -0,0 +1,186 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetCloud.json +func ExampleCloudsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewCloudsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateCloud.json +func ExampleCloudsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewCloudsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armscvmm.Cloud{ + ExtendedLocation: &armscvmm.ExtendedLocation{ + Name: to.Ptr(""), + Type: to.Ptr(""), + }, + Location: to.Ptr(""), + Properties: &armscvmm.CloudProperties{ + UUID: to.Ptr(""), + VmmServerID: to.Ptr(""), + }, + }, + &armscvmm.CloudsClientBeginCreateOrUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteCloud.json +func ExampleCloudsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewCloudsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, + "", + "", + &armscvmm.CloudsClientBeginDeleteOptions{Force: nil, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateCloud.json +func ExampleCloudsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewCloudsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, + "", + "", + armscvmm.ResourcePatch{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, + &armscvmm.CloudsClientBeginUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListCloudsByResourceGroup.json +func ExampleCloudsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewCloudsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListCloudsBySubscription.json +func ExampleCloudsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewCloudsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_inventoryitems_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_inventoryitems_client_test.go new file mode 100644 index 000000000000..44d926bcfd44 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_inventoryitems_client_test.go @@ -0,0 +1,116 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_test + +import ( + "context" + "log" + + "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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateInventoryItem.json +func ExampleInventoryItemsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewInventoryItemsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Create(ctx, + "", + "", + "", + &armscvmm.InventoryItemsClientCreateOptions{Body: &armscvmm.InventoryItem{ + Properties: &armscvmm.CloudInventoryItem{ + InventoryType: to.Ptr(armscvmm.InventoryTypeCloud), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetInventoryItem.json +func ExampleInventoryItemsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewInventoryItemsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteInventoryItem.json +func ExampleInventoryItemsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewInventoryItemsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListInventoryItemsByVMMServer.json +func ExampleInventoryItemsClient_NewListByVMMServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewInventoryItemsClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByVMMServerPager("", + "", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_operations_client_test.go new file mode 100644 index 000000000000..7ff80ea35de0 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_operations_client_test.go @@ -0,0 +1,41 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListOperations.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewOperationsClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualmachines_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualmachines_client_test.go new file mode 100644 index 000000000000..f55697ec7825 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualmachines_client_test.go @@ -0,0 +1,375 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/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, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVirtualMachine.json +func ExampleVirtualMachinesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armscvmm.VirtualMachine{ + ExtendedLocation: &armscvmm.ExtendedLocation{ + Name: to.Ptr(""), + Type: to.Ptr(""), + }, + Location: to.Ptr(""), + Properties: &armscvmm.VirtualMachineProperties{ + CloudID: to.Ptr(""), + HardwareProfile: &armscvmm.HardwareProfile{ + CPUCount: to.Ptr[int32](4), + MemoryMB: to.Ptr[int32](4096), + }, + TemplateID: to.Ptr(""), + VmmServerID: to.Ptr(""), + }, + }, + &armscvmm.VirtualMachinesClientBeginCreateOrUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteVirtualMachine.json +func ExampleVirtualMachinesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginDeleteOptions{Retain: nil, + Force: nil, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVirtualMachine.json +func ExampleVirtualMachinesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, + "", + "", + armscvmm.VirtualMachineUpdate{ + Properties: &armscvmm.VirtualMachineUpdateProperties{ + HardwareProfile: &armscvmm.HardwareProfileUpdate{ + CPUCount: to.Ptr[int32](4), + MemoryMB: to.Ptr[int32](4096), + }, + NetworkProfile: &armscvmm.NetworkProfileUpdate{ + NetworkInterfaces: []*armscvmm.NetworkInterfacesUpdate{ + { + Name: to.Ptr(""), + IPv4AddressType: to.Ptr(armscvmm.AllocationMethodDynamic), + IPv6AddressType: to.Ptr(armscvmm.AllocationMethodDynamic), + MacAddressType: to.Ptr(armscvmm.AllocationMethodStatic), + }}, + }, + StorageProfile: &armscvmm.StorageProfileUpdate{ + Disks: []*armscvmm.VirtualDiskUpdate{ + { + Name: to.Ptr(""), + DiskSizeGB: to.Ptr[int32](10), + }}, + }, + }, + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, + &armscvmm.VirtualMachinesClientBeginUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/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, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginStop(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginStopOptions{Body: &armscvmm.StopVirtualMachineOptions{ + SkipShutdown: to.Ptr(true), + }, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/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, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginStart(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginStartOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/RestartVirtualMachine.json +func ExampleVirtualMachinesClient_BeginRestart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginRestart(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginRestartOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateCheckpointVirtualMachine.json +func ExampleVirtualMachinesClient_BeginCreateCheckpoint() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateCheckpoint(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginCreateCheckpointOptions{Body: &armscvmm.VirtualMachineCreateCheckpoint{ + Name: to.Ptr(""), + Description: to.Ptr(""), + }, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteCheckpointVirtualMachine.json +func ExampleVirtualMachinesClient_BeginDeleteCheckpoint() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDeleteCheckpoint(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginDeleteCheckpointOptions{Body: &armscvmm.VirtualMachineDeleteCheckpoint{ + ID: to.Ptr(""), + }, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/RestoreCheckpointVirtualMachine.json +func ExampleVirtualMachinesClient_BeginRestoreCheckpoint() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginRestoreCheckpoint(ctx, + "", + "", + &armscvmm.VirtualMachinesClientBeginRestoreCheckpointOptions{Body: &armscvmm.VirtualMachineRestoreCheckpoint{ + ID: to.Ptr(""), + }, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualMachinesByResourceGroup.json +func ExampleVirtualMachinesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualMachinesBySubscription.json +func ExampleVirtualMachinesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachinesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualmachinetemplates_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualmachinetemplates_client_test.go new file mode 100644 index 000000000000..d5cdb18ca415 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualmachinetemplates_client_test.go @@ -0,0 +1,186 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetVirtualMachineTemplate.json +func ExampleVirtualMachineTemplatesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachineTemplatesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVirtualMachineTemplate.json +func ExampleVirtualMachineTemplatesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachineTemplatesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armscvmm.VirtualMachineTemplate{ + ExtendedLocation: &armscvmm.ExtendedLocation{ + Name: to.Ptr(""), + Type: to.Ptr(""), + }, + Location: to.Ptr(""), + Properties: &armscvmm.VirtualMachineTemplateProperties{ + UUID: to.Ptr(""), + VmmServerID: to.Ptr(""), + }, + }, + &armscvmm.VirtualMachineTemplatesClientBeginCreateOrUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteVirtualMachineTemplate.json +func ExampleVirtualMachineTemplatesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachineTemplatesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, + "", + "", + &armscvmm.VirtualMachineTemplatesClientBeginDeleteOptions{Force: nil, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVirtualMachineTemplate.json +func ExampleVirtualMachineTemplatesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachineTemplatesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, + "", + "", + armscvmm.ResourcePatch{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, + &armscvmm.VirtualMachineTemplatesClientBeginUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualMachineTemplatesByResourceGroup.json +func ExampleVirtualMachineTemplatesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachineTemplatesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualMachineTemplatesBySubscription.json +func ExampleVirtualMachineTemplatesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualMachineTemplatesClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualnetworks_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualnetworks_client_test.go new file mode 100644 index 000000000000..080779152a91 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_virtualnetworks_client_test.go @@ -0,0 +1,186 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetVirtualNetwork.json +func ExampleVirtualNetworksClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualNetworksClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVirtualNetwork.json +func ExampleVirtualNetworksClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualNetworksClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armscvmm.VirtualNetwork{ + ExtendedLocation: &armscvmm.ExtendedLocation{ + Name: to.Ptr(""), + Type: to.Ptr(""), + }, + Location: to.Ptr(""), + Properties: &armscvmm.VirtualNetworkProperties{ + UUID: to.Ptr(""), + VmmServerID: to.Ptr(""), + }, + }, + &armscvmm.VirtualNetworksClientBeginCreateOrUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteVirtualNetwork.json +func ExampleVirtualNetworksClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualNetworksClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, + "", + "", + &armscvmm.VirtualNetworksClientBeginDeleteOptions{Force: nil, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVirtualNetwork.json +func ExampleVirtualNetworksClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualNetworksClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, + "", + "", + armscvmm.ResourcePatch{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, + &armscvmm.VirtualNetworksClientBeginUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualNetworksByResourceGroup.json +func ExampleVirtualNetworksClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualNetworksClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualNetworksBySubscription.json +func ExampleVirtualNetworksClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVirtualNetworksClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_vmmservers_client_test.go b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_vmmservers_client_test.go new file mode 100644 index 000000000000..7ec6f1414740 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/ze_generated_example_vmmservers_client_test.go @@ -0,0 +1,190 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm_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/scvmm/armscvmm" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetVMMServer.json +func ExampleVmmServersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVmmServersClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVMMServer.json +func ExampleVmmServersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVmmServersClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armscvmm.VMMServer{ + ExtendedLocation: &armscvmm.ExtendedLocation{ + Name: to.Ptr(""), + Type: to.Ptr(""), + }, + Location: to.Ptr(""), + Properties: &armscvmm.VMMServerProperties{ + Credentials: &armscvmm.VMMServerPropertiesCredentials{ + Password: to.Ptr(""), + Username: to.Ptr(""), + }, + Fqdn: to.Ptr(""), + Port: to.Ptr[int32](1234), + }, + }, + &armscvmm.VmmServersClientBeginCreateOrUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteVMMServer.json +func ExampleVmmServersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVmmServersClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, + "", + "", + &armscvmm.VmmServersClientBeginDeleteOptions{Force: nil, + ResumeToken: "", + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVMMServer.json +func ExampleVmmServersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVmmServersClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, + "", + "", + armscvmm.ResourcePatch{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, + &armscvmm.VmmServersClientBeginUpdateOptions{ResumeToken: ""}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVMMServersByResourceGroup.json +func ExampleVmmServersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVmmServersClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("", + nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVMMServersBySubscription.json +func ExampleVmmServersClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armscvmm.NewVmmServersClient("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_availabilitysets_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_availabilitysets_client.go new file mode 100644 index 000000000000..ea6d793dd327 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_availabilitysets_client.go @@ -0,0 +1,426 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// AvailabilitySetsClient contains the methods for the AvailabilitySets group. +// Don't use this type directly, use NewAvailabilitySetsClient() instead. +type AvailabilitySetsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewAvailabilitySetsClient creates a new instance of AvailabilitySetsClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewAvailabilitySetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvailabilitySetsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &AvailabilitySetsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Onboards the ScVmm availability set as an Azure resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// availabilitySetName - Name of the AvailabilitySet. +// body - Request payload. +// options - AvailabilitySetsClientBeginCreateOrUpdateOptions contains the optional parameters for the AvailabilitySetsClient.BeginCreateOrUpdate +// method. +func (client *AvailabilitySetsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, body AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*armruntime.Poller[AvailabilitySetsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, availabilitySetName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[AvailabilitySetsClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[AvailabilitySetsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Onboards the ScVmm availability set as an Azure resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *AvailabilitySetsClient) createOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, body AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, availabilitySetName, 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) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, body AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" + 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 availabilitySetName == "" { + return nil, errors.New("parameter availabilitySetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deregisters the ScVmm availability set from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// availabilitySetName - Name of the AvailabilitySet. +// options - AvailabilitySetsClientBeginDeleteOptions contains the optional parameters for the AvailabilitySetsClient.BeginDelete +// method. +func (client *AvailabilitySetsClient) BeginDelete(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientBeginDeleteOptions) (*armruntime.Poller[AvailabilitySetsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, availabilitySetName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[AvailabilitySetsClientDeleteResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[AvailabilitySetsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deregisters the ScVmm availability set from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *AvailabilitySetsClient) deleteOperation(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, availabilitySetName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" + 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 availabilitySetName == "" { + return nil, errors.New("parameter availabilitySetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Implements AvailabilitySet GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// availabilitySetName - Name of the AvailabilitySet. +// options - AvailabilitySetsClientGetOptions contains the optional parameters for the AvailabilitySetsClient.Get method. +func (client *AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientGetOptions) (AvailabilitySetsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, availabilitySetName, options) + if err != nil { + return AvailabilitySetsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AvailabilitySetsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AvailabilitySetsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AvailabilitySetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" + 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 availabilitySetName == "" { + return nil, errors.New("parameter availabilitySetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AvailabilitySetsClient) getHandleResponse(resp *http.Response) (AvailabilitySetsClientGetResponse, error) { + result := AvailabilitySetsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySet); err != nil { + return AvailabilitySetsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List of AvailabilitySets in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// options - AvailabilitySetsClientListByResourceGroupOptions contains the optional parameters for the AvailabilitySetsClient.ListByResourceGroup +// method. +func (client *AvailabilitySetsClient) NewListByResourceGroupPager(resourceGroupName string, options *AvailabilitySetsClientListByResourceGroupOptions) *runtime.Pager[AvailabilitySetsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[AvailabilitySetsClientListByResourceGroupResponse]{ + More: func(page AvailabilitySetsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AvailabilitySetsClientListByResourceGroupResponse) (AvailabilitySetsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AvailabilitySetsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AvailabilitySetsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AvailabilitySetsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AvailabilitySetsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AvailabilitySetsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AvailabilitySetsClient) listByResourceGroupHandleResponse(resp *http.Response) (AvailabilitySetsClientListByResourceGroupResponse, error) { + result := AvailabilitySetsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySetListResult); err != nil { + return AvailabilitySetsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List of AvailabilitySets in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// options - AvailabilitySetsClientListBySubscriptionOptions contains the optional parameters for the AvailabilitySetsClient.ListBySubscription +// method. +func (client *AvailabilitySetsClient) NewListBySubscriptionPager(options *AvailabilitySetsClientListBySubscriptionOptions) *runtime.Pager[AvailabilitySetsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[AvailabilitySetsClientListBySubscriptionResponse]{ + More: func(page AvailabilitySetsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AvailabilitySetsClientListBySubscriptionResponse) (AvailabilitySetsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AvailabilitySetsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AvailabilitySetsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AvailabilitySetsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AvailabilitySetsClient) listBySubscriptionCreateRequest(ctx context.Context, options *AvailabilitySetsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/availabilitySets" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AvailabilitySetsClient) listBySubscriptionHandleResponse(resp *http.Response) (AvailabilitySetsClientListBySubscriptionResponse, error) { + result := AvailabilitySetsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySetListResult); err != nil { + return AvailabilitySetsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the AvailabilitySets resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// availabilitySetName - Name of the AvailabilitySet. +// body - AvailabilitySets patch payload. +// options - AvailabilitySetsClientBeginUpdateOptions contains the optional parameters for the AvailabilitySetsClient.BeginUpdate +// method. +func (client *AvailabilitySetsClient) BeginUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, body ResourcePatch, options *AvailabilitySetsClientBeginUpdateOptions) (*armruntime.Poller[AvailabilitySetsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, availabilitySetName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[AvailabilitySetsClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[AvailabilitySetsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the AvailabilitySets resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *AvailabilitySetsClient) update(ctx context.Context, resourceGroupName string, availabilitySetName string, body ResourcePatch, options *AvailabilitySetsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, availabilitySetName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *AvailabilitySetsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, body ResourcePatch, options *AvailabilitySetsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if availabilitySetName == "" { + return nil, errors.New("parameter availabilitySetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_clouds_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_clouds_client.go new file mode 100644 index 000000000000..82cca500caf4 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_clouds_client.go @@ -0,0 +1,426 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// CloudsClient contains the methods for the Clouds group. +// Don't use this type directly, use NewCloudsClient() instead. +type CloudsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewCloudsClient creates a new instance of CloudsClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewCloudsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CloudsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &CloudsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Onboards the ScVmm fabric cloud as an Azure cloud resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// cloudName - Name of the Cloud. +// body - Request payload. +// options - CloudsClientBeginCreateOrUpdateOptions contains the optional parameters for the CloudsClient.BeginCreateOrUpdate +// method. +func (client *CloudsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, cloudName string, body Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*armruntime.Poller[CloudsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, cloudName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[CloudsClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[CloudsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Onboards the ScVmm fabric cloud as an Azure cloud resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *CloudsClient) createOrUpdate(ctx context.Context, resourceGroupName string, cloudName string, body Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, cloudName, 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) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CloudsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, body Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" + 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 cloudName == "" { + return nil, errors.New("parameter cloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deregisters the ScVmm fabric cloud from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// cloudName - Name of the Cloud. +// options - CloudsClientBeginDeleteOptions contains the optional parameters for the CloudsClient.BeginDelete method. +func (client *CloudsClient) BeginDelete(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientBeginDeleteOptions) (*armruntime.Poller[CloudsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, cloudName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[CloudsClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[CloudsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deregisters the ScVmm fabric cloud from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *CloudsClient) deleteOperation(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, cloudName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CloudsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" + 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 cloudName == "" { + return nil, errors.New("parameter cloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Implements Cloud GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// cloudName - Name of the Cloud. +// options - CloudsClientGetOptions contains the optional parameters for the CloudsClient.Get method. +func (client *CloudsClient) Get(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientGetOptions) (CloudsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, cloudName, options) + if err != nil { + return CloudsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CloudsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CloudsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CloudsClient) getCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" + 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 cloudName == "" { + return nil, errors.New("parameter cloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CloudsClient) getHandleResponse(resp *http.Response) (CloudsClientGetResponse, error) { + result := CloudsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Cloud); err != nil { + return CloudsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List of Clouds in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// options - CloudsClientListByResourceGroupOptions contains the optional parameters for the CloudsClient.ListByResourceGroup +// method. +func (client *CloudsClient) NewListByResourceGroupPager(resourceGroupName string, options *CloudsClientListByResourceGroupOptions) *runtime.Pager[CloudsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[CloudsClientListByResourceGroupResponse]{ + More: func(page CloudsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CloudsClientListByResourceGroupResponse) (CloudsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CloudsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CloudsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CloudsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CloudsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CloudsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CloudsClient) listByResourceGroupHandleResponse(resp *http.Response) (CloudsClientListByResourceGroupResponse, error) { + result := CloudsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CloudListResult); err != nil { + return CloudsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List of Clouds in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// options - CloudsClientListBySubscriptionOptions contains the optional parameters for the CloudsClient.ListBySubscription +// method. +func (client *CloudsClient) NewListBySubscriptionPager(options *CloudsClientListBySubscriptionOptions) *runtime.Pager[CloudsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[CloudsClientListBySubscriptionResponse]{ + More: func(page CloudsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CloudsClientListBySubscriptionResponse) (CloudsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CloudsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CloudsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CloudsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CloudsClient) listBySubscriptionCreateRequest(ctx context.Context, options *CloudsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/clouds" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *CloudsClient) listBySubscriptionHandleResponse(resp *http.Response) (CloudsClientListBySubscriptionResponse, error) { + result := CloudsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CloudListResult); err != nil { + return CloudsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the Clouds resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// cloudName - Name of the Cloud. +// body - Clouds patch payload. +// options - CloudsClientBeginUpdateOptions contains the optional parameters for the CloudsClient.BeginUpdate method. +func (client *CloudsClient) BeginUpdate(ctx context.Context, resourceGroupName string, cloudName string, body ResourcePatch, options *CloudsClientBeginUpdateOptions) (*armruntime.Poller[CloudsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, cloudName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[CloudsClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[CloudsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the Clouds resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *CloudsClient) update(ctx context.Context, resourceGroupName string, cloudName string, body ResourcePatch, options *CloudsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, cloudName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *CloudsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, body ResourcePatch, options *CloudsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cloudName == "" { + return nil, errors.New("parameter cloudName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_constants.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_constants.go new file mode 100644 index 000000000000..c3f096184263 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_constants.go @@ -0,0 +1,153 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +const ( + moduleName = "armscvmm" + moduleVersion = "v0.1.0" +) + +// AllocationMethod - Allocation method. +type AllocationMethod string + +const ( + AllocationMethodDynamic AllocationMethod = "Dynamic" + AllocationMethodStatic AllocationMethod = "Static" +) + +// PossibleAllocationMethodValues returns the possible values for the AllocationMethod const type. +func PossibleAllocationMethodValues() []AllocationMethod { + return []AllocationMethod{ + AllocationMethodDynamic, + AllocationMethodStatic, + } +} + +// CreateDiffDisk - Gets or sets a value indicating diff disk. +type CreateDiffDisk string + +const ( + CreateDiffDiskFalse CreateDiffDisk = "false" + CreateDiffDiskTrue CreateDiffDisk = "true" +) + +// PossibleCreateDiffDiskValues returns the possible values for the CreateDiffDisk const type. +func PossibleCreateDiffDiskValues() []CreateDiffDisk { + return []CreateDiffDisk{ + CreateDiffDiskFalse, + CreateDiffDiskTrue, + } +} + +// 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, + } +} + +// DynamicMemoryEnabled - Gets or sets a value indicating whether to enable dynamic memory or not. +type DynamicMemoryEnabled string + +const ( + DynamicMemoryEnabledFalse DynamicMemoryEnabled = "false" + DynamicMemoryEnabledTrue DynamicMemoryEnabled = "true" +) + +// PossibleDynamicMemoryEnabledValues returns the possible values for the DynamicMemoryEnabled const type. +func PossibleDynamicMemoryEnabledValues() []DynamicMemoryEnabled { + return []DynamicMemoryEnabled{ + DynamicMemoryEnabledFalse, + DynamicMemoryEnabledTrue, + } +} + +// InventoryType - The inventory type. +type InventoryType string + +const ( + InventoryTypeCloud InventoryType = "Cloud" + InventoryTypeVirtualMachine InventoryType = "VirtualMachine" + InventoryTypeVirtualMachineTemplate InventoryType = "VirtualMachineTemplate" + InventoryTypeVirtualNetwork InventoryType = "VirtualNetwork" +) + +// PossibleInventoryTypeValues returns the possible values for the InventoryType const type. +func PossibleInventoryTypeValues() []InventoryType { + return []InventoryType{ + InventoryTypeCloud, + InventoryTypeVirtualMachine, + InventoryTypeVirtualMachineTemplate, + InventoryTypeVirtualNetwork, + } +} + +// IsCustomizable - Gets or sets a value indicating whether the vm template is customizable or not. +type IsCustomizable string + +const ( + IsCustomizableFalse IsCustomizable = "false" + IsCustomizableTrue IsCustomizable = "true" +) + +// PossibleIsCustomizableValues returns the possible values for the IsCustomizable const type. +func PossibleIsCustomizableValues() []IsCustomizable { + return []IsCustomizable{ + IsCustomizableFalse, + IsCustomizableTrue, + } +} + +// LimitCPUForMigration - Gets or sets a value indicating whether to enable processor compatibility mode for live migration +// of VMs. +type LimitCPUForMigration string + +const ( + LimitCPUForMigrationFalse LimitCPUForMigration = "false" + LimitCPUForMigrationTrue LimitCPUForMigration = "true" +) + +// PossibleLimitCPUForMigrationValues returns the possible values for the LimitCPUForMigration const type. +func PossibleLimitCPUForMigrationValues() []LimitCPUForMigration { + return []LimitCPUForMigration{ + LimitCPUForMigrationFalse, + LimitCPUForMigrationTrue, + } +} + +// OsType - Defines the different types of VM guest operating systems. +type OsType string + +const ( + OsTypeLinux OsType = "Linux" + OsTypeOther OsType = "Other" + OsTypeWindows OsType = "Windows" +) + +// PossibleOsTypeValues returns the possible values for the OsType const type. +func PossibleOsTypeValues() []OsType { + return []OsType{ + OsTypeLinux, + OsTypeOther, + OsTypeWindows, + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_inventoryitems_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_inventoryitems_client.go new file mode 100644 index 000000000000..bcf2cdd0b3c1 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_inventoryitems_client.go @@ -0,0 +1,298 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "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" +) + +// InventoryItemsClient contains the methods for the InventoryItems group. +// Don't use this type directly, use NewInventoryItemsClient() instead. +type InventoryItemsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewInventoryItemsClient creates a new instance of InventoryItemsClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewInventoryItemsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InventoryItemsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &InventoryItemsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Create - Create Or Update InventoryItem. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// inventoryItemName - Name of the inventoryItem. +// options - InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. +func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientCreateOptions) (InventoryItemsClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemName, options) + if err != nil { + return InventoryItemsClientCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return InventoryItemsClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return InventoryItemsClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *InventoryItemsClient) createCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + if inventoryItemName == "" { + return nil, errors.New("parameter inventoryItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *InventoryItemsClient) createHandleResponse(resp *http.Response) (InventoryItemsClientCreateResponse, error) { + result := InventoryItemsClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InventoryItem); err != nil { + return InventoryItemsClientCreateResponse{}, err + } + return result, nil +} + +// Delete - Deletes an inventoryItem. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// inventoryItemName - Name of the inventoryItem. +// options - InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. +func (client *InventoryItemsClient) Delete(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientDeleteOptions) (InventoryItemsClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemName, options) + if err != nil { + return InventoryItemsClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return InventoryItemsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return InventoryItemsClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return InventoryItemsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + if inventoryItemName == "" { + return nil, errors.New("parameter inventoryItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Shows an inventory item. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// inventoryItemName - Name of the inventoryItem. +// options - InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. +func (client *InventoryItemsClient) Get(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientGetOptions) (InventoryItemsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemName, options) + if err != nil { + return InventoryItemsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return InventoryItemsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return InventoryItemsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *InventoryItemsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + if inventoryItemName == "" { + return nil, errors.New("parameter inventoryItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *InventoryItemsClient) getHandleResponse(resp *http.Response) (InventoryItemsClientGetResponse, error) { + result := InventoryItemsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InventoryItem); err != nil { + return InventoryItemsClientGetResponse{}, err + } + return result, nil +} + +// NewListByVMMServerPager - Returns the list of inventoryItems in the given VMMServer. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// options - InventoryItemsClientListByVMMServerOptions contains the optional parameters for the InventoryItemsClient.ListByVMMServer +// method. +func (client *InventoryItemsClient) NewListByVMMServerPager(resourceGroupName string, vmmServerName string, options *InventoryItemsClientListByVMMServerOptions) *runtime.Pager[InventoryItemsClientListByVMMServerResponse] { + return runtime.NewPager(runtime.PageProcessor[InventoryItemsClientListByVMMServerResponse]{ + More: func(page InventoryItemsClientListByVMMServerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *InventoryItemsClientListByVMMServerResponse) (InventoryItemsClientListByVMMServerResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByVMMServerCreateRequest(ctx, resourceGroupName, vmmServerName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return InventoryItemsClientListByVMMServerResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return InventoryItemsClientListByVMMServerResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return InventoryItemsClientListByVMMServerResponse{}, runtime.NewResponseError(resp) + } + return client.listByVMMServerHandleResponse(resp) + }, + }) +} + +// listByVMMServerCreateRequest creates the ListByVMMServer request. +func (client *InventoryItemsClient) listByVMMServerCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, options *InventoryItemsClientListByVMMServerOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByVMMServerHandleResponse handles the ListByVMMServer response. +func (client *InventoryItemsClient) listByVMMServerHandleResponse(resp *http.Response) (InventoryItemsClientListByVMMServerResponse, error) { + result := InventoryItemsClientListByVMMServerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InventoryItemsList); err != nil { + return InventoryItemsClientListByVMMServerResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_models.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_models.go new file mode 100644 index 000000000000..7f29b438a3bb --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_models.go @@ -0,0 +1,1346 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import "time" + +// AvailabilitySet - The AvailabilitySets resource definition. +type AvailabilitySet struct { + // The extended location. + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + + // Gets or sets the location. + Location *string `json:"location,omitempty"` + + // Resource properties. + Properties *AvailabilitySetProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// AvailabilitySetListItem - Availability Set model +type AvailabilitySetListItem struct { + // Gets the ARM Id of the microsoft.scvmm/availabilitySets resource. + ID *string `json:"id,omitempty"` + + // Gets or sets the name of the availability set. + Name *string `json:"name,omitempty"` +} + +// AvailabilitySetListResult - List of AvailabilitySets. +type AvailabilitySetListResult struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of AvailabilitySets. + Value []*AvailabilitySet `json:"value,omitempty"` +} + +// AvailabilitySetProperties - Defines the resource properties. +type AvailabilitySetProperties struct { + // Name of the availability set. + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + + // ARM Id of the vmmServer resource in which this resource resides. + VmmServerID *string `json:"vmmServerId,omitempty"` + + // READ-ONLY; Gets or sets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// AvailabilitySetsClientBeginCreateOrUpdateOptions contains the optional parameters for the AvailabilitySetsClient.BeginCreateOrUpdate +// method. +type AvailabilitySetsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AvailabilitySetsClientBeginDeleteOptions contains the optional parameters for the AvailabilitySetsClient.BeginDelete method. +type AvailabilitySetsClientBeginDeleteOptions struct { + // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. + Force *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AvailabilitySetsClientBeginUpdateOptions contains the optional parameters for the AvailabilitySetsClient.BeginUpdate method. +type AvailabilitySetsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AvailabilitySetsClientGetOptions contains the optional parameters for the AvailabilitySetsClient.Get method. +type AvailabilitySetsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AvailabilitySetsClientListByResourceGroupOptions contains the optional parameters for the AvailabilitySetsClient.ListByResourceGroup +// method. +type AvailabilitySetsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AvailabilitySetsClientListBySubscriptionOptions contains the optional parameters for the AvailabilitySetsClient.ListBySubscription +// method. +type AvailabilitySetsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// Checkpoint - Defines the resource properties. +type Checkpoint struct { + // Gets ID of the checkpoint. + CheckpointID *string `json:"checkpointID,omitempty"` + + // Gets description of the checkpoint. + Description *string `json:"description,omitempty"` + + // Gets name of the checkpoint. + Name *string `json:"name,omitempty"` + + // Gets ID of parent of the checkpoint. + ParentCheckpointID *string `json:"parentCheckpointID,omitempty"` +} + +// Cloud - The Clouds resource definition. +type Cloud struct { + // REQUIRED; The extended location. + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + + // REQUIRED; Gets or sets the location. + Location *string `json:"location,omitempty"` + + // REQUIRED; Resource properties. + Properties *CloudProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CloudCapacity - Cloud Capacity model +type CloudCapacity struct { + // CPUCount specifies the maximum number of CPUs that can be allocated in the cloud. + CPUCount *int64 `json:"cpuCount,omitempty"` + + // MemoryMB specifies a memory usage limit in megabytes. + MemoryMB *int64 `json:"memoryMB,omitempty"` + + // VMCount gives the max number of VMs that can be deployed in the cloud. + VMCount *int64 `json:"vmCount,omitempty"` +} + +// CloudInventoryItem - The Cloud inventory item. +type CloudInventoryItem struct { + // REQUIRED; They inventory type. + InventoryType *InventoryType `json:"inventoryType,omitempty"` + + // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + InventoryItemName *string `json:"inventoryItemName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. + ManagedResourceID *string `json:"managedResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + UUID *string `json:"uuid,omitempty" azure:"ro"` +} + +// CloudListResult - List of Clouds. +type CloudListResult struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of Clouds. + Value []*Cloud `json:"value,omitempty"` +} + +// CloudProperties - Defines the resource properties. +type CloudProperties struct { + // Gets or sets the inventory Item ID for the resource. + InventoryItemID *string `json:"inventoryItemId,omitempty"` + + // Unique ID of the cloud. + UUID *string `json:"uuid,omitempty"` + + // ARM Id of the vmmServer resource in which this resource resides. + VmmServerID *string `json:"vmmServerId,omitempty"` + + // READ-ONLY; Capacity of the cloud. + CloudCapacity *CloudCapacity `json:"cloudCapacity,omitempty" azure:"ro"` + + // READ-ONLY; Name of the cloud in VMMServer. + CloudName *string `json:"cloudName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; List of QoS policies available for the cloud. + StorageQoSPolicies []*StorageQoSPolicy `json:"storageQoSPolicies,omitempty" azure:"ro"` +} + +// CloudsClientBeginCreateOrUpdateOptions contains the optional parameters for the CloudsClient.BeginCreateOrUpdate method. +type CloudsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CloudsClientBeginDeleteOptions contains the optional parameters for the CloudsClient.BeginDelete method. +type CloudsClientBeginDeleteOptions struct { + // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. + Force *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CloudsClientBeginUpdateOptions contains the optional parameters for the CloudsClient.BeginUpdate method. +type CloudsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CloudsClientGetOptions contains the optional parameters for the CloudsClient.Get method. +type CloudsClientGetOptions struct { + // placeholder for future optional parameters +} + +// CloudsClientListByResourceGroupOptions contains the optional parameters for the CloudsClient.ListByResourceGroup method. +type CloudsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CloudsClientListBySubscriptionOptions contains the optional parameters for the CloudsClient.ListBySubscription method. +type CloudsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ErrorDefinition - Error definition. +type ErrorDefinition struct { + // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Internal error details. + Details []*ErrorDefinition `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; Description of the error. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// ErrorResponse - Error response. +type ErrorResponse struct { + // The error details. + Error *ErrorDefinition `json:"error,omitempty"` +} + +// ExtendedLocation - The extended location. +type ExtendedLocation struct { + // The extended location name. + Name *string `json:"name,omitempty"` + + // The extended location type. + Type *string `json:"type,omitempty"` +} + +// HardwareProfile - Defines the resource properties. +type HardwareProfile struct { + // Gets or sets the number of vCPUs for the vm. + CPUCount *int32 `json:"cpuCount,omitempty"` + + // Gets or sets a value indicating whether to enable dynamic memory or not. + DynamicMemoryEnabled *DynamicMemoryEnabled `json:"dynamicMemoryEnabled,omitempty"` + + // Gets or sets the max dynamic memory for the vm. + DynamicMemoryMaxMB *int32 `json:"dynamicMemoryMaxMB,omitempty"` + + // Gets or sets the min dynamic memory for the vm. + DynamicMemoryMinMB *int32 `json:"dynamicMemoryMinMB,omitempty"` + + // Gets highly available property. + IsHighlyAvailable *string `json:"isHighlyAvailable,omitempty"` + + // Gets or sets a value indicating whether to enable processor compatibility mode for live migration of VMs. + LimitCPUForMigration *LimitCPUForMigration `json:"limitCpuForMigration,omitempty"` + + // MemoryMB is the size of a virtual machine's memory, in MB. + MemoryMB *int32 `json:"memoryMB,omitempty"` +} + +// HardwareProfileUpdate - Defines the resource properties. +type HardwareProfileUpdate struct { + // Gets or sets the number of vCPUs for the vm. + CPUCount *int32 `json:"cpuCount,omitempty"` + + // Gets or sets a value indicating whether to enable dynamic memory or not. + DynamicMemoryEnabled *DynamicMemoryEnabled `json:"dynamicMemoryEnabled,omitempty"` + + // Gets or sets the max dynamic memory for the vm. + DynamicMemoryMaxMB *int32 `json:"dynamicMemoryMaxMB,omitempty"` + + // Gets or sets the min dynamic memory for the vm. + DynamicMemoryMinMB *int32 `json:"dynamicMemoryMinMB,omitempty"` + + // Gets or sets a value indicating whether to enable processor compatibility mode for live migration of VMs. + LimitCPUForMigration *LimitCPUForMigration `json:"limitCpuForMigration,omitempty"` + + // MemoryMB is the size of a virtual machine's memory, in MB. + MemoryMB *int32 `json:"memoryMB,omitempty"` +} + +// InventoryItem - Defines the inventory item. +type InventoryItem struct { + // REQUIRED; Resource properties. + Properties InventoryItemPropertiesClassification `json:"properties,omitempty"` + + // Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are + // a kind of Microsoft.Web/sites type. If supported, the resource provider must + // validate and persist this value. + Kind *string `json:"kind,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"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,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"` +} + +// InventoryItemDetails - Defines the resource properties. +type InventoryItemDetails struct { + // Gets or sets the inventory Item ID for the resource. + InventoryItemID *string `json:"inventoryItemId,omitempty"` + + // Gets or sets the Managed Object name in VMM for the resource. + InventoryItemName *string `json:"inventoryItemName,omitempty"` +} + +// InventoryItemPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetInventoryItemProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *CloudInventoryItem, *InventoryItemProperties, *VirtualMachineInventoryItem, *VirtualMachineTemplateInventoryItem, *VirtualNetworkInventoryItem +type InventoryItemPropertiesClassification interface { + // GetInventoryItemProperties returns the InventoryItemProperties content of the underlying type. + GetInventoryItemProperties() *InventoryItemProperties +} + +// InventoryItemProperties - Defines the resource properties. +type InventoryItemProperties struct { + // REQUIRED; They inventory type. + InventoryType *InventoryType `json:"inventoryType,omitempty"` + + // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + InventoryItemName *string `json:"inventoryItemName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. + ManagedResourceID *string `json:"managedResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + UUID *string `json:"uuid,omitempty" azure:"ro"` +} + +// InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. +type InventoryItemsClientCreateOptions struct { + // Request payload. + Body *InventoryItem +} + +// InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. +type InventoryItemsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. +type InventoryItemsClientGetOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsClientListByVMMServerOptions contains the optional parameters for the InventoryItemsClient.ListByVMMServer +// method. +type InventoryItemsClientListByVMMServerOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsList - List of InventoryItems. +type InventoryItemsList struct { + // REQUIRED; Array of InventoryItems + Value []*InventoryItem `json:"value,omitempty"` + + // Url to follow for getting next page of InventoryItems. + NextLink *string `json:"nextLink,omitempty"` +} + +// NetworkInterfaces - Network Interface model +type NetworkInterfaces struct { + // Gets or sets the ipv4 address type. + IPv4AddressType *AllocationMethod `json:"ipv4AddressType,omitempty"` + + // Gets or sets the ipv6 address type. + IPv6AddressType *AllocationMethod `json:"ipv6AddressType,omitempty"` + + // Gets or sets the nic MAC address. + MacAddress *string `json:"macAddress,omitempty"` + + // Gets or sets the mac address type. + MacAddressType *AllocationMethod `json:"macAddressType,omitempty"` + + // Gets or sets the name of the network interface. + Name *string `json:"name,omitempty"` + + // Gets or sets the nic id. + NicID *string `json:"nicId,omitempty"` + + // Gets or sets the ARM Id of the Microsoft.ScVmm/virtualNetwork resource to connect the nic. + VirtualNetworkID *string `json:"virtualNetworkId,omitempty"` + + // READ-ONLY; Gets the display name of the network interface as shown in the vmmServer. This is the fallback label for a NIC + // when the name is not set. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the nic ipv4 addresses. + IPv4Addresses []*string `json:"ipv4Addresses,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the nic ipv6 addresses. + IPv6Addresses []*string `json:"ipv6Addresses,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the name of the virtual network in vmmServer that the nic is connected to. + NetworkName *string `json:"networkName,omitempty" azure:"ro"` +} + +// NetworkInterfacesUpdate - Network Interface model +type NetworkInterfacesUpdate struct { + // Gets or sets the ipv4 address type. + IPv4AddressType *AllocationMethod `json:"ipv4AddressType,omitempty"` + + // Gets or sets the ipv6 address type. + IPv6AddressType *AllocationMethod `json:"ipv6AddressType,omitempty"` + + // Gets or sets the nic MAC address. + MacAddress *string `json:"macAddress,omitempty"` + + // Gets or sets the mac address type. + MacAddressType *AllocationMethod `json:"macAddressType,omitempty"` + + // Gets or sets the name of the network interface. + Name *string `json:"name,omitempty"` + + // Gets or sets the nic id. + NicID *string `json:"nicId,omitempty"` + + // Gets or sets the ARM Id of the Microsoft.ScVmm/virtualNetwork resource to connect the nic. + VirtualNetworkID *string `json:"virtualNetworkId,omitempty"` +} + +// NetworkProfile - Defines the resource properties. +type NetworkProfile struct { + // Gets or sets the list of network interfaces associated with the virtual machine. + NetworkInterfaces []*NetworkInterfaces `json:"networkInterfaces,omitempty"` +} + +// NetworkProfileUpdate - Defines the resource properties. +type NetworkProfileUpdate struct { + // Gets or sets the list of network interfaces associated with the virtual machine. + NetworkInterfaces []*NetworkInterfacesUpdate `json:"networkInterfaces,omitempty"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OsProfile - Defines the resource properties. +type OsProfile struct { + // Admin password of the virtual machine. + AdminPassword *string `json:"adminPassword,omitempty"` + + // Gets or sets computer name. + ComputerName *string `json:"computerName,omitempty"` + + // READ-ONLY; Gets or sets os name. + OSName *string `json:"osName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the type of the os. + OSType *OsType `json:"osType,omitempty" azure:"ro"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // 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"` +} + +// 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"` +} + +// ResourcePatch - Object containing tags updates for patch operations. +type ResourcePatch struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// ResourceProviderOperation - Results of the request to list operations. +type ResourceProviderOperation struct { + // Display metadata associated with the operation. + Display *ResourceProviderOperationDisplay `json:"display,omitempty"` + + // Indicates whether the operation applies to data-plane. + IsDataAction *string `json:"isDataAction,omitempty"` + + // Operation name, in format of {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` +} + +// ResourceProviderOperationDisplay - Display metadata associated with the operation. +type ResourceProviderOperationDisplay struct { + // Description of this operation. + Description *string `json:"description,omitempty"` + + // Type of operation: read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // The resource provider. + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// ResourceProviderOperationList - Results of the request to list operations. +type ResourceProviderOperationList struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of Operations. + Value []*ResourceProviderOperation `json:"value,omitempty"` +} + +// StopVirtualMachineOptions - Defines the stop action properties. +type StopVirtualMachineOptions struct { + // Gets or sets a value indicating whether to request non-graceful VM shutdown. True value for this flag indicates non-graceful + // shutdown whereas false indicates otherwise. Defaults to false. + SkipShutdown *bool `json:"skipShutdown,omitempty"` +} + +// StorageProfile - Defines the resource properties. +type StorageProfile struct { + // Gets or sets the list of virtual disks associated with the virtual machine. + Disks []*VirtualDisk `json:"disks,omitempty"` +} + +// StorageProfileUpdate - Defines the resource properties. +type StorageProfileUpdate struct { + // Gets or sets the list of virtual disks associated with the virtual machine. + Disks []*VirtualDiskUpdate `json:"disks,omitempty"` +} + +// StorageQoSPolicy - The StorageQoSPolicy definition. +type StorageQoSPolicy struct { + // The Bandwidth Limit for internet traffic. + BandwidthLimit *int64 `json:"bandwidthLimit,omitempty"` + + // The ID of the QoS policy. + ID *string `json:"id,omitempty"` + + // The maximum IO operations per second. + IopsMaximum *int64 `json:"iopsMaximum,omitempty"` + + // The minimum IO operations per second. + IopsMinimum *int64 `json:"iopsMinimum,omitempty"` + + // The name of the policy. + Name *string `json:"name,omitempty"` + + // The underlying policy. + PolicyID *string `json:"policyId,omitempty"` +} + +// StorageQoSPolicyDetails - The StorageQoSPolicyDetails definition. +type StorageQoSPolicyDetails struct { + // The ID of the QoS policy. + ID *string `json:"id,omitempty"` + + // The name of the policy. + Name *string `json:"name,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"` +} + +// VMMServer - The VmmServers resource definition. +type VMMServer struct { + // REQUIRED; The extended location. + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + + // REQUIRED; Gets or sets the location. + Location *string `json:"location,omitempty"` + + // REQUIRED; Resource properties. + Properties *VMMServerProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VMMServerListResult - List of VmmServers. +type VMMServerListResult struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of VmmServers. + Value []*VMMServer `json:"value,omitempty"` +} + +// VMMServerProperties - Defines the resource properties. +type VMMServerProperties struct { + // REQUIRED; Fqdn is the hostname/ip of the vmmServer. + Fqdn *string `json:"fqdn,omitempty"` + + // Credentials to connect to VMMServer. + Credentials *VMMServerPropertiesCredentials `json:"credentials,omitempty"` + + // Port is the port on which the vmmServer is listening. + Port *int32 `json:"port,omitempty"` + + // READ-ONLY; Gets or sets the connection status to the vmmServer. + ConnectionStatus *string `json:"connectionStatus,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets any error message if connection to vmmServer is having any issue. + ErrorMessage *string `json:"errorMessage,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Unique ID of vmmServer. + UUID *string `json:"uuid,omitempty" azure:"ro"` + + // READ-ONLY; Version is the version of the vmmSever. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// VMMServerPropertiesCredentials - Credentials to connect to VMMServer. +type VMMServerPropertiesCredentials struct { + // Credentials to use to connect to VMMServer. + Password *string `json:"password,omitempty"` + + // Username to use to connect to VMMServer. + Username *string `json:"username,omitempty"` +} + +// VirtualDisk - Virtual disk model +type VirtualDisk struct { + // Gets or sets the disk bus. + Bus *int32 `json:"bus,omitempty"` + + // Gets or sets the disk bus type. + BusType *string `json:"busType,omitempty"` + + // Gets or sets a value indicating diff disk. + CreateDiffDisk *CreateDiffDisk `json:"createDiffDisk,omitempty"` + + // Gets or sets the disk id. + DiskID *string `json:"diskId,omitempty"` + + // Gets or sets the disk total size. + DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` + + // Gets or sets the disk lun. + Lun *int32 `json:"lun,omitempty"` + + // Gets or sets the name of the disk. + Name *string `json:"name,omitempty"` + + // The QoS policy for the disk. + StorageQoSPolicy *StorageQoSPolicyDetails `json:"storageQoSPolicy,omitempty"` + + // Gets or sets the disk id in the template. + TemplateDiskID *string `json:"templateDiskId,omitempty"` + + // Gets or sets the disk vhd type. + VhdType *string `json:"vhdType,omitempty"` + + // READ-ONLY; Gets the display name of the virtual disk as shown in the vmmServer. This is the fallback label for a disk when + // the name is not set. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the max disk size. + MaxDiskSizeGB *int32 `json:"maxDiskSizeGB,omitempty" azure:"ro"` + + // READ-ONLY; Gets the disk vhd format type. + VhdFormatType *string `json:"vhdFormatType,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the disk volume type. + VolumeType *string `json:"volumeType,omitempty" azure:"ro"` +} + +// VirtualDiskUpdate - Virtual disk model +type VirtualDiskUpdate struct { + // Gets or sets the disk bus. + Bus *int32 `json:"bus,omitempty"` + + // Gets or sets the disk bus type. + BusType *string `json:"busType,omitempty"` + + // Gets or sets the disk id. + DiskID *string `json:"diskId,omitempty"` + + // Gets or sets the disk total size. + DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` + + // Gets or sets the disk lun. + Lun *int32 `json:"lun,omitempty"` + + // Gets or sets the name of the disk. + Name *string `json:"name,omitempty"` + + // The QoS policy for the disk. + StorageQoSPolicy *StorageQoSPolicyDetails `json:"storageQoSPolicy,omitempty"` + + // Gets or sets the disk vhd type. + VhdType *string `json:"vhdType,omitempty"` +} + +// VirtualMachine - The VirtualMachines resource definition. +type VirtualMachine struct { + // REQUIRED; The extended location. + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + + // REQUIRED; Gets or sets the location. + Location *string `json:"location,omitempty"` + + // REQUIRED; Resource properties. + Properties *VirtualMachineProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VirtualMachineCreateCheckpoint - Defines the create checkpoint action properties. +type VirtualMachineCreateCheckpoint struct { + // Description of the checkpoint. + Description *string `json:"description,omitempty"` + + // Name of the checkpoint. + Name *string `json:"name,omitempty"` +} + +// VirtualMachineDeleteCheckpoint - Defines the delete checkpoint action properties. +type VirtualMachineDeleteCheckpoint struct { + // ID of the checkpoint to be deleted. + ID *string `json:"id,omitempty"` +} + +// VirtualMachineInventoryItem - The Virtual machine inventory item. +type VirtualMachineInventoryItem struct { + // REQUIRED; They inventory type. + InventoryType *InventoryType `json:"inventoryType,omitempty"` + + // Cloud inventory resource details where the VM is present. + Cloud *InventoryItemDetails `json:"cloud,omitempty"` + + // Gets or sets the nic ip addresses. + IPAddresses []*string `json:"ipAddresses,omitempty"` + + // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + InventoryItemName *string `json:"inventoryItemName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. + ManagedResourceID *string `json:"managedResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets os name. + OSName *string `json:"osName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the type of the os. + OSType *OsType `json:"osType,omitempty" azure:"ro"` + + // READ-ONLY; Gets the power state of the virtual machine. + PowerState *string `json:"powerState,omitempty" azure:"ro"` + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + UUID *string `json:"uuid,omitempty" azure:"ro"` +} + +// VirtualMachineListResult - List of VirtualMachines. +type VirtualMachineListResult struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of VirtualMachines. + Value []*VirtualMachine `json:"value,omitempty"` +} + +// VirtualMachineProperties - Defines the resource properties. +type VirtualMachineProperties struct { + // Availability Sets in vm. + AvailabilitySets []*AvailabilitySetListItem `json:"availabilitySets,omitempty"` + + // Type of checkpoint supported for the vm. + CheckpointType *string `json:"checkpointType,omitempty"` + + // Checkpoints in the vm. + Checkpoints []*Checkpoint `json:"checkpoints,omitempty"` + + // ARM Id of the cloud resource to use for deploying the vm. + CloudID *string `json:"cloudId,omitempty"` + + // Gets or sets the generation for the vm. + Generation *int32 `json:"generation,omitempty"` + + // Hardware properties. + HardwareProfile *HardwareProfile `json:"hardwareProfile,omitempty"` + + // Gets or sets the inventory Item ID for the resource. + InventoryItemID *string `json:"inventoryItemId,omitempty"` + + // Network properties. + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + + // OS properties. + OSProfile *OsProfile `json:"osProfile,omitempty"` + + // Storage properties. + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + + // ARM Id of the template resource to use for deploying the vm. + TemplateID *string `json:"templateId,omitempty"` + + // Unique ID of the virtual machine. + UUID *string `json:"uuid,omitempty"` + + // VMName is the name of VM on the SCVMM server. + VMName *string `json:"vmName,omitempty"` + + // ARM Id of the vmmServer resource in which this resource resides. + VmmServerID *string `json:"vmmServerId,omitempty"` + + // READ-ONLY; Gets the power state of the virtual machine. + PowerState *string `json:"powerState,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// VirtualMachineRestoreCheckpoint - Defines the restore checkpoint action properties. +type VirtualMachineRestoreCheckpoint struct { + // ID of the checkpoint to be restored to. + ID *string `json:"id,omitempty"` +} + +// VirtualMachineTemplate - The VirtualMachineTemplates resource definition. +type VirtualMachineTemplate struct { + // REQUIRED; The extended location. + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + + // REQUIRED; Gets or sets the location. + Location *string `json:"location,omitempty"` + + // REQUIRED; Resource properties. + Properties *VirtualMachineTemplateProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VirtualMachineTemplateInventoryItem - The Virtual machine template inventory item. +type VirtualMachineTemplateInventoryItem struct { + // REQUIRED; They inventory type. + InventoryType *InventoryType `json:"inventoryType,omitempty"` + + // READ-ONLY; Gets or sets the desired number of vCPUs for the vm. + CPUCount *int32 `json:"cpuCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + InventoryItemName *string `json:"inventoryItemName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. + ManagedResourceID *string `json:"managedResourceId,omitempty" azure:"ro"` + + // READ-ONLY; MemoryMB is the desired size of a virtual machine's memory, in MB. + MemoryMB *int32 `json:"memoryMB,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets os name. + OSName *string `json:"osName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the type of the os. + OSType *OsType `json:"osType,omitempty" azure:"ro"` + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + UUID *string `json:"uuid,omitempty" azure:"ro"` +} + +// VirtualMachineTemplateListResult - List of VirtualMachineTemplates. +type VirtualMachineTemplateListResult struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of VirtualMachineTemplates. + Value []*VirtualMachineTemplate `json:"value,omitempty"` +} + +// VirtualMachineTemplateProperties - Defines the resource properties. +type VirtualMachineTemplateProperties struct { + // Gets or sets the inventory Item ID for the resource. + InventoryItemID *string `json:"inventoryItemId,omitempty"` + + // Unique ID of the virtual machine template. + UUID *string `json:"uuid,omitempty"` + + // ARM Id of the vmmServer resource in which this resource resides. + VmmServerID *string `json:"vmmServerId,omitempty"` + + // READ-ONLY; Gets or sets the desired number of vCPUs for the vm. + CPUCount *int32 `json:"cpuCount,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets computer name. + ComputerName *string `json:"computerName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the disks of the template. + Disks []*VirtualDisk `json:"disks,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets a value indicating whether to enable dynamic memory or not. + DynamicMemoryEnabled *DynamicMemoryEnabled `json:"dynamicMemoryEnabled,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the max dynamic memory for the vm. + DynamicMemoryMaxMB *int32 `json:"dynamicMemoryMaxMB,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the min dynamic memory for the vm. + DynamicMemoryMinMB *int32 `json:"dynamicMemoryMinMB,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the generation for the vm. + Generation *int32 `json:"generation,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets a value indicating whether the vm template is customizable or not. + IsCustomizable *IsCustomizable `json:"isCustomizable,omitempty" azure:"ro"` + + // READ-ONLY; Gets highly available property. + IsHighlyAvailable *string `json:"isHighlyAvailable,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets a value indicating whether to enable processor compatibility mode for live migration of VMs. + LimitCPUForMigration *LimitCPUForMigration `json:"limitCpuForMigration,omitempty" azure:"ro"` + + // READ-ONLY; MemoryMB is the desired size of a virtual machine's memory, in MB. + MemoryMB *int32 `json:"memoryMB,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the network interfaces of the template. + NetworkInterfaces []*NetworkInterfaces `json:"networkInterfaces,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets os name. + OSName *string `json:"osName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the type of the os. + OSType *OsType `json:"osType,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// VirtualMachineTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreateOrUpdate +// method. +type VirtualMachineTemplatesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete +// method. +type VirtualMachineTemplatesClientBeginDeleteOptions struct { + // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. + Force *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginUpdate +// method. +type VirtualMachineTemplatesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get method. +type VirtualMachineTemplatesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.ListByResourceGroup +// method. +type VirtualMachineTemplatesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineTemplatesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachineTemplatesClient.ListBySubscription +// method. +type VirtualMachineTemplatesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineUpdate - Defines the virtualMachineUpdate. +type VirtualMachineUpdate struct { + // Defines the resource properties. + Properties *VirtualMachineUpdateProperties `json:"properties,omitempty"` + + // Gets or sets the Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// VirtualMachineUpdateProperties - Defines the resource properties. +type VirtualMachineUpdateProperties struct { + // Availability Sets in vm. + AvailabilitySets []*AvailabilitySetListItem `json:"availabilitySets,omitempty"` + + // Defines the resource properties. + HardwareProfile *HardwareProfileUpdate `json:"hardwareProfile,omitempty"` + + // Defines the resource properties. + NetworkProfile *NetworkProfileUpdate `json:"networkProfile,omitempty"` + + // Defines the resource properties. + StorageProfile *StorageProfileUpdate `json:"storageProfile,omitempty"` +} + +// VirtualMachinesClientBeginCreateCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateCheckpoint +// method. +type VirtualMachinesClientBeginCreateCheckpointOptions struct { + // Virtualmachine create checkpoint action payload. + Body *VirtualMachineCreateCheckpoint + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate +// method. +type VirtualMachinesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginDeleteCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginDeleteCheckpoint +// method. +type VirtualMachinesClientBeginDeleteCheckpointOptions struct { + // Virtualmachine delete checkpoint action payload. + Body *VirtualMachineDeleteCheckpoint + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete method. +type VirtualMachinesClientBeginDeleteOptions struct { + // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. + Force *bool + // Resumes the LRO from the provided token. + ResumeToken string + // Whether to just disable the VM from azure and retain the VM in the VMM. + Retain *bool +} + +// VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart method. +type VirtualMachinesClientBeginRestartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginRestoreCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginRestoreCheckpoint +// method. +type VirtualMachinesClientBeginRestoreCheckpointOptions struct { + // Virtualmachine restore checkpoint action payload. + Body *VirtualMachineRestoreCheckpoint + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart method. +type VirtualMachinesClientBeginStartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop method. +type VirtualMachinesClientBeginStopOptions struct { + // Virtualmachine stop action payload. + Body *StopVirtualMachineOptions + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate method. +type VirtualMachinesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +type VirtualMachinesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.ListByResourceGroup +// method. +type VirtualMachinesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.ListBySubscription +// method. +type VirtualMachinesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetwork - The VirtualNetworks resource definition. +type VirtualNetwork struct { + // REQUIRED; The extended location. + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + + // REQUIRED; Gets or sets the location. + Location *string `json:"location,omitempty"` + + // REQUIRED; Resource properties. + Properties *VirtualNetworkProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VirtualNetworkInventoryItem - The Virtual network inventory item. +type VirtualNetworkInventoryItem struct { + // REQUIRED; They inventory type. + InventoryType *InventoryType `json:"inventoryType,omitempty"` + + // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + InventoryItemName *string `json:"inventoryItemName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. + ManagedResourceID *string `json:"managedResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + UUID *string `json:"uuid,omitempty" azure:"ro"` +} + +// VirtualNetworkListResult - List of VirtualNetworks. +type VirtualNetworkListResult struct { + // Url to follow for getting next page of resources. + NextLink *string `json:"nextLink,omitempty"` + + // List of VirtualNetworks. + Value []*VirtualNetwork `json:"value,omitempty"` +} + +// VirtualNetworkProperties - Defines the resource properties. +type VirtualNetworkProperties struct { + // Gets or sets the inventory Item ID for the resource. + InventoryItemID *string `json:"inventoryItemId,omitempty"` + + // Unique ID of the virtual network. + UUID *string `json:"uuid,omitempty"` + + // ARM Id of the vmmServer resource in which this resource resides. + VmmServerID *string `json:"vmmServerId,omitempty"` + + // READ-ONLY; Name of the virtual network in vmmServer. + NetworkName *string `json:"networkName,omitempty" azure:"ro"` + + // READ-ONLY; Gets or sets the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate +// method. +type VirtualNetworksClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete method. +type VirtualNetworksClientBeginDeleteOptions struct { + // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. + Force *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginUpdate method. +type VirtualNetworksClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. +type VirtualNetworksClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.ListByResourceGroup +// method. +type VirtualNetworksClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientListBySubscriptionOptions contains the optional parameters for the VirtualNetworksClient.ListBySubscription +// method. +type VirtualNetworksClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VmmServersClientBeginCreateOrUpdateOptions contains the optional parameters for the VmmServersClient.BeginCreateOrUpdate +// method. +type VmmServersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VmmServersClientBeginDeleteOptions contains the optional parameters for the VmmServersClient.BeginDelete method. +type VmmServersClientBeginDeleteOptions struct { + // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. + Force *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VmmServersClientBeginUpdateOptions contains the optional parameters for the VmmServersClient.BeginUpdate method. +type VmmServersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VmmServersClientGetOptions contains the optional parameters for the VmmServersClient.Get method. +type VmmServersClientGetOptions struct { + // placeholder for future optional parameters +} + +// VmmServersClientListByResourceGroupOptions contains the optional parameters for the VmmServersClient.ListByResourceGroup +// method. +type VmmServersClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VmmServersClientListBySubscriptionOptions contains the optional parameters for the VmmServersClient.ListBySubscription +// method. +type VmmServersClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_models_serde.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_models_serde.go new file mode 100644 index 000000000000..b19e4eda6e84 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_models_serde.go @@ -0,0 +1,667 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AvailabilitySet. +func (a AvailabilitySet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", a.ExtendedLocation) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type AvailabilitySetListResult. +func (a AvailabilitySetListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type Cloud. +func (c Cloud) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", c.ExtendedLocation) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type CloudInventoryItem. +func (c *CloudInventoryItem) GetInventoryItemProperties() *InventoryItemProperties { + return &InventoryItemProperties{ + InventoryType: c.InventoryType, + ManagedResourceID: c.ManagedResourceID, + UUID: c.UUID, + InventoryItemName: c.InventoryItemName, + ProvisioningState: c.ProvisioningState, + } +} + +// MarshalJSON implements the json.Marshaller interface for type CloudInventoryItem. +func (c CloudInventoryItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "inventoryItemName", c.InventoryItemName) + objectMap["inventoryType"] = InventoryTypeCloud + populate(objectMap, "managedResourceId", c.ManagedResourceID) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "uuid", c.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudInventoryItem. +func (c *CloudInventoryItem) 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 "inventoryItemName": + err = unpopulate(val, &c.InventoryItemName) + delete(rawMsg, key) + case "inventoryType": + err = unpopulate(val, &c.InventoryType) + delete(rawMsg, key) + case "managedResourceId": + err = unpopulate(val, &c.ManagedResourceID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &c.ProvisioningState) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, &c.UUID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CloudListResult. +func (c CloudListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type CloudProperties. +func (c CloudProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cloudCapacity", c.CloudCapacity) + populate(objectMap, "cloudName", c.CloudName) + populate(objectMap, "inventoryItemId", c.InventoryItemID) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "storageQoSPolicies", c.StorageQoSPolicies) + populate(objectMap, "uuid", c.UUID) + populate(objectMap, "vmmServerId", c.VmmServerID) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. +func (e ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type InventoryItem. +func (i InventoryItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", i.ID) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryItem. +func (i *InventoryItem) 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 "id": + err = unpopulate(val, &i.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, &i.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &i.Name) + delete(rawMsg, key) + case "properties": + i.Properties, err = unmarshalInventoryItemPropertiesClassification(val) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &i.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type InventoryItemProperties. +func (i *InventoryItemProperties) GetInventoryItemProperties() *InventoryItemProperties { return i } + +// MarshalJSON implements the json.Marshaller interface for type InventoryItemsList. +func (i InventoryItemsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkInterfaces. +func (n NetworkInterfaces) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", n.DisplayName) + populate(objectMap, "ipv4AddressType", n.IPv4AddressType) + populate(objectMap, "ipv4Addresses", n.IPv4Addresses) + populate(objectMap, "ipv6AddressType", n.IPv6AddressType) + populate(objectMap, "ipv6Addresses", n.IPv6Addresses) + populate(objectMap, "macAddress", n.MacAddress) + populate(objectMap, "macAddressType", n.MacAddressType) + populate(objectMap, "name", n.Name) + populate(objectMap, "networkName", n.NetworkName) + populate(objectMap, "nicId", n.NicID) + populate(objectMap, "virtualNetworkId", n.VirtualNetworkID) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkProfile. +func (n NetworkProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "networkInterfaces", n.NetworkInterfaces) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkProfileUpdate. +func (n NetworkProfileUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "networkInterfaces", n.NetworkInterfaces) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ResourcePatch. +func (r ResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationList. +func (r ResourceProviderOperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type StorageProfile. +func (s StorageProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "disks", s.Disks) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type StorageProfileUpdate. +func (s StorageProfileUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "disks", s.Disks) + return json.Marshal(objectMap) +} + +// 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 +} + +// MarshalJSON implements the json.Marshaller interface for type VMMServer. +func (v VMMServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VMMServerListResult. +func (v VMMServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachine. +func (v VirtualMachine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type VirtualMachineInventoryItem. +func (v *VirtualMachineInventoryItem) GetInventoryItemProperties() *InventoryItemProperties { + return &InventoryItemProperties{ + InventoryType: v.InventoryType, + ManagedResourceID: v.ManagedResourceID, + UUID: v.UUID, + InventoryItemName: v.InventoryItemName, + ProvisioningState: v.ProvisioningState, + } +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInventoryItem. +func (v VirtualMachineInventoryItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cloud", v.Cloud) + populate(objectMap, "ipAddresses", v.IPAddresses) + populate(objectMap, "inventoryItemName", v.InventoryItemName) + objectMap["inventoryType"] = InventoryTypeVirtualMachine + populate(objectMap, "managedResourceId", v.ManagedResourceID) + populate(objectMap, "osName", v.OSName) + populate(objectMap, "osType", v.OSType) + populate(objectMap, "powerState", v.PowerState) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "uuid", v.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInventoryItem. +func (v *VirtualMachineInventoryItem) 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 "cloud": + err = unpopulate(val, &v.Cloud) + delete(rawMsg, key) + case "ipAddresses": + err = unpopulate(val, &v.IPAddresses) + delete(rawMsg, key) + case "inventoryItemName": + err = unpopulate(val, &v.InventoryItemName) + delete(rawMsg, key) + case "inventoryType": + err = unpopulate(val, &v.InventoryType) + delete(rawMsg, key) + case "managedResourceId": + err = unpopulate(val, &v.ManagedResourceID) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, &v.OSName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, &v.OSType) + delete(rawMsg, key) + case "powerState": + err = unpopulate(val, &v.PowerState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &v.ProvisioningState) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, &v.UUID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineListResult. +func (v VirtualMachineListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineProperties. +func (v VirtualMachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilitySets", v.AvailabilitySets) + populate(objectMap, "checkpointType", v.CheckpointType) + populate(objectMap, "checkpoints", v.Checkpoints) + populate(objectMap, "cloudId", v.CloudID) + populate(objectMap, "generation", v.Generation) + populate(objectMap, "hardwareProfile", v.HardwareProfile) + populate(objectMap, "inventoryItemId", v.InventoryItemID) + populate(objectMap, "networkProfile", v.NetworkProfile) + populate(objectMap, "osProfile", v.OSProfile) + populate(objectMap, "powerState", v.PowerState) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "storageProfile", v.StorageProfile) + populate(objectMap, "templateId", v.TemplateID) + populate(objectMap, "uuid", v.UUID) + populate(objectMap, "vmName", v.VMName) + populate(objectMap, "vmmServerId", v.VmmServerID) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplate. +func (v VirtualMachineTemplate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type VirtualMachineTemplateInventoryItem. +func (v *VirtualMachineTemplateInventoryItem) GetInventoryItemProperties() *InventoryItemProperties { + return &InventoryItemProperties{ + InventoryType: v.InventoryType, + ManagedResourceID: v.ManagedResourceID, + UUID: v.UUID, + InventoryItemName: v.InventoryItemName, + ProvisioningState: v.ProvisioningState, + } +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplateInventoryItem. +func (v VirtualMachineTemplateInventoryItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cpuCount", v.CPUCount) + populate(objectMap, "inventoryItemName", v.InventoryItemName) + objectMap["inventoryType"] = InventoryTypeVirtualMachineTemplate + populate(objectMap, "managedResourceId", v.ManagedResourceID) + populate(objectMap, "memoryMB", v.MemoryMB) + populate(objectMap, "osName", v.OSName) + populate(objectMap, "osType", v.OSType) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "uuid", v.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineTemplateInventoryItem. +func (v *VirtualMachineTemplateInventoryItem) 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 "cpuCount": + err = unpopulate(val, &v.CPUCount) + delete(rawMsg, key) + case "inventoryItemName": + err = unpopulate(val, &v.InventoryItemName) + delete(rawMsg, key) + case "inventoryType": + err = unpopulate(val, &v.InventoryType) + delete(rawMsg, key) + case "managedResourceId": + err = unpopulate(val, &v.ManagedResourceID) + delete(rawMsg, key) + case "memoryMB": + err = unpopulate(val, &v.MemoryMB) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, &v.OSName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, &v.OSType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &v.ProvisioningState) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, &v.UUID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplateListResult. +func (v VirtualMachineTemplateListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplateProperties. +func (v VirtualMachineTemplateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cpuCount", v.CPUCount) + populate(objectMap, "computerName", v.ComputerName) + populate(objectMap, "disks", v.Disks) + populate(objectMap, "dynamicMemoryEnabled", v.DynamicMemoryEnabled) + populate(objectMap, "dynamicMemoryMaxMB", v.DynamicMemoryMaxMB) + populate(objectMap, "dynamicMemoryMinMB", v.DynamicMemoryMinMB) + populate(objectMap, "generation", v.Generation) + populate(objectMap, "inventoryItemId", v.InventoryItemID) + populate(objectMap, "isCustomizable", v.IsCustomizable) + populate(objectMap, "isHighlyAvailable", v.IsHighlyAvailable) + populate(objectMap, "limitCpuForMigration", v.LimitCPUForMigration) + populate(objectMap, "memoryMB", v.MemoryMB) + populate(objectMap, "networkInterfaces", v.NetworkInterfaces) + populate(objectMap, "osName", v.OSName) + populate(objectMap, "osType", v.OSType) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "uuid", v.UUID) + populate(objectMap, "vmmServerId", v.VmmServerID) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdate. +func (v VirtualMachineUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdateProperties. +func (v VirtualMachineUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilitySets", v.AvailabilitySets) + populate(objectMap, "hardwareProfile", v.HardwareProfile) + populate(objectMap, "networkProfile", v.NetworkProfile) + populate(objectMap, "storageProfile", v.StorageProfile) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetwork. +func (v VirtualNetwork) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type VirtualNetworkInventoryItem. +func (v *VirtualNetworkInventoryItem) GetInventoryItemProperties() *InventoryItemProperties { + return &InventoryItemProperties{ + InventoryType: v.InventoryType, + ManagedResourceID: v.ManagedResourceID, + UUID: v.UUID, + InventoryItemName: v.InventoryItemName, + ProvisioningState: v.ProvisioningState, + } +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkInventoryItem. +func (v VirtualNetworkInventoryItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "inventoryItemName", v.InventoryItemName) + objectMap["inventoryType"] = InventoryTypeVirtualNetwork + populate(objectMap, "managedResourceId", v.ManagedResourceID) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "uuid", v.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkInventoryItem. +func (v *VirtualNetworkInventoryItem) 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 "inventoryItemName": + err = unpopulate(val, &v.InventoryItemName) + delete(rawMsg, key) + case "inventoryType": + err = unpopulate(val, &v.InventoryType) + delete(rawMsg, key) + case "managedResourceId": + err = unpopulate(val, &v.ManagedResourceID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &v.ProvisioningState) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, &v.UUID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkListResult. +func (v VirtualNetworkListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +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/scvmm/armscvmm/zz_generated_operations_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_operations_client.go new file mode 100644 index 000000000000..585a14ac9488 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_operations_client.go @@ -0,0 +1,103 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "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/cloud" + "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 { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - Returns list of all operations. +// If the operation fails it returns an *azcore.ResponseError type. +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ScVmm/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-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) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceProviderOperationList); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..3389cf89c2d9 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_polymorphic_helpers.go @@ -0,0 +1,35 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import "encoding/json" + +func unmarshalInventoryItemPropertiesClassification(rawMsg json.RawMessage) (InventoryItemPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b InventoryItemPropertiesClassification + switch m["inventoryType"] { + case string(InventoryTypeCloud): + b = &CloudInventoryItem{} + case string(InventoryTypeVirtualMachine): + b = &VirtualMachineInventoryItem{} + case string(InventoryTypeVirtualMachineTemplate): + b = &VirtualMachineTemplateInventoryItem{} + case string(InventoryTypeVirtualNetwork): + b = &VirtualNetworkInventoryItem{} + default: + b = &InventoryItemProperties{} + } + return b, json.Unmarshal(rawMsg, b) +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_response_types.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_response_types.go new file mode 100644 index 000000000000..044b75da2440 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_response_types.go @@ -0,0 +1,244 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +// AvailabilitySetsClientCreateOrUpdateResponse contains the response from method AvailabilitySetsClient.CreateOrUpdate. +type AvailabilitySetsClientCreateOrUpdateResponse struct { + AvailabilitySet +} + +// AvailabilitySetsClientDeleteResponse contains the response from method AvailabilitySetsClient.Delete. +type AvailabilitySetsClientDeleteResponse struct { + // placeholder for future response values +} + +// AvailabilitySetsClientGetResponse contains the response from method AvailabilitySetsClient.Get. +type AvailabilitySetsClientGetResponse struct { + AvailabilitySet +} + +// AvailabilitySetsClientListByResourceGroupResponse contains the response from method AvailabilitySetsClient.ListByResourceGroup. +type AvailabilitySetsClientListByResourceGroupResponse struct { + AvailabilitySetListResult +} + +// AvailabilitySetsClientListBySubscriptionResponse contains the response from method AvailabilitySetsClient.ListBySubscription. +type AvailabilitySetsClientListBySubscriptionResponse struct { + AvailabilitySetListResult +} + +// AvailabilitySetsClientUpdateResponse contains the response from method AvailabilitySetsClient.Update. +type AvailabilitySetsClientUpdateResponse struct { + AvailabilitySet +} + +// CloudsClientCreateOrUpdateResponse contains the response from method CloudsClient.CreateOrUpdate. +type CloudsClientCreateOrUpdateResponse struct { + Cloud +} + +// CloudsClientDeleteResponse contains the response from method CloudsClient.Delete. +type CloudsClientDeleteResponse struct { + // placeholder for future response values +} + +// CloudsClientGetResponse contains the response from method CloudsClient.Get. +type CloudsClientGetResponse struct { + Cloud +} + +// CloudsClientListByResourceGroupResponse contains the response from method CloudsClient.ListByResourceGroup. +type CloudsClientListByResourceGroupResponse struct { + CloudListResult +} + +// CloudsClientListBySubscriptionResponse contains the response from method CloudsClient.ListBySubscription. +type CloudsClientListBySubscriptionResponse struct { + CloudListResult +} + +// CloudsClientUpdateResponse contains the response from method CloudsClient.Update. +type CloudsClientUpdateResponse struct { + Cloud +} + +// InventoryItemsClientCreateResponse contains the response from method InventoryItemsClient.Create. +type InventoryItemsClientCreateResponse struct { + InventoryItem +} + +// InventoryItemsClientDeleteResponse contains the response from method InventoryItemsClient.Delete. +type InventoryItemsClientDeleteResponse struct { + // placeholder for future response values +} + +// InventoryItemsClientGetResponse contains the response from method InventoryItemsClient.Get. +type InventoryItemsClientGetResponse struct { + InventoryItem +} + +// InventoryItemsClientListByVMMServerResponse contains the response from method InventoryItemsClient.ListByVMMServer. +type InventoryItemsClientListByVMMServerResponse struct { + InventoryItemsList +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + ResourceProviderOperationList +} + +// VirtualMachineTemplatesClientCreateOrUpdateResponse contains the response from method VirtualMachineTemplatesClient.CreateOrUpdate. +type VirtualMachineTemplatesClientCreateOrUpdateResponse struct { + VirtualMachineTemplate +} + +// VirtualMachineTemplatesClientDeleteResponse contains the response from method VirtualMachineTemplatesClient.Delete. +type VirtualMachineTemplatesClientDeleteResponse struct { + // placeholder for future response values +} + +// VirtualMachineTemplatesClientGetResponse contains the response from method VirtualMachineTemplatesClient.Get. +type VirtualMachineTemplatesClientGetResponse struct { + VirtualMachineTemplate +} + +// VirtualMachineTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineTemplatesClient.ListByResourceGroup. +type VirtualMachineTemplatesClientListByResourceGroupResponse struct { + VirtualMachineTemplateListResult +} + +// VirtualMachineTemplatesClientListBySubscriptionResponse contains the response from method VirtualMachineTemplatesClient.ListBySubscription. +type VirtualMachineTemplatesClientListBySubscriptionResponse struct { + VirtualMachineTemplateListResult +} + +// VirtualMachineTemplatesClientUpdateResponse contains the response from method VirtualMachineTemplatesClient.Update. +type VirtualMachineTemplatesClientUpdateResponse struct { + VirtualMachineTemplate +} + +// VirtualMachinesClientCreateCheckpointResponse contains the response from method VirtualMachinesClient.CreateCheckpoint. +type VirtualMachinesClientCreateCheckpointResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.CreateOrUpdate. +type VirtualMachinesClientCreateOrUpdateResponse struct { + VirtualMachine +} + +// VirtualMachinesClientDeleteCheckpointResponse contains the response from method VirtualMachinesClient.DeleteCheckpoint. +type VirtualMachinesClientDeleteCheckpointResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.Delete. +type VirtualMachinesClientDeleteResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientGetResponse contains the response from method VirtualMachinesClient.Get. +type VirtualMachinesClientGetResponse struct { + VirtualMachine +} + +// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.ListByResourceGroup. +type VirtualMachinesClientListByResourceGroupResponse struct { + VirtualMachineListResult +} + +// VirtualMachinesClientListBySubscriptionResponse contains the response from method VirtualMachinesClient.ListBySubscription. +type VirtualMachinesClientListBySubscriptionResponse struct { + VirtualMachineListResult +} + +// VirtualMachinesClientRestartResponse contains the response from method VirtualMachinesClient.Restart. +type VirtualMachinesClientRestartResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientRestoreCheckpointResponse contains the response from method VirtualMachinesClient.RestoreCheckpoint. +type VirtualMachinesClientRestoreCheckpointResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientStartResponse contains the response from method VirtualMachinesClient.Start. +type VirtualMachinesClientStartResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientStopResponse contains the response from method VirtualMachinesClient.Stop. +type VirtualMachinesClientStopResponse struct { + // placeholder for future response values +} + +// VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.Update. +type VirtualMachinesClientUpdateResponse struct { + VirtualMachine +} + +// VirtualNetworksClientCreateOrUpdateResponse contains the response from method VirtualNetworksClient.CreateOrUpdate. +type VirtualNetworksClientCreateOrUpdateResponse struct { + VirtualNetwork +} + +// VirtualNetworksClientDeleteResponse contains the response from method VirtualNetworksClient.Delete. +type VirtualNetworksClientDeleteResponse struct { + // placeholder for future response values +} + +// VirtualNetworksClientGetResponse contains the response from method VirtualNetworksClient.Get. +type VirtualNetworksClientGetResponse struct { + VirtualNetwork +} + +// VirtualNetworksClientListByResourceGroupResponse contains the response from method VirtualNetworksClient.ListByResourceGroup. +type VirtualNetworksClientListByResourceGroupResponse struct { + VirtualNetworkListResult +} + +// VirtualNetworksClientListBySubscriptionResponse contains the response from method VirtualNetworksClient.ListBySubscription. +type VirtualNetworksClientListBySubscriptionResponse struct { + VirtualNetworkListResult +} + +// VirtualNetworksClientUpdateResponse contains the response from method VirtualNetworksClient.Update. +type VirtualNetworksClientUpdateResponse struct { + VirtualNetwork +} + +// VmmServersClientCreateOrUpdateResponse contains the response from method VmmServersClient.CreateOrUpdate. +type VmmServersClientCreateOrUpdateResponse struct { + VMMServer +} + +// VmmServersClientDeleteResponse contains the response from method VmmServersClient.Delete. +type VmmServersClientDeleteResponse struct { + // placeholder for future response values +} + +// VmmServersClientGetResponse contains the response from method VmmServersClient.Get. +type VmmServersClientGetResponse struct { + VMMServer +} + +// VmmServersClientListByResourceGroupResponse contains the response from method VmmServersClient.ListByResourceGroup. +type VmmServersClientListByResourceGroupResponse struct { + VMMServerListResult +} + +// VmmServersClientListBySubscriptionResponse contains the response from method VmmServersClient.ListBySubscription. +type VmmServersClientListBySubscriptionResponse struct { + VMMServerListResult +} + +// VmmServersClientUpdateResponse contains the response from method VmmServersClient.Update. +type VmmServersClientUpdateResponse struct { + VMMServer +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_time_rfc3339.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..63e62611ec0d --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +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/scvmm/armscvmm/zz_generated_virtualmachines_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualmachines_client.go new file mode 100644 index 000000000000..8526f8e33709 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualmachines_client.go @@ -0,0 +1,809 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// VirtualMachinesClient contains the methods for the VirtualMachines group. +// Don't use this type directly, use NewVirtualMachinesClient() instead. +type VirtualMachinesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVirtualMachinesClient creates a new instance of VirtualMachinesClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachinesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VirtualMachinesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateCheckpoint - Creates a checkpoint in virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginCreateCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateCheckpoint +// method. +func (client *VirtualMachinesClient) BeginCreateCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginCreateCheckpointOptions) (*armruntime.Poller[VirtualMachinesClientCreateCheckpointResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createCheckpoint(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[VirtualMachinesClientCreateCheckpointResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientCreateCheckpointResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateCheckpoint - Creates a checkpoint in virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) createCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginCreateCheckpointOptions) (*http.Response, error) { + req, err := client.createCheckpointCreateRequest(ctx, resourceGroupName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCheckpointCreateRequest creates the CreateCheckpoint request. +func (client *VirtualMachinesClient) createCheckpointCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginCreateCheckpointOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// BeginCreateOrUpdate - Creates Or Updates virtual machines deployed on scvmm fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// body - Request payload. +// options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate +// method. +func (client *VirtualMachinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*armruntime.Poller[VirtualMachinesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualMachineName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualMachinesClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates Or Updates virtual machines deployed on scvmm fabric. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, 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.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/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 virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a VirtualMachine deployed on ScVmm fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete +// method. +func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*armruntime.Poller[VirtualMachinesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualMachinesClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a VirtualMachine deployed on ScVmm fabric. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, 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, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/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 virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + if options != nil && options.Retain != nil { + reqQP.Set("retain", strconv.FormatBool(*options.Retain)) + } + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// BeginDeleteCheckpoint - Deletes a checkpoint in virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginDeleteCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginDeleteCheckpoint +// method. +func (client *VirtualMachinesClient) BeginDeleteCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteCheckpointOptions) (*armruntime.Poller[VirtualMachinesClientDeleteCheckpointResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteCheckpoint(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[VirtualMachinesClientDeleteCheckpointResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientDeleteCheckpointResponse](options.ResumeToken, client.pl, nil) + } +} + +// DeleteCheckpoint - Deletes a checkpoint in virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) deleteCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteCheckpointOptions) (*http.Response, error) { + req, err := client.deleteCheckpointCreateRequest(ctx, resourceGroupName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCheckpointCreateRequest creates the DeleteCheckpoint request. +func (client *VirtualMachinesClient) deleteCheckpointCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteCheckpointOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// Get - Implements VirtualMachine GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (VirtualMachinesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return VirtualMachinesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachinesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachinesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/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 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-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) (VirtualMachinesClientGetResponse, error) { + result := VirtualMachinesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachine); err != nil { + return VirtualMachinesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List of VirtualMachines in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.ListByResourceGroup +// method. +func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachinesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[VirtualMachinesClientListByResourceGroupResponse]{ + More: func(page VirtualMachinesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualMachinesClientListByResourceGroupResponse) (VirtualMachinesClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualMachinesClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachinesClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachinesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *VirtualMachinesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/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)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachinesClientListByResourceGroupResponse, error) { + result := VirtualMachinesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineListResult); err != nil { + return VirtualMachinesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List of VirtualMachines in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// options - VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.ListBySubscription +// method. +func (client *VirtualMachinesClient) NewListBySubscriptionPager(options *VirtualMachinesClientListBySubscriptionOptions) *runtime.Pager[VirtualMachinesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[VirtualMachinesClientListBySubscriptionResponse]{ + More: func(page VirtualMachinesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualMachinesClientListBySubscriptionResponse) (VirtualMachinesClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualMachinesClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachinesClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachinesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VirtualMachinesClient) listBySubscriptionCreateRequest(ctx context.Context, options *VirtualMachinesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachines" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VirtualMachinesClient) listBySubscriptionHandleResponse(resp *http.Response) (VirtualMachinesClientListBySubscriptionResponse, error) { + result := VirtualMachinesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineListResult); err != nil { + return VirtualMachinesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginRestart - Restart virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart +// method. +func (client *VirtualMachinesClient) BeginRestart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*armruntime.Poller[VirtualMachinesClientRestartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.restart(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[VirtualMachinesClientRestartResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientRestartResponse](options.ResumeToken, client.pl, nil) + } +} + +// Restart - Restart virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) restart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*http.Response, error) { + req, err := client.restartCreateRequest(ctx, resourceGroupName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// restartCreateRequest creates the Restart request. +func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// BeginRestoreCheckpoint - Restores to a checkpoint in virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginRestoreCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginRestoreCheckpoint +// method. +func (client *VirtualMachinesClient) BeginRestoreCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestoreCheckpointOptions) (*armruntime.Poller[VirtualMachinesClientRestoreCheckpointResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.restoreCheckpoint(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[VirtualMachinesClientRestoreCheckpointResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientRestoreCheckpointResponse](options.ResumeToken, client.pl, nil) + } +} + +// RestoreCheckpoint - Restores to a checkpoint in virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) restoreCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestoreCheckpointOptions) (*http.Response, error) { + req, err := client.restoreCheckpointCreateRequest(ctx, resourceGroupName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// restoreCheckpointCreateRequest creates the RestoreCheckpoint request. +func (client *VirtualMachinesClient) restoreCheckpointCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestoreCheckpointOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// BeginStart - Start virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart +// method. +func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*armruntime.Poller[VirtualMachinesClientStartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.start(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[VirtualMachinesClientStartResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.pl, nil) + } +} + +// Start - Start virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// BeginStop - Stop virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop +// method. +func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*armruntime.Poller[VirtualMachinesClientStopResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.stop(ctx, resourceGroupName, virtualMachineName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller[VirtualMachinesClientStopResponse](resp, client.pl, nil) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.pl, nil) + } +} + +// Stop - Stop virtual machine. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// BeginUpdate - Updates the VirtualMachines resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineName - Name of the VirtualMachine. +// body - VirtualMachines patch payload. +// options - VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate +// method. +func (client *VirtualMachinesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*armruntime.Poller[VirtualMachinesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualMachineName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualMachinesClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachinesClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the VirtualMachines resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachinesClient) update(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, 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.StatusCreated, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VirtualMachinesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualmachinetemplates_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualmachinetemplates_client.go new file mode 100644 index 000000000000..06bce02553c5 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualmachinetemplates_client.go @@ -0,0 +1,429 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// VirtualMachineTemplatesClient contains the methods for the VirtualMachineTemplates group. +// Don't use this type directly, use NewVirtualMachineTemplatesClient() instead. +type VirtualMachineTemplatesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVirtualMachineTemplatesClient creates a new instance of VirtualMachineTemplatesClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVirtualMachineTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineTemplatesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VirtualMachineTemplatesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Onboards the ScVmm VM Template as an Azure VM Template resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineTemplateName - Name of the VirtualMachineTemplate. +// body - Request payload. +// options - VirtualMachineTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreateOrUpdate +// method. +func (client *VirtualMachineTemplatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*armruntime.Poller[VirtualMachineTemplatesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualMachineTemplateName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualMachineTemplatesClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachineTemplatesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Onboards the ScVmm VM Template as an Azure VM Template resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachineTemplatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, 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) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualMachineTemplatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}" + 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 virtualMachineTemplateName == "" { + return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deregisters the ScVmm VM Template from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineTemplateName - Name of the VirtualMachineTemplate. +// options - VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete +// method. +func (client *VirtualMachineTemplatesClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*armruntime.Poller[VirtualMachineTemplatesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineTemplateName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualMachineTemplatesClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachineTemplatesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deregisters the ScVmm VM Template from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachineTemplatesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}" + 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 virtualMachineTemplateName == "" { + return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Implements VirtualMachineTemplate GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineTemplateName - Name of the VirtualMachineTemplate. +// options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get +// method. +func (client *VirtualMachineTemplatesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientGetOptions) (VirtualMachineTemplatesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, options) + if err != nil { + return VirtualMachineTemplatesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachineTemplatesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachineTemplatesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VirtualMachineTemplatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}" + 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 virtualMachineTemplateName == "" { + return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VirtualMachineTemplatesClient) getHandleResponse(resp *http.Response) (VirtualMachineTemplatesClientGetResponse, error) { + result := VirtualMachineTemplatesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineTemplate); err != nil { + return VirtualMachineTemplatesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List of VirtualMachineTemplates in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// options - VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.ListByResourceGroup +// method. +func (client *VirtualMachineTemplatesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachineTemplatesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachineTemplatesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[VirtualMachineTemplatesClientListByResourceGroupResponse]{ + More: func(page VirtualMachineTemplatesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualMachineTemplatesClientListByResourceGroupResponse) (VirtualMachineTemplatesClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualMachineTemplatesClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachineTemplatesClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachineTemplatesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *VirtualMachineTemplatesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualMachineTemplatesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *VirtualMachineTemplatesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachineTemplatesClientListByResourceGroupResponse, error) { + result := VirtualMachineTemplatesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineTemplateListResult); err != nil { + return VirtualMachineTemplatesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List of VirtualMachineTemplates in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// options - VirtualMachineTemplatesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachineTemplatesClient.ListBySubscription +// method. +func (client *VirtualMachineTemplatesClient) NewListBySubscriptionPager(options *VirtualMachineTemplatesClientListBySubscriptionOptions) *runtime.Pager[VirtualMachineTemplatesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[VirtualMachineTemplatesClientListBySubscriptionResponse]{ + More: func(page VirtualMachineTemplatesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualMachineTemplatesClientListBySubscriptionResponse) (VirtualMachineTemplatesClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualMachineTemplatesClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualMachineTemplatesClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachineTemplatesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VirtualMachineTemplatesClient) listBySubscriptionCreateRequest(ctx context.Context, options *VirtualMachineTemplatesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachineTemplates" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VirtualMachineTemplatesClient) listBySubscriptionHandleResponse(resp *http.Response) (VirtualMachineTemplatesClientListBySubscriptionResponse, error) { + result := VirtualMachineTemplatesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineTemplateListResult); err != nil { + return VirtualMachineTemplatesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the VirtualMachineTemplate resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualMachineTemplateName - Name of the VirtualMachineTemplate. +// body - VirtualMachineTemplates patch details. +// options - VirtualMachineTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginUpdate +// method. +func (client *VirtualMachineTemplatesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*armruntime.Poller[VirtualMachineTemplatesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualMachineTemplateName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualMachineTemplatesClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualMachineTemplatesClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the VirtualMachineTemplate resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualMachineTemplatesClient) update(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VirtualMachineTemplatesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if virtualMachineTemplateName == "" { + return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualnetworks_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualnetworks_client.go new file mode 100644 index 000000000000..4785d116e61b --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_virtualnetworks_client.go @@ -0,0 +1,428 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// VirtualNetworksClient contains the methods for the VirtualNetworks group. +// Don't use this type directly, use NewVirtualNetworksClient() instead. +type VirtualNetworksClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVirtualNetworksClient creates a new instance of VirtualNetworksClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworksClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VirtualNetworksClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Onboards the ScVmm virtual network as an Azure virtual network resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualNetworkName - Name of the VirtualNetwork. +// body - Request payload. +// options - VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate +// method. +func (client *VirtualNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*armruntime.Poller[VirtualNetworksClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualNetworkName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualNetworksClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Onboards the ScVmm virtual network as an Azure virtual network resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualNetworkName, 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) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}" + 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 virtualNetworkName == "" { + return nil, errors.New("parameter virtualNetworkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deregisters the ScVmm virtual network from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualNetworkName - Name of the VirtualNetwork. +// options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete +// method. +func (client *VirtualNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*armruntime.Poller[VirtualNetworksClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualNetworkName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualNetworksClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deregisters the ScVmm virtual network from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualNetworkName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}" + 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 virtualNetworkName == "" { + return nil, errors.New("parameter virtualNetworkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Implements VirtualNetwork GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualNetworkName - Name of the VirtualNetwork. +// options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. +func (client *VirtualNetworksClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientGetOptions) (VirtualNetworksClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, virtualNetworkName, options) + if err != nil { + return VirtualNetworksClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualNetworksClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VirtualNetworksClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}" + 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 virtualNetworkName == "" { + return nil, errors.New("parameter virtualNetworkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VirtualNetworksClient) getHandleResponse(resp *http.Response) (VirtualNetworksClientGetResponse, error) { + result := VirtualNetworksClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetwork); err != nil { + return VirtualNetworksClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List of VirtualNetworks in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// options - VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.ListByResourceGroup +// method. +func (client *VirtualNetworksClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualNetworksClientListByResourceGroupOptions) *runtime.Pager[VirtualNetworksClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[VirtualNetworksClientListByResourceGroupResponse]{ + More: func(page VirtualNetworksClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualNetworksClientListByResourceGroupResponse) (VirtualNetworksClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualNetworksClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualNetworksClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *VirtualNetworksClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualNetworksClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *VirtualNetworksClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualNetworksClientListByResourceGroupResponse, error) { + result := VirtualNetworksClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworkListResult); err != nil { + return VirtualNetworksClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List of VirtualNetworks in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// options - VirtualNetworksClientListBySubscriptionOptions contains the optional parameters for the VirtualNetworksClient.ListBySubscription +// method. +func (client *VirtualNetworksClient) NewListBySubscriptionPager(options *VirtualNetworksClientListBySubscriptionOptions) *runtime.Pager[VirtualNetworksClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[VirtualNetworksClientListBySubscriptionResponse]{ + More: func(page VirtualNetworksClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualNetworksClientListBySubscriptionResponse) (VirtualNetworksClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualNetworksClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualNetworksClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VirtualNetworksClient) listBySubscriptionCreateRequest(ctx context.Context, options *VirtualNetworksClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualNetworks" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VirtualNetworksClient) listBySubscriptionHandleResponse(resp *http.Response) (VirtualNetworksClientListBySubscriptionResponse, error) { + result := VirtualNetworksClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworkListResult); err != nil { + return VirtualNetworksClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the VirtualNetworks resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// virtualNetworkName - Name of the VirtualNetwork. +// body - VirtualNetworks patch payload. +// options - VirtualNetworksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginUpdate +// method. +func (client *VirtualNetworksClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientBeginUpdateOptions) (*armruntime.Poller[VirtualNetworksClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualNetworkName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VirtualNetworksClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VirtualNetworksClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the VirtualNetworks resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VirtualNetworksClient) update(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualNetworkName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if virtualNetworkName == "" { + return nil, errors.New("parameter virtualNetworkName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/zz_generated_vmmservers_client.go b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_vmmservers_client.go new file mode 100644 index 000000000000..fcd04b20febb --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/zz_generated_vmmservers_client.go @@ -0,0 +1,426 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armscvmm + +import ( + "context" + "errors" + "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/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// VmmServersClient contains the methods for the VmmServers group. +// Don't use this type directly, use NewVmmServersClient() instead. +type VmmServersClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVmmServersClient creates a new instance of VmmServersClient with the specified values. +// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVmmServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VmmServersClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VmmServersClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Onboards the SCVMM fabric as an Azure VmmServer resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// body - Request payload. +// options - VmmServersClientBeginCreateOrUpdateOptions contains the optional parameters for the VmmServersClient.BeginCreateOrUpdate +// method. +func (client *VmmServersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, body VMMServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*armruntime.Poller[VmmServersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, vmmServerName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VmmServersClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VmmServersClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Onboards the SCVMM fabric as an Azure VmmServer resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VmmServersClient) createOrUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, body VMMServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vmmServerName, 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) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VmmServersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, body VMMServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deboards the SCVMM fabric from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// options - VmmServersClientBeginDeleteOptions contains the optional parameters for the VmmServersClient.BeginDelete method. +func (client *VmmServersClient) BeginDelete(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientBeginDeleteOptions) (*armruntime.Poller[VmmServersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, vmmServerName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VmmServersClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VmmServersClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deboards the SCVMM fabric from Azure. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VmmServersClient) deleteOperation(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vmmServerName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VmmServersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Implements VMMServer GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// options - VmmServersClientGetOptions contains the optional parameters for the VmmServersClient.Get method. +func (client *VmmServersClient) Get(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientGetOptions) (VmmServersClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, vmmServerName, options) + if err != nil { + return VmmServersClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VmmServersClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VmmServersClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VmmServersClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}" + 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 vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VmmServersClient) getHandleResponse(resp *http.Response) (VmmServersClientGetResponse, error) { + result := VmmServersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMMServer); err != nil { + return VmmServersClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List of VmmServers in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// options - VmmServersClientListByResourceGroupOptions contains the optional parameters for the VmmServersClient.ListByResourceGroup +// method. +func (client *VmmServersClient) NewListByResourceGroupPager(resourceGroupName string, options *VmmServersClientListByResourceGroupOptions) *runtime.Pager[VmmServersClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[VmmServersClientListByResourceGroupResponse]{ + More: func(page VmmServersClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VmmServersClientListByResourceGroupResponse) (VmmServersClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VmmServersClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VmmServersClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VmmServersClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *VmmServersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VmmServersClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *VmmServersClient) listByResourceGroupHandleResponse(resp *http.Response) (VmmServersClientListByResourceGroupResponse, error) { + result := VmmServersClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMMServerListResult); err != nil { + return VmmServersClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List of VmmServers in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// options - VmmServersClientListBySubscriptionOptions contains the optional parameters for the VmmServersClient.ListBySubscription +// method. +func (client *VmmServersClient) NewListBySubscriptionPager(options *VmmServersClientListBySubscriptionOptions) *runtime.Pager[VmmServersClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[VmmServersClientListBySubscriptionResponse]{ + More: func(page VmmServersClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VmmServersClientListBySubscriptionResponse) (VmmServersClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VmmServersClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VmmServersClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VmmServersClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VmmServersClient) listBySubscriptionCreateRequest(ctx context.Context, options *VmmServersClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/vmmServers" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VmmServersClient) listBySubscriptionHandleResponse(resp *http.Response) (VmmServersClientListBySubscriptionResponse, error) { + result := VmmServersClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMMServerListResult); err != nil { + return VmmServersClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the VmmServers resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. +// vmmServerName - Name of the VMMServer. +// body - VmmServers patch payload. +// options - VmmServersClientBeginUpdateOptions contains the optional parameters for the VmmServersClient.BeginUpdate method. +func (client *VmmServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, body ResourcePatch, options *VmmServersClientBeginUpdateOptions) (*armruntime.Poller[VmmServersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, vmmServerName, body, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VmmServersClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VmmServersClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the VmmServers resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VmmServersClient) update(ctx context.Context, resourceGroupName string, vmmServerName string, body ResourcePatch, options *VmmServersClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, vmmServerName, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VmmServersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, body ResourcePatch, options *VmmServersClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if vmmServerName == "" { + return nil, errors.New("parameter vmmServerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-05-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, body) +}