From 29de9ca4ced7021d05fe9b4b477d1f6e7c7623d8 Mon Sep 17 00:00:00 2001 From: Jiahui Peng <46921893+Alancere@users.noreply.github.com> Date: Thu, 16 Dec 2021 13:30:04 +0800 Subject: [PATCH] [Release] sdk/resourcemanager/mixedreality/armmixedreality/0.1.0 (#16592) * [Release] sdk/resourcemanager/mixedreality/armmixedreality/0.1.0 generation from spec commit: 4cda81c5daed78441aa8043dd32ae00b02899c36 * Update CHANGELOG.md Co-authored-by: Dapeng Zhang --- .../mixedreality/armmixedreality/CHANGELOG.md | 5 + .../mixedreality/armmixedreality/LICENSE.txt | 21 + .../mixedreality/armmixedreality/README.md | 75 ++ .../mixedreality/armmixedreality/autorest.md | 13 + .../mixedreality/armmixedreality/build.go | 7 + .../mixedreality/armmixedreality/ci.yml | 27 + .../mixedreality/armmixedreality/go.mod | 9 + .../mixedreality/armmixedreality/go.sum | 45 ++ .../armmixedreality/go_mod_tidy_hack.go | 13 + ..._example_mixedrealityclient_client_test.go | 38 + ...ample_objectanchorsaccounts_client_test.go | 189 +++++ ...enerated_example_operations_client_test.go | 33 + ...ple_remoterenderingaccounts_client_test.go | 185 +++++ ...mple_spatialanchorsaccounts_client_test.go | 179 +++++ .../armmixedreality/zz_generated_constants.go | 108 +++ .../zz_generated_mixedrealityclient_client.go | 104 +++ .../armmixedreality/zz_generated_models.go | 729 ++++++++++++++++++ ..._generated_objectanchorsaccounts_client.go | 536 +++++++++++++ .../zz_generated_operations_client.go | 89 +++ .../armmixedreality/zz_generated_pagers.go | 395 ++++++++++ ...enerated_remoterenderingaccounts_client.go | 536 +++++++++++++ .../zz_generated_response_types.go | 305 ++++++++ ...generated_spatialanchorsaccounts_client.go | 536 +++++++++++++ .../zz_generated_time_rfc3339.go | 85 ++ 24 files changed, 4262 insertions(+) create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/LICENSE.txt create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/README.md create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/autorest.md create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/build.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/ci.yml create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/go.mod create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/go.sum create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_operations_client_test.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_mixedrealityclient_client.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go create mode 100644 sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md b/sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md new file mode 100644 index 000000000000..34ac19703899 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-16) + +- Init release. diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/LICENSE.txt b/sdk/resourcemanager/mixedreality/armmixedreality/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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/mixedreality/armmixedreality/README.md b/sdk/resourcemanager/mixedreality/armmixedreality/README.md new file mode 100644 index 000000000000..5eed617a5a91 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/README.md @@ -0,0 +1,75 @@ +# Azure Mixed Readlity Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality) + +The `armmixedreality` module provides operations for working with Azure Mixed Readlity. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/mixedreality/armmixedreality) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.16 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Mixed Readlity module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Mixed Readlity. 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 Mixed Readlity 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 := armmixedreality.NewObjectAnchorsAccountsClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options = arm.ClientOptions{ + Host: arm.AzureChina, +} +client := armmixedreality.NewObjectAnchorsAccountsClient(, 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 `Mixed Readlity` 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/mixedreality/armmixedreality/autorest.md b/sdk/resourcemanager/mixedreality/armmixedreality/autorest.md new file mode 100644 index 000000000000..f2bfaa763103 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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/4cda81c5daed78441aa8043dd32ae00b02899c36/specification/mixedreality/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/4cda81c5daed78441aa8043dd32ae00b02899c36/specification/mixedreality/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/mixedreality/armmixedreality/build.go b/sdk/resourcemanager/mixedreality/armmixedreality/build.go new file mode 100644 index 000000000000..67db4b8d484c --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/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/mixedreality/armmixedreality + +package armmixedreality diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ci.yml b/sdk/resourcemanager/mixedreality/armmixedreality/ci.yml new file mode 100644 index 000000000000..1ee46ca8b3f3 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/mixedreality/armmixedreality/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/mixedreality/armmixedreality/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/mixedreality/armmixedreality' diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/go.mod b/sdk/resourcemanager/mixedreality/armmixedreality/go.mod new file mode 100644 index 000000000000..79d948d8d136 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 +) diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/go.sum b/sdk/resourcemanager/mixedreality/armmixedreality/go.sum new file mode 100644 index 000000000000..35739a609db5 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible h1:j6y8ddurcaiyLfwBwPmJFaunp6BDzyQTuAgMrm1r++o= +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS9cgjHVYSH6DDa0XJMyrblsI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0/go.mod h1:GJzjM4SR9T0KyX5gKCVyz1ytD8FeWeUPCwtFCt1AyfE= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/go_mod_tidy_hack.go b/sdk/resourcemanager/mixedreality/armmixedreality/go_mod_tidy_hack.go new file mode 100644 index 000000000000..5a5f959ac283 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armmixedreality + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go new file mode 100644 index 000000000000..3dd13250f620 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_mixedrealityclient_client_test.go @@ -0,0 +1,38 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality_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/mixedreality/armmixedreality" +) + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/proxy/CheckNameAvailabilityForLocalUniqueness.json +func ExampleMixedRealityClient_CheckNameAvailabilityLocal() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewMixedRealityClient("", cred, nil) + _, err = client.CheckNameAvailabilityLocal(ctx, + "", + armmixedreality.CheckNameAvailabilityRequest{ + Name: to.StringPtr(""), + Type: to.StringPtr(""), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go new file mode 100644 index 000000000000..672a6d81954a --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_objectanchorsaccounts_client_test.go @@ -0,0 +1,189 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality_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/mixedreality/armmixedreality" +) + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/GetBySubscription.json +func ExampleObjectAnchorsAccountsClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + pager := client.ListBySubscription(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ObjectAnchorsAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/GetByResourceGroup.json +func ExampleObjectAnchorsAccountsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + pager := client.ListByResourceGroup("", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ObjectAnchorsAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Delete.json +func ExampleObjectAnchorsAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Get.json +func ExampleObjectAnchorsAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ObjectAnchorsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Patch.json +func ExampleObjectAnchorsAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + armmixedreality.ObjectAnchorsAccount{ + TrackedResource: armmixedreality.TrackedResource{ + Location: to.StringPtr(""), + Tags: map[string]*string{ + "hero": to.StringPtr("romeo"), + "heroine": to.StringPtr("juliet"), + }, + }, + Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + Identity: armmixedreality.Identity{ + Type: to.StringPtr(""), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ObjectAnchorsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/Put.json +func ExampleObjectAnchorsAccountsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + res, err := client.Create(ctx, + "", + "", + armmixedreality.ObjectAnchorsAccount{ + TrackedResource: armmixedreality.TrackedResource{ + Location: to.StringPtr(""), + }, + Identity: &armmixedreality.ObjectAnchorsAccountIdentity{ + Identity: armmixedreality.Identity{ + Type: to.StringPtr(""), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ObjectAnchorsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/ListKeys.json +func ExampleObjectAnchorsAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + _, err = client.ListKeys(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/object-anchors/RegenerateKey.json +func ExampleObjectAnchorsAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewObjectAnchorsAccountsClient("", cred, nil) + _, err = client.RegenerateKeys(ctx, + "", + "", + armmixedreality.AccountKeyRegenerateRequest{ + Serial: armmixedreality.SerialPrimary.ToPtr(), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_operations_client_test.go new file mode 100644 index 000000000000..9a65a9c0a04a --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_operations_client_test.go @@ -0,0 +1,33 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mixedreality/armmixedreality" +) + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/proxy/ExposingAvailableOperations.json +func ExampleOperationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewOperationsClient(cred, nil) + pager := client.List(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go new file mode 100644 index 000000000000..c9cd70c50df1 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_remoterenderingaccounts_client_test.go @@ -0,0 +1,185 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality_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/mixedreality/armmixedreality" +) + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/GetBySubscription.json +func ExampleRemoteRenderingAccountsClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + pager := client.ListBySubscription(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("RemoteRenderingAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/GetByResourceGroup.json +func ExampleRemoteRenderingAccountsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + pager := client.ListByResourceGroup("", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("RemoteRenderingAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Delete.json +func ExampleRemoteRenderingAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Get.json +func ExampleRemoteRenderingAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("RemoteRenderingAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Patch.json +func ExampleRemoteRenderingAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + armmixedreality.RemoteRenderingAccount{ + TrackedResource: armmixedreality.TrackedResource{ + Location: to.StringPtr(""), + Tags: map[string]*string{ + "hero": to.StringPtr("romeo"), + "heroine": to.StringPtr("juliet"), + }, + }, + Identity: &armmixedreality.Identity{ + Type: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("RemoteRenderingAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/Put.json +func ExampleRemoteRenderingAccountsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + res, err := client.Create(ctx, + "", + "", + armmixedreality.RemoteRenderingAccount{ + TrackedResource: armmixedreality.TrackedResource{ + Location: to.StringPtr(""), + }, + Identity: &armmixedreality.Identity{ + Type: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("RemoteRenderingAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/ListKeys.json +func ExampleRemoteRenderingAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + _, err = client.ListKeys(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/remote-rendering/RegenerateKey.json +func ExampleRemoteRenderingAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewRemoteRenderingAccountsClient("", cred, nil) + _, err = client.RegenerateKeys(ctx, + "", + "", + armmixedreality.AccountKeyRegenerateRequest{ + Serial: armmixedreality.SerialPrimary.ToPtr(), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go new file mode 100644 index 000000000000..d82e11ef6966 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/ze_generated_example_spatialanchorsaccounts_client_test.go @@ -0,0 +1,179 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality_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/mixedreality/armmixedreality" +) + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/GetBySubscription.json +func ExampleSpatialAnchorsAccountsClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + pager := client.ListBySubscription(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("SpatialAnchorsAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/GetByResourceGroup.json +func ExampleSpatialAnchorsAccountsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + pager := client.ListByResourceGroup("", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("SpatialAnchorsAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Delete.json +func ExampleSpatialAnchorsAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Get.json +func ExampleSpatialAnchorsAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("SpatialAnchorsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Patch.json +func ExampleSpatialAnchorsAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + armmixedreality.SpatialAnchorsAccount{ + TrackedResource: armmixedreality.TrackedResource{ + Location: to.StringPtr(""), + Tags: map[string]*string{ + "hero": to.StringPtr("romeo"), + "heroine": to.StringPtr("juliet"), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("SpatialAnchorsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/Put.json +func ExampleSpatialAnchorsAccountsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + res, err := client.Create(ctx, + "", + "", + armmixedreality.SpatialAnchorsAccount{ + TrackedResource: armmixedreality.TrackedResource{ + Location: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("SpatialAnchorsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/ListKeys.json +func ExampleSpatialAnchorsAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + _, err = client.ListKeys(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/mixedreality/resource-manager/Microsoft.MixedReality/preview/2021-03-01-preview/examples/spatial-anchors/RegenerateKey.json +func ExampleSpatialAnchorsAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmixedreality.NewSpatialAnchorsAccountsClient("", cred, nil) + _, err = client.RegenerateKeys(ctx, + "", + "", + armmixedreality.AccountKeyRegenerateRequest{ + Serial: armmixedreality.SerialPrimary.ToPtr(), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go new file mode 100644 index 000000000000..663b6d177f37 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_constants.go @@ -0,0 +1,108 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +const ( + module = "armmixedreality" + version = "v0.1.0" +) + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// NameUnavailableReason - reason of name unavailable. +type NameUnavailableReason string + +const ( + NameUnavailableReasonAlreadyExists NameUnavailableReason = "AlreadyExists" + NameUnavailableReasonInvalid NameUnavailableReason = "Invalid" +) + +// PossibleNameUnavailableReasonValues returns the possible values for the NameUnavailableReason const type. +func PossibleNameUnavailableReasonValues() []NameUnavailableReason { + return []NameUnavailableReason{ + NameUnavailableReasonAlreadyExists, + NameUnavailableReasonInvalid, + } +} + +// ToPtr returns a *NameUnavailableReason pointing to the current value. +func (c NameUnavailableReason) ToPtr() *NameUnavailableReason { + return &c +} + +// SKUTier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. +type SKUTier string + +const ( + SKUTierFree SKUTier = "Free" + SKUTierBasic SKUTier = "Basic" + SKUTierStandard SKUTier = "Standard" + SKUTierPremium SKUTier = "Premium" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierFree, + SKUTierBasic, + SKUTierStandard, + SKUTierPremium, + } +} + +// ToPtr returns a *SKUTier pointing to the current value. +func (c SKUTier) ToPtr() *SKUTier { + return &c +} + +// Serial - Serial of key to be regenerated +type Serial int32 + +const ( + // SerialPrimary - The Primary Key + SerialPrimary Serial = 1 + // SerialSecondary - The Secondary Key + SerialSecondary Serial = 2 +) + +// PossibleSerialValues returns the possible values for the Serial const type. +func PossibleSerialValues() []Serial { + return []Serial{ + SerialPrimary, + SerialSecondary, + } +} + +// ToPtr returns a *Serial pointing to the current value. +func (c Serial) ToPtr() *Serial { + return &c +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_mixedrealityclient_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_mixedrealityclient_client.go new file mode 100644 index 000000000000..36d0dd5096d2 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_mixedrealityclient_client.go @@ -0,0 +1,104 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// MixedRealityClient contains the methods for the MixedRealityClient group. +// Don't use this type directly, use NewMixedRealityClient() instead. +type MixedRealityClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewMixedRealityClient creates a new instance of MixedRealityClient with the specified values. +func NewMixedRealityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *MixedRealityClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &MixedRealityClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailabilityLocal - Check Name Availability for local uniqueness +// If the operation fails it returns the *CloudError error type. +func (client *MixedRealityClient) CheckNameAvailabilityLocal(ctx context.Context, location string, checkNameAvailability CheckNameAvailabilityRequest, options *MixedRealityClientCheckNameAvailabilityLocalOptions) (MixedRealityClientCheckNameAvailabilityLocalResponse, error) { + req, err := client.checkNameAvailabilityLocalCreateRequest(ctx, location, checkNameAvailability, options) + if err != nil { + return MixedRealityClientCheckNameAvailabilityLocalResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MixedRealityClientCheckNameAvailabilityLocalResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MixedRealityClientCheckNameAvailabilityLocalResponse{}, client.checkNameAvailabilityLocalHandleError(resp) + } + return client.checkNameAvailabilityLocalHandleResponse(resp) +} + +// checkNameAvailabilityLocalCreateRequest creates the CheckNameAvailabilityLocal request. +func (client *MixedRealityClient) checkNameAvailabilityLocalCreateRequest(ctx context.Context, location string, checkNameAvailability CheckNameAvailabilityRequest, options *MixedRealityClientCheckNameAvailabilityLocalOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.MixedReality/locations/{location}/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, checkNameAvailability) +} + +// checkNameAvailabilityLocalHandleResponse handles the CheckNameAvailabilityLocal response. +func (client *MixedRealityClient) checkNameAvailabilityLocalHandleResponse(resp *http.Response) (MixedRealityClientCheckNameAvailabilityLocalResponse, error) { + result := MixedRealityClientCheckNameAvailabilityLocalResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return MixedRealityClientCheckNameAvailabilityLocalResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityLocalHandleError handles the CheckNameAvailabilityLocal error response. +func (client *MixedRealityClient) checkNameAvailabilityLocalHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go new file mode 100644 index 000000000000..6813b94330df --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_models.go @@ -0,0 +1,729 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AccountKeyRegenerateRequest - Request for account key regeneration +type AccountKeyRegenerateRequest struct { + // Serial of key to be regenerated + Serial *Serial `json:"serial,omitempty"` +} + +// AccountKeys - Developer Keys of account +type AccountKeys struct { + // READ-ONLY; value of primary key. + PrimaryKey *string `json:"primaryKey,omitempty" azure:"ro"` + + // READ-ONLY; value of secondary key. + SecondaryKey *string `json:"secondaryKey,omitempty" azure:"ro"` +} + +// CheckNameAvailabilityRequest - Check Name Availability Request +type CheckNameAvailabilityRequest struct { + // REQUIRED; Resource Name To Verify + Name *string `json:"name,omitempty"` + + // REQUIRED; Fully qualified resource type which includes provider namespace + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResponse - Check Name Availability Response +type CheckNameAvailabilityResponse struct { + // REQUIRED; if name Available + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // detail message + Message *string `json:"message,omitempty"` + + // Resource Name To Verify + Reason *NameUnavailableReason `json:"reason,omitempty"` +} + +// CloudError - An Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // An Error response. + InnerError *CloudErrorBody `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// CloudErrorBody - An error response from Azure. +type CloudErrorBody struct { + // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBody `json:"details,omitempty"` + + // A message describing the error, intended to be suitable for displaying in a user interface. + Message *string `json:"message,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// Identity for the resource. +type Identity struct { + // The identity type. + Type *string `json:"type,omitempty"` + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// LogSpecification - Specifications of the Log for Azure Monitoring +type LogSpecification struct { + // Blob duration of the log + BlobDuration *string `json:"blobDuration,omitempty"` + + // Localized friendly display name of the log + DisplayName *string `json:"displayName,omitempty"` + + // Name of the log + Name *string `json:"name,omitempty"` +} + +// MetricDimension - Specifications of the Dimension of metrics +type MetricDimension struct { + // Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + + // Internal name of the dimension. + InternalName *string `json:"internalName,omitempty"` + + // Name of the dimension + Name *string `json:"name,omitempty"` + + // Flag to indicate export for Shoebox + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// MetricSpecification - Specifications of the Metrics for Azure Monitoring +type MetricSpecification struct { + // Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + + // Metric category + Category *string `json:"category,omitempty"` + + // Dimensions of the metric + Dimensions []*MetricDimension `json:"dimensions,omitempty"` + + // Localized friendly description of the metric + DisplayDescription *string `json:"displayDescription,omitempty"` + + // Localized friendly display name of the metric + DisplayName *string `json:"displayName,omitempty"` + + // Flag to indicate use of regional Mdm accounts + EnableRegionalMdmAccount *bool `json:"enableRegionalMdmAccount,omitempty"` + + // Flag to determine is Zero is returned for time duration where no metric is emitted + FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + + // Internal metric name. + InternalMetricName *string `json:"internalMetricName,omitempty"` + + // Locked aggregation type of the metric + LockedAggregationType *string `json:"lockedAggregationType,omitempty"` + + // Metric filter regex pattern + MetricFilterPattern *string `json:"metricFilterPattern,omitempty"` + + // Name of the metric + Name *string `json:"name,omitempty"` + + // Source mdm account + SourceMdmAccount *string `json:"sourceMdmAccount,omitempty"` + + // Source mdm namespace + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty"` + + // Supported aggregation types. Valid values: Average, Minimum, Maximum, Total, Count. + SupportedAggregationTypes []*string `json:"supportedAggregationTypes,omitempty"` + + // Supported time grains. Valid values: PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H, P1D + SupportedTimeGrainTypes []*string `json:"supportedTimeGrainTypes,omitempty"` + + // Unit that makes sense for the metric + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "enableRegionalMdmAccount", m.EnableRegionalMdmAccount) + populate(objectMap, "fillGapWithZero", m.FillGapWithZero) + populate(objectMap, "internalMetricName", m.InternalMetricName) + populate(objectMap, "lockedAggregationType", m.LockedAggregationType) + populate(objectMap, "metricFilterPattern", m.MetricFilterPattern) + populate(objectMap, "name", m.Name) + populate(objectMap, "sourceMdmAccount", m.SourceMdmAccount) + populate(objectMap, "sourceMdmNamespace", m.SourceMdmNamespace) + populate(objectMap, "supportedAggregationTypes", m.SupportedAggregationTypes) + populate(objectMap, "supportedTimeGrainTypes", m.SupportedTimeGrainTypes) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// MixedRealityAccountProperties - Common Properties shared by Mixed Reality Accounts +type MixedRealityAccountProperties struct { + // The name of the storage account associated with this accountId + StorageAccountName *string `json:"storageAccountName,omitempty"` + + // READ-ONLY; Correspond domain name of certain Spatial Anchors Account + AccountDomain *string `json:"accountDomain,omitempty" azure:"ro"` + + // READ-ONLY; unique id of certain account. + AccountID *string `json:"accountId,omitempty" azure:"ro"` +} + +// MixedRealityClientCheckNameAvailabilityLocalOptions contains the optional parameters for the MixedRealityClient.CheckNameAvailabilityLocal method. +type MixedRealityClientCheckNameAvailabilityLocalOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccount Response. +type ObjectAnchorsAccount struct { + TrackedResource + Identity *ObjectAnchorsAccountIdentity `json:"identity,omitempty"` + + // The kind of account, if supported + Kind *SKU `json:"kind,omitempty"` + + // The plan associated with this account + Plan *Identity `json:"plan,omitempty"` + + // Property bag. + Properties *MixedRealityAccountProperties `json:"properties,omitempty"` + + // The sku associated with this account + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; The system metadata related to an object anchors account. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ObjectAnchorsAccount. +func (o ObjectAnchorsAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + o.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", o.Identity) + populate(objectMap, "kind", o.Kind) + populate(objectMap, "plan", o.Plan) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "sku", o.SKU) + populate(objectMap, "systemData", o.SystemData) + return json.Marshal(objectMap) +} + +type ObjectAnchorsAccountIdentity struct { + Identity +} + +// ObjectAnchorsAccountPage - Result of the request to get resource collection. It contains a list of resources and a URL link to get the next set of results. +type ObjectAnchorsAccountPage struct { + // URL to get the next set of resource list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of resources supported by the Resource Provider. + Value []*ObjectAnchorsAccount `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ObjectAnchorsAccountPage. +func (o ObjectAnchorsAccountPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// ObjectAnchorsAccountsCreateOptions contains the optional parameters for the ObjectAnchorsAccounts.Create method. +type ObjectAnchorsAccountsCreateOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsDeleteOptions contains the optional parameters for the ObjectAnchorsAccounts.Delete method. +type ObjectAnchorsAccountsDeleteOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsGetOptions contains the optional parameters for the ObjectAnchorsAccounts.Get method. +type ObjectAnchorsAccountsGetOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsListByResourceGroupOptions contains the optional parameters for the ObjectAnchorsAccounts.ListByResourceGroup method. +type ObjectAnchorsAccountsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsListBySubscriptionOptions contains the optional parameters for the ObjectAnchorsAccounts.ListBySubscription method. +type ObjectAnchorsAccountsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsListKeysOptions contains the optional parameters for the ObjectAnchorsAccounts.ListKeys method. +type ObjectAnchorsAccountsListKeysOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsRegenerateKeysOptions contains the optional parameters for the ObjectAnchorsAccounts.RegenerateKeys method. +type ObjectAnchorsAccountsRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// ObjectAnchorsAccountsUpdateOptions contains the optional parameters for the ObjectAnchorsAccounts.Update method. +type ObjectAnchorsAccountsUpdateOptions struct { + // placeholder for future optional parameters +} + +// Operation - REST API operation +type Operation struct { + // The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Whether or not this is a data plane operation + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + + // The origin + Origin *string `json:"origin,omitempty"` + + // Properties of the operation + Properties *OperationProperties `json:"properties,omitempty"` +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // REQUIRED; Description of operation + Description *string `json:"description,omitempty"` + + // REQUIRED; Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // REQUIRED; Service provider: Microsoft.ResourceProvider + Provider *string `json:"provider,omitempty"` + + // REQUIRED; Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"resource,omitempty"` +} + +// OperationPage - Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. +type OperationPage struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of operations supported by the Resource Provider. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationPage. +func (o OperationPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationProperties - Operation properties. +type OperationProperties struct { + // Service specification. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccount Response. +type RemoteRenderingAccount struct { + TrackedResource + // The identity associated with this account + Identity *Identity `json:"identity,omitempty"` + + // The kind of account, if supported + Kind *SKU `json:"kind,omitempty"` + + // The plan associated with this account + Plan *Identity `json:"plan,omitempty"` + + // Property bag. + Properties *MixedRealityAccountProperties `json:"properties,omitempty"` + + // The sku associated with this account + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; System metadata for this account + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RemoteRenderingAccount. +func (r RemoteRenderingAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", r.Identity) + populate(objectMap, "kind", r.Kind) + populate(objectMap, "plan", r.Plan) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "systemData", r.SystemData) + return json.Marshal(objectMap) +} + +// RemoteRenderingAccountPage - Result of the request to get resource collection. It contains a list of resources and a URL link to get the next set of +// results. +type RemoteRenderingAccountPage struct { + // URL to get the next set of resource list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of resources supported by the Resource Provider. + Value []*RemoteRenderingAccount `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RemoteRenderingAccountPage. +func (r RemoteRenderingAccountPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RemoteRenderingAccountsCreateOptions contains the optional parameters for the RemoteRenderingAccounts.Create method. +type RemoteRenderingAccountsCreateOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsDeleteOptions contains the optional parameters for the RemoteRenderingAccounts.Delete method. +type RemoteRenderingAccountsDeleteOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsGetOptions contains the optional parameters for the RemoteRenderingAccounts.Get method. +type RemoteRenderingAccountsGetOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsListByResourceGroupOptions contains the optional parameters for the RemoteRenderingAccounts.ListByResourceGroup method. +type RemoteRenderingAccountsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsListBySubscriptionOptions contains the optional parameters for the RemoteRenderingAccounts.ListBySubscription method. +type RemoteRenderingAccountsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsListKeysOptions contains the optional parameters for the RemoteRenderingAccounts.ListKeys method. +type RemoteRenderingAccountsListKeysOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsRegenerateKeysOptions contains the optional parameters for the RemoteRenderingAccounts.RegenerateKeys method. +type RemoteRenderingAccountsRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// RemoteRenderingAccountsUpdateOptions contains the optional parameters for the RemoteRenderingAccounts.Update method. +type RemoteRenderingAccountsUpdateOptions struct { + // placeholder for future optional parameters +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// SKU - The resource model definition representing SKU +type SKU struct { + // REQUIRED; The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string `json:"name,omitempty"` + + // If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. + Capacity *int32 `json:"capacity,omitempty"` + + // If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + + // The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string `json:"size,omitempty"` + + // This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. + Tier *SKUTier `json:"tier,omitempty"` +} + +// ServiceSpecification - Service specification payload +type ServiceSpecification struct { + // Specifications of the Log for Azure Monitoring + LogSpecifications []*LogSpecification `json:"logSpecifications,omitempty"` + + // Specifications of the Metrics for Azure Monitoring + MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "logSpecifications", s.LogSpecifications) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +// SpatialAnchorsAccount Response. +type SpatialAnchorsAccount struct { + TrackedResource + // The identity associated with this account + Identity *Identity `json:"identity,omitempty"` + + // The kind of account, if supported + Kind *SKU `json:"kind,omitempty"` + + // The plan associated with this account + Plan *Identity `json:"plan,omitempty"` + + // Property bag. + Properties *MixedRealityAccountProperties `json:"properties,omitempty"` + + // The sku associated with this account + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; System metadata for this account + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SpatialAnchorsAccount. +func (s SpatialAnchorsAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "plan", s.Plan) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "systemData", s.SystemData) + return json.Marshal(objectMap) +} + +// SpatialAnchorsAccountPage - Result of the request to get resource collection. It contains a list of resources and a URL link to get the next set of results. +type SpatialAnchorsAccountPage struct { + // URL to get the next set of resource list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of resources supported by the Resource Provider. + Value []*SpatialAnchorsAccount `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SpatialAnchorsAccountPage. +func (s SpatialAnchorsAccountPage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SpatialAnchorsAccountsCreateOptions contains the optional parameters for the SpatialAnchorsAccounts.Create method. +type SpatialAnchorsAccountsCreateOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsDeleteOptions contains the optional parameters for the SpatialAnchorsAccounts.Delete method. +type SpatialAnchorsAccountsDeleteOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsGetOptions contains the optional parameters for the SpatialAnchorsAccounts.Get method. +type SpatialAnchorsAccountsGetOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsListByResourceGroupOptions contains the optional parameters for the SpatialAnchorsAccounts.ListByResourceGroup method. +type SpatialAnchorsAccountsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsListBySubscriptionOptions contains the optional parameters for the SpatialAnchorsAccounts.ListBySubscription method. +type SpatialAnchorsAccountsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsListKeysOptions contains the optional parameters for the SpatialAnchorsAccounts.ListKeys method. +type SpatialAnchorsAccountsListKeysOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsRegenerateKeysOptions contains the optional parameters for the SpatialAnchorsAccounts.RegenerateKeys method. +type SpatialAnchorsAccountsRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// SpatialAnchorsAccountsUpdateOptions contains the optional parameters for the SpatialAnchorsAccounts.Update method. +type SpatialAnchorsAccountsUpdateOptions struct { + // placeholder for future optional parameters +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +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/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go new file mode 100644 index 000000000000..cac209e9f74b --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_objectanchorsaccounts_client.go @@ -0,0 +1,536 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ObjectAnchorsAccountsClient contains the methods for the ObjectAnchorsAccounts group. +// Don't use this type directly, use NewObjectAnchorsAccountsClient() instead. +type ObjectAnchorsAccountsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewObjectAnchorsAccountsClient creates a new instance of ObjectAnchorsAccountsClient with the specified values. +func NewObjectAnchorsAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ObjectAnchorsAccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ObjectAnchorsAccountsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Create - Creating or Updating an object anchors Account. +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, objectAnchorsAccount ObjectAnchorsAccount, options *ObjectAnchorsAccountsCreateOptions) (ObjectAnchorsAccountsCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, objectAnchorsAccount, options) + if err != nil { + return ObjectAnchorsAccountsCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ObjectAnchorsAccountsCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return ObjectAnchorsAccountsCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *ObjectAnchorsAccountsClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, objectAnchorsAccount ObjectAnchorsAccount, options *ObjectAnchorsAccountsCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, objectAnchorsAccount) +} + +// createHandleResponse handles the Create response. +func (client *ObjectAnchorsAccountsClient) createHandleResponse(resp *http.Response) (ObjectAnchorsAccountsCreateResponse, error) { + result := ObjectAnchorsAccountsCreateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ObjectAnchorsAccount); err != nil { + return ObjectAnchorsAccountsCreateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *ObjectAnchorsAccountsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete an Object Anchors Account. +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsDeleteOptions) (ObjectAnchorsAccountsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return ObjectAnchorsAccountsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ObjectAnchorsAccountsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ObjectAnchorsAccountsDeleteResponse{}, client.deleteHandleError(resp) + } + return ObjectAnchorsAccountsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ObjectAnchorsAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ObjectAnchorsAccountsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Retrieve an Object Anchors Account. +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsGetOptions) (ObjectAnchorsAccountsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return ObjectAnchorsAccountsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ObjectAnchorsAccountsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ObjectAnchorsAccountsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ObjectAnchorsAccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ObjectAnchorsAccountsClient) getHandleResponse(resp *http.Response) (ObjectAnchorsAccountsGetResponse, error) { + result := ObjectAnchorsAccountsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ObjectAnchorsAccount); err != nil { + return ObjectAnchorsAccountsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ObjectAnchorsAccountsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - List Resources by Resource Group +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) ListByResourceGroup(resourceGroupName string, options *ObjectAnchorsAccountsListByResourceGroupOptions) *ObjectAnchorsAccountsListByResourceGroupPager { + return &ObjectAnchorsAccountsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ObjectAnchorsAccountsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ObjectAnchorsAccountPage.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ObjectAnchorsAccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ObjectAnchorsAccountsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ObjectAnchorsAccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (ObjectAnchorsAccountsListByResourceGroupResponse, error) { + result := ObjectAnchorsAccountsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ObjectAnchorsAccountPage); err != nil { + return ObjectAnchorsAccountsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ObjectAnchorsAccountsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - List Object Anchors Accounts by Subscription +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) ListBySubscription(options *ObjectAnchorsAccountsListBySubscriptionOptions) *ObjectAnchorsAccountsListBySubscriptionPager { + return &ObjectAnchorsAccountsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ObjectAnchorsAccountsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ObjectAnchorsAccountPage.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ObjectAnchorsAccountsClient) listBySubscriptionCreateRequest(ctx context.Context, options *ObjectAnchorsAccountsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.MixedReality/objectAnchorsAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ObjectAnchorsAccountsClient) listBySubscriptionHandleResponse(resp *http.Response) (ObjectAnchorsAccountsListBySubscriptionResponse, error) { + result := ObjectAnchorsAccountsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ObjectAnchorsAccountPage); err != nil { + return ObjectAnchorsAccountsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ObjectAnchorsAccountsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListKeys - List Both of the 2 Keys of an object anchors Account +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsListKeysOptions) (ObjectAnchorsAccountsListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return ObjectAnchorsAccountsListKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ObjectAnchorsAccountsListKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ObjectAnchorsAccountsListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *ObjectAnchorsAccountsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *ObjectAnchorsAccountsListKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts/{accountName}/listKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *ObjectAnchorsAccountsClient) listKeysHandleResponse(resp *http.Response) (ObjectAnchorsAccountsListKeysResponse, error) { + result := ObjectAnchorsAccountsListKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountKeys); err != nil { + return ObjectAnchorsAccountsListKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *ObjectAnchorsAccountsClient) listKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// RegenerateKeys - Regenerate specified Key of an object anchors Account +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *ObjectAnchorsAccountsRegenerateKeysOptions) (ObjectAnchorsAccountsRegenerateKeysResponse, error) { + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, regenerate, options) + if err != nil { + return ObjectAnchorsAccountsRegenerateKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ObjectAnchorsAccountsRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ObjectAnchorsAccountsRegenerateKeysResponse{}, client.regenerateKeysHandleError(resp) + } + return client.regenerateKeysHandleResponse(resp) +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *ObjectAnchorsAccountsClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *ObjectAnchorsAccountsRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts/{accountName}/regenerateKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, regenerate) +} + +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *ObjectAnchorsAccountsClient) regenerateKeysHandleResponse(resp *http.Response) (ObjectAnchorsAccountsRegenerateKeysResponse, error) { + result := ObjectAnchorsAccountsRegenerateKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountKeys); err != nil { + return ObjectAnchorsAccountsRegenerateKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// regenerateKeysHandleError handles the RegenerateKeys error response. +func (client *ObjectAnchorsAccountsClient) regenerateKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updating an Object Anchors Account +// If the operation fails it returns the *CloudError error type. +func (client *ObjectAnchorsAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, objectAnchorsAccount ObjectAnchorsAccount, options *ObjectAnchorsAccountsUpdateOptions) (ObjectAnchorsAccountsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, objectAnchorsAccount, options) + if err != nil { + return ObjectAnchorsAccountsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ObjectAnchorsAccountsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ObjectAnchorsAccountsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ObjectAnchorsAccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, objectAnchorsAccount ObjectAnchorsAccount, options *ObjectAnchorsAccountsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/objectAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, objectAnchorsAccount) +} + +// updateHandleResponse handles the Update response. +func (client *ObjectAnchorsAccountsClient) updateHandleResponse(resp *http.Response) (ObjectAnchorsAccountsUpdateResponse, error) { + result := ObjectAnchorsAccountsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ObjectAnchorsAccount); err != nil { + return ObjectAnchorsAccountsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ObjectAnchorsAccountsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go new file mode 100644 index 000000000000..715e850e322c --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Exposing Available Operations +// If the operation fails it returns the *CloudError error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationPage.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.MixedReality/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationPage); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_pagers.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_pagers.go new file mode 100644 index 000000000000..9dccebf6141d --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_pagers.go @@ -0,0 +1,395 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// ObjectAnchorsAccountsListByResourceGroupPager provides operations for iterating over paged responses. +type ObjectAnchorsAccountsListByResourceGroupPager struct { + client *ObjectAnchorsAccountsClient + current ObjectAnchorsAccountsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ObjectAnchorsAccountsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ObjectAnchorsAccountsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ObjectAnchorsAccountsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ObjectAnchorsAccountPage.NextLink == nil || len(*p.current.ObjectAnchorsAccountPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ObjectAnchorsAccountsListByResourceGroupResponse page. +func (p *ObjectAnchorsAccountsListByResourceGroupPager) PageResponse() ObjectAnchorsAccountsListByResourceGroupResponse { + return p.current +} + +// ObjectAnchorsAccountsListBySubscriptionPager provides operations for iterating over paged responses. +type ObjectAnchorsAccountsListBySubscriptionPager struct { + client *ObjectAnchorsAccountsClient + current ObjectAnchorsAccountsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ObjectAnchorsAccountsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ObjectAnchorsAccountsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ObjectAnchorsAccountsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ObjectAnchorsAccountPage.NextLink == nil || len(*p.current.ObjectAnchorsAccountPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ObjectAnchorsAccountsListBySubscriptionResponse page. +func (p *ObjectAnchorsAccountsListBySubscriptionPager) PageResponse() ObjectAnchorsAccountsListBySubscriptionResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationPage.NextLink == nil || len(*p.current.OperationPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// RemoteRenderingAccountsListByResourceGroupPager provides operations for iterating over paged responses. +type RemoteRenderingAccountsListByResourceGroupPager struct { + client *RemoteRenderingAccountsClient + current RemoteRenderingAccountsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, RemoteRenderingAccountsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *RemoteRenderingAccountsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *RemoteRenderingAccountsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RemoteRenderingAccountPage.NextLink == nil || len(*p.current.RemoteRenderingAccountPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current RemoteRenderingAccountsListByResourceGroupResponse page. +func (p *RemoteRenderingAccountsListByResourceGroupPager) PageResponse() RemoteRenderingAccountsListByResourceGroupResponse { + return p.current +} + +// RemoteRenderingAccountsListBySubscriptionPager provides operations for iterating over paged responses. +type RemoteRenderingAccountsListBySubscriptionPager struct { + client *RemoteRenderingAccountsClient + current RemoteRenderingAccountsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, RemoteRenderingAccountsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *RemoteRenderingAccountsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *RemoteRenderingAccountsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RemoteRenderingAccountPage.NextLink == nil || len(*p.current.RemoteRenderingAccountPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current RemoteRenderingAccountsListBySubscriptionResponse page. +func (p *RemoteRenderingAccountsListBySubscriptionPager) PageResponse() RemoteRenderingAccountsListBySubscriptionResponse { + return p.current +} + +// SpatialAnchorsAccountsListByResourceGroupPager provides operations for iterating over paged responses. +type SpatialAnchorsAccountsListByResourceGroupPager struct { + client *SpatialAnchorsAccountsClient + current SpatialAnchorsAccountsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, SpatialAnchorsAccountsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *SpatialAnchorsAccountsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *SpatialAnchorsAccountsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SpatialAnchorsAccountPage.NextLink == nil || len(*p.current.SpatialAnchorsAccountPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current SpatialAnchorsAccountsListByResourceGroupResponse page. +func (p *SpatialAnchorsAccountsListByResourceGroupPager) PageResponse() SpatialAnchorsAccountsListByResourceGroupResponse { + return p.current +} + +// SpatialAnchorsAccountsListBySubscriptionPager provides operations for iterating over paged responses. +type SpatialAnchorsAccountsListBySubscriptionPager struct { + client *SpatialAnchorsAccountsClient + current SpatialAnchorsAccountsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, SpatialAnchorsAccountsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *SpatialAnchorsAccountsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *SpatialAnchorsAccountsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SpatialAnchorsAccountPage.NextLink == nil || len(*p.current.SpatialAnchorsAccountPage.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current SpatialAnchorsAccountsListBySubscriptionResponse page. +func (p *SpatialAnchorsAccountsListBySubscriptionPager) PageResponse() SpatialAnchorsAccountsListBySubscriptionResponse { + return p.current +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go new file mode 100644 index 000000000000..76b1bb16eace --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_remoterenderingaccounts_client.go @@ -0,0 +1,536 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// RemoteRenderingAccountsClient contains the methods for the RemoteRenderingAccounts group. +// Don't use this type directly, use NewRemoteRenderingAccountsClient() instead. +type RemoteRenderingAccountsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewRemoteRenderingAccountsClient creates a new instance of RemoteRenderingAccountsClient with the specified values. +func NewRemoteRenderingAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *RemoteRenderingAccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &RemoteRenderingAccountsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Create - Creating or Updating a Remote Rendering Account. +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, remoteRenderingAccount RemoteRenderingAccount, options *RemoteRenderingAccountsCreateOptions) (RemoteRenderingAccountsCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, remoteRenderingAccount, options) + if err != nil { + return RemoteRenderingAccountsCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RemoteRenderingAccountsCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return RemoteRenderingAccountsCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *RemoteRenderingAccountsClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, remoteRenderingAccount RemoteRenderingAccount, options *RemoteRenderingAccountsCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, remoteRenderingAccount) +} + +// createHandleResponse handles the Create response. +func (client *RemoteRenderingAccountsClient) createHandleResponse(resp *http.Response) (RemoteRenderingAccountsCreateResponse, error) { + result := RemoteRenderingAccountsCreateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RemoteRenderingAccount); err != nil { + return RemoteRenderingAccountsCreateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *RemoteRenderingAccountsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Remote Rendering Account. +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsDeleteOptions) (RemoteRenderingAccountsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return RemoteRenderingAccountsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RemoteRenderingAccountsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return RemoteRenderingAccountsDeleteResponse{}, client.deleteHandleError(resp) + } + return RemoteRenderingAccountsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RemoteRenderingAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *RemoteRenderingAccountsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Retrieve a Remote Rendering Account. +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsGetOptions) (RemoteRenderingAccountsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return RemoteRenderingAccountsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RemoteRenderingAccountsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RemoteRenderingAccountsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RemoteRenderingAccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RemoteRenderingAccountsClient) getHandleResponse(resp *http.Response) (RemoteRenderingAccountsGetResponse, error) { + result := RemoteRenderingAccountsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RemoteRenderingAccount); err != nil { + return RemoteRenderingAccountsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *RemoteRenderingAccountsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - List Resources by Resource Group +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) ListByResourceGroup(resourceGroupName string, options *RemoteRenderingAccountsListByResourceGroupOptions) *RemoteRenderingAccountsListByResourceGroupPager { + return &RemoteRenderingAccountsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp RemoteRenderingAccountsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.RemoteRenderingAccountPage.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *RemoteRenderingAccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *RemoteRenderingAccountsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *RemoteRenderingAccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (RemoteRenderingAccountsListByResourceGroupResponse, error) { + result := RemoteRenderingAccountsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RemoteRenderingAccountPage); err != nil { + return RemoteRenderingAccountsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *RemoteRenderingAccountsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - List Remote Rendering Accounts by Subscription +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) ListBySubscription(options *RemoteRenderingAccountsListBySubscriptionOptions) *RemoteRenderingAccountsListBySubscriptionPager { + return &RemoteRenderingAccountsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp RemoteRenderingAccountsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.RemoteRenderingAccountPage.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *RemoteRenderingAccountsClient) listBySubscriptionCreateRequest(ctx context.Context, options *RemoteRenderingAccountsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.MixedReality/remoteRenderingAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *RemoteRenderingAccountsClient) listBySubscriptionHandleResponse(resp *http.Response) (RemoteRenderingAccountsListBySubscriptionResponse, error) { + result := RemoteRenderingAccountsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RemoteRenderingAccountPage); err != nil { + return RemoteRenderingAccountsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *RemoteRenderingAccountsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListKeys - List Both of the 2 Keys of a Remote Rendering Account +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsListKeysOptions) (RemoteRenderingAccountsListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return RemoteRenderingAccountsListKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RemoteRenderingAccountsListKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RemoteRenderingAccountsListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *RemoteRenderingAccountsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *RemoteRenderingAccountsListKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts/{accountName}/listKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *RemoteRenderingAccountsClient) listKeysHandleResponse(resp *http.Response) (RemoteRenderingAccountsListKeysResponse, error) { + result := RemoteRenderingAccountsListKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountKeys); err != nil { + return RemoteRenderingAccountsListKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *RemoteRenderingAccountsClient) listKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// RegenerateKeys - Regenerate specified Key of a Remote Rendering Account +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *RemoteRenderingAccountsRegenerateKeysOptions) (RemoteRenderingAccountsRegenerateKeysResponse, error) { + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, regenerate, options) + if err != nil { + return RemoteRenderingAccountsRegenerateKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RemoteRenderingAccountsRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RemoteRenderingAccountsRegenerateKeysResponse{}, client.regenerateKeysHandleError(resp) + } + return client.regenerateKeysHandleResponse(resp) +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *RemoteRenderingAccountsClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *RemoteRenderingAccountsRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts/{accountName}/regenerateKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, regenerate) +} + +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *RemoteRenderingAccountsClient) regenerateKeysHandleResponse(resp *http.Response) (RemoteRenderingAccountsRegenerateKeysResponse, error) { + result := RemoteRenderingAccountsRegenerateKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountKeys); err != nil { + return RemoteRenderingAccountsRegenerateKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// regenerateKeysHandleError handles the RegenerateKeys error response. +func (client *RemoteRenderingAccountsClient) regenerateKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updating a Remote Rendering Account +// If the operation fails it returns the *CloudError error type. +func (client *RemoteRenderingAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, remoteRenderingAccount RemoteRenderingAccount, options *RemoteRenderingAccountsUpdateOptions) (RemoteRenderingAccountsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, remoteRenderingAccount, options) + if err != nil { + return RemoteRenderingAccountsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RemoteRenderingAccountsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RemoteRenderingAccountsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *RemoteRenderingAccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, remoteRenderingAccount RemoteRenderingAccount, options *RemoteRenderingAccountsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/remoteRenderingAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, remoteRenderingAccount) +} + +// updateHandleResponse handles the Update response. +func (client *RemoteRenderingAccountsClient) updateHandleResponse(resp *http.Response) (RemoteRenderingAccountsUpdateResponse, error) { + result := RemoteRenderingAccountsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RemoteRenderingAccount); err != nil { + return RemoteRenderingAccountsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *RemoteRenderingAccountsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go new file mode 100644 index 000000000000..a1a1af2a8c2f --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_response_types.go @@ -0,0 +1,305 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import "net/http" + +// MixedRealityClientCheckNameAvailabilityLocalResponse contains the response from method MixedRealityClient.CheckNameAvailabilityLocal. +type MixedRealityClientCheckNameAvailabilityLocalResponse struct { + MixedRealityClientCheckNameAvailabilityLocalResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MixedRealityClientCheckNameAvailabilityLocalResult contains the result from method MixedRealityClient.CheckNameAvailabilityLocal. +type MixedRealityClientCheckNameAvailabilityLocalResult struct { + CheckNameAvailabilityResponse +} + +// ObjectAnchorsAccountsCreateResponse contains the response from method ObjectAnchorsAccounts.Create. +type ObjectAnchorsAccountsCreateResponse struct { + ObjectAnchorsAccountsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsCreateResult contains the result from method ObjectAnchorsAccounts.Create. +type ObjectAnchorsAccountsCreateResult struct { + ObjectAnchorsAccount +} + +// ObjectAnchorsAccountsDeleteResponse contains the response from method ObjectAnchorsAccounts.Delete. +type ObjectAnchorsAccountsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsGetResponse contains the response from method ObjectAnchorsAccounts.Get. +type ObjectAnchorsAccountsGetResponse struct { + ObjectAnchorsAccountsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsGetResult contains the result from method ObjectAnchorsAccounts.Get. +type ObjectAnchorsAccountsGetResult struct { + ObjectAnchorsAccount +} + +// ObjectAnchorsAccountsListByResourceGroupResponse contains the response from method ObjectAnchorsAccounts.ListByResourceGroup. +type ObjectAnchorsAccountsListByResourceGroupResponse struct { + ObjectAnchorsAccountsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsListByResourceGroupResult contains the result from method ObjectAnchorsAccounts.ListByResourceGroup. +type ObjectAnchorsAccountsListByResourceGroupResult struct { + ObjectAnchorsAccountPage +} + +// ObjectAnchorsAccountsListBySubscriptionResponse contains the response from method ObjectAnchorsAccounts.ListBySubscription. +type ObjectAnchorsAccountsListBySubscriptionResponse struct { + ObjectAnchorsAccountsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsListBySubscriptionResult contains the result from method ObjectAnchorsAccounts.ListBySubscription. +type ObjectAnchorsAccountsListBySubscriptionResult struct { + ObjectAnchorsAccountPage +} + +// ObjectAnchorsAccountsListKeysResponse contains the response from method ObjectAnchorsAccounts.ListKeys. +type ObjectAnchorsAccountsListKeysResponse struct { + ObjectAnchorsAccountsListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsListKeysResult contains the result from method ObjectAnchorsAccounts.ListKeys. +type ObjectAnchorsAccountsListKeysResult struct { + AccountKeys +} + +// ObjectAnchorsAccountsRegenerateKeysResponse contains the response from method ObjectAnchorsAccounts.RegenerateKeys. +type ObjectAnchorsAccountsRegenerateKeysResponse struct { + ObjectAnchorsAccountsRegenerateKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsRegenerateKeysResult contains the result from method ObjectAnchorsAccounts.RegenerateKeys. +type ObjectAnchorsAccountsRegenerateKeysResult struct { + AccountKeys +} + +// ObjectAnchorsAccountsUpdateResponse contains the response from method ObjectAnchorsAccounts.Update. +type ObjectAnchorsAccountsUpdateResponse struct { + ObjectAnchorsAccountsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectAnchorsAccountsUpdateResult contains the result from method ObjectAnchorsAccounts.Update. +type ObjectAnchorsAccountsUpdateResult struct { + ObjectAnchorsAccount +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationPage +} + +// RemoteRenderingAccountsCreateResponse contains the response from method RemoteRenderingAccounts.Create. +type RemoteRenderingAccountsCreateResponse struct { + RemoteRenderingAccountsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsCreateResult contains the result from method RemoteRenderingAccounts.Create. +type RemoteRenderingAccountsCreateResult struct { + RemoteRenderingAccount +} + +// RemoteRenderingAccountsDeleteResponse contains the response from method RemoteRenderingAccounts.Delete. +type RemoteRenderingAccountsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsGetResponse contains the response from method RemoteRenderingAccounts.Get. +type RemoteRenderingAccountsGetResponse struct { + RemoteRenderingAccountsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsGetResult contains the result from method RemoteRenderingAccounts.Get. +type RemoteRenderingAccountsGetResult struct { + RemoteRenderingAccount +} + +// RemoteRenderingAccountsListByResourceGroupResponse contains the response from method RemoteRenderingAccounts.ListByResourceGroup. +type RemoteRenderingAccountsListByResourceGroupResponse struct { + RemoteRenderingAccountsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsListByResourceGroupResult contains the result from method RemoteRenderingAccounts.ListByResourceGroup. +type RemoteRenderingAccountsListByResourceGroupResult struct { + RemoteRenderingAccountPage +} + +// RemoteRenderingAccountsListBySubscriptionResponse contains the response from method RemoteRenderingAccounts.ListBySubscription. +type RemoteRenderingAccountsListBySubscriptionResponse struct { + RemoteRenderingAccountsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsListBySubscriptionResult contains the result from method RemoteRenderingAccounts.ListBySubscription. +type RemoteRenderingAccountsListBySubscriptionResult struct { + RemoteRenderingAccountPage +} + +// RemoteRenderingAccountsListKeysResponse contains the response from method RemoteRenderingAccounts.ListKeys. +type RemoteRenderingAccountsListKeysResponse struct { + RemoteRenderingAccountsListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsListKeysResult contains the result from method RemoteRenderingAccounts.ListKeys. +type RemoteRenderingAccountsListKeysResult struct { + AccountKeys +} + +// RemoteRenderingAccountsRegenerateKeysResponse contains the response from method RemoteRenderingAccounts.RegenerateKeys. +type RemoteRenderingAccountsRegenerateKeysResponse struct { + RemoteRenderingAccountsRegenerateKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsRegenerateKeysResult contains the result from method RemoteRenderingAccounts.RegenerateKeys. +type RemoteRenderingAccountsRegenerateKeysResult struct { + AccountKeys +} + +// RemoteRenderingAccountsUpdateResponse contains the response from method RemoteRenderingAccounts.Update. +type RemoteRenderingAccountsUpdateResponse struct { + RemoteRenderingAccountsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RemoteRenderingAccountsUpdateResult contains the result from method RemoteRenderingAccounts.Update. +type RemoteRenderingAccountsUpdateResult struct { + RemoteRenderingAccount +} + +// SpatialAnchorsAccountsCreateResponse contains the response from method SpatialAnchorsAccounts.Create. +type SpatialAnchorsAccountsCreateResponse struct { + SpatialAnchorsAccountsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsCreateResult contains the result from method SpatialAnchorsAccounts.Create. +type SpatialAnchorsAccountsCreateResult struct { + SpatialAnchorsAccount +} + +// SpatialAnchorsAccountsDeleteResponse contains the response from method SpatialAnchorsAccounts.Delete. +type SpatialAnchorsAccountsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsGetResponse contains the response from method SpatialAnchorsAccounts.Get. +type SpatialAnchorsAccountsGetResponse struct { + SpatialAnchorsAccountsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsGetResult contains the result from method SpatialAnchorsAccounts.Get. +type SpatialAnchorsAccountsGetResult struct { + SpatialAnchorsAccount +} + +// SpatialAnchorsAccountsListByResourceGroupResponse contains the response from method SpatialAnchorsAccounts.ListByResourceGroup. +type SpatialAnchorsAccountsListByResourceGroupResponse struct { + SpatialAnchorsAccountsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsListByResourceGroupResult contains the result from method SpatialAnchorsAccounts.ListByResourceGroup. +type SpatialAnchorsAccountsListByResourceGroupResult struct { + SpatialAnchorsAccountPage +} + +// SpatialAnchorsAccountsListBySubscriptionResponse contains the response from method SpatialAnchorsAccounts.ListBySubscription. +type SpatialAnchorsAccountsListBySubscriptionResponse struct { + SpatialAnchorsAccountsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsListBySubscriptionResult contains the result from method SpatialAnchorsAccounts.ListBySubscription. +type SpatialAnchorsAccountsListBySubscriptionResult struct { + SpatialAnchorsAccountPage +} + +// SpatialAnchorsAccountsListKeysResponse contains the response from method SpatialAnchorsAccounts.ListKeys. +type SpatialAnchorsAccountsListKeysResponse struct { + SpatialAnchorsAccountsListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsListKeysResult contains the result from method SpatialAnchorsAccounts.ListKeys. +type SpatialAnchorsAccountsListKeysResult struct { + AccountKeys +} + +// SpatialAnchorsAccountsRegenerateKeysResponse contains the response from method SpatialAnchorsAccounts.RegenerateKeys. +type SpatialAnchorsAccountsRegenerateKeysResponse struct { + SpatialAnchorsAccountsRegenerateKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsRegenerateKeysResult contains the result from method SpatialAnchorsAccounts.RegenerateKeys. +type SpatialAnchorsAccountsRegenerateKeysResult struct { + AccountKeys +} + +// SpatialAnchorsAccountsUpdateResponse contains the response from method SpatialAnchorsAccounts.Update. +type SpatialAnchorsAccountsUpdateResponse struct { + SpatialAnchorsAccountsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SpatialAnchorsAccountsUpdateResult contains the result from method SpatialAnchorsAccounts.Update. +type SpatialAnchorsAccountsUpdateResult struct { + SpatialAnchorsAccount +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go new file mode 100644 index 000000000000..48e4e7e86bea --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_spatialanchorsaccounts_client.go @@ -0,0 +1,536 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// SpatialAnchorsAccountsClient contains the methods for the SpatialAnchorsAccounts group. +// Don't use this type directly, use NewSpatialAnchorsAccountsClient() instead. +type SpatialAnchorsAccountsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewSpatialAnchorsAccountsClient creates a new instance of SpatialAnchorsAccountsClient with the specified values. +func NewSpatialAnchorsAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *SpatialAnchorsAccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &SpatialAnchorsAccountsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Create - Creating or Updating a Spatial Anchors Account. +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, spatialAnchorsAccount SpatialAnchorsAccount, options *SpatialAnchorsAccountsCreateOptions) (SpatialAnchorsAccountsCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, spatialAnchorsAccount, options) + if err != nil { + return SpatialAnchorsAccountsCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpatialAnchorsAccountsCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return SpatialAnchorsAccountsCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *SpatialAnchorsAccountsClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, spatialAnchorsAccount SpatialAnchorsAccount, options *SpatialAnchorsAccountsCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, spatialAnchorsAccount) +} + +// createHandleResponse handles the Create response. +func (client *SpatialAnchorsAccountsClient) createHandleResponse(resp *http.Response) (SpatialAnchorsAccountsCreateResponse, error) { + result := SpatialAnchorsAccountsCreateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccount); err != nil { + return SpatialAnchorsAccountsCreateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *SpatialAnchorsAccountsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Spatial Anchors Account. +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsDeleteOptions) (SpatialAnchorsAccountsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return SpatialAnchorsAccountsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpatialAnchorsAccountsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return SpatialAnchorsAccountsDeleteResponse{}, client.deleteHandleError(resp) + } + return SpatialAnchorsAccountsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SpatialAnchorsAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *SpatialAnchorsAccountsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Retrieve a Spatial Anchors Account. +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsGetOptions) (SpatialAnchorsAccountsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return SpatialAnchorsAccountsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpatialAnchorsAccountsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpatialAnchorsAccountsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SpatialAnchorsAccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SpatialAnchorsAccountsClient) getHandleResponse(resp *http.Response) (SpatialAnchorsAccountsGetResponse, error) { + result := SpatialAnchorsAccountsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccount); err != nil { + return SpatialAnchorsAccountsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SpatialAnchorsAccountsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - List Resources by Resource Group +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) ListByResourceGroup(resourceGroupName string, options *SpatialAnchorsAccountsListByResourceGroupOptions) *SpatialAnchorsAccountsListByResourceGroupPager { + return &SpatialAnchorsAccountsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp SpatialAnchorsAccountsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.SpatialAnchorsAccountPage.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *SpatialAnchorsAccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *SpatialAnchorsAccountsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *SpatialAnchorsAccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (SpatialAnchorsAccountsListByResourceGroupResponse, error) { + result := SpatialAnchorsAccountsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccountPage); err != nil { + return SpatialAnchorsAccountsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *SpatialAnchorsAccountsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - List Spatial Anchors Accounts by Subscription +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) ListBySubscription(options *SpatialAnchorsAccountsListBySubscriptionOptions) *SpatialAnchorsAccountsListBySubscriptionPager { + return &SpatialAnchorsAccountsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp SpatialAnchorsAccountsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.SpatialAnchorsAccountPage.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *SpatialAnchorsAccountsClient) listBySubscriptionCreateRequest(ctx context.Context, options *SpatialAnchorsAccountsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.MixedReality/spatialAnchorsAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *SpatialAnchorsAccountsClient) listBySubscriptionHandleResponse(resp *http.Response) (SpatialAnchorsAccountsListBySubscriptionResponse, error) { + result := SpatialAnchorsAccountsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccountPage); err != nil { + return SpatialAnchorsAccountsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *SpatialAnchorsAccountsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListKeys - List Both of the 2 Keys of a Spatial Anchors Account +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsListKeysOptions) (SpatialAnchorsAccountsListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return SpatialAnchorsAccountsListKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpatialAnchorsAccountsListKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpatialAnchorsAccountsListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *SpatialAnchorsAccountsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsListKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}/listKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *SpatialAnchorsAccountsClient) listKeysHandleResponse(resp *http.Response) (SpatialAnchorsAccountsListKeysResponse, error) { + result := SpatialAnchorsAccountsListKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountKeys); err != nil { + return SpatialAnchorsAccountsListKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *SpatialAnchorsAccountsClient) listKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// RegenerateKeys - Regenerate specified Key of a Spatial Anchors Account +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *SpatialAnchorsAccountsRegenerateKeysOptions) (SpatialAnchorsAccountsRegenerateKeysResponse, error) { + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, regenerate, options) + if err != nil { + return SpatialAnchorsAccountsRegenerateKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpatialAnchorsAccountsRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpatialAnchorsAccountsRegenerateKeysResponse{}, client.regenerateKeysHandleError(resp) + } + return client.regenerateKeysHandleResponse(resp) +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *SpatialAnchorsAccountsClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, regenerate AccountKeyRegenerateRequest, options *SpatialAnchorsAccountsRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}/regenerateKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, regenerate) +} + +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *SpatialAnchorsAccountsClient) regenerateKeysHandleResponse(resp *http.Response) (SpatialAnchorsAccountsRegenerateKeysResponse, error) { + result := SpatialAnchorsAccountsRegenerateKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountKeys); err != nil { + return SpatialAnchorsAccountsRegenerateKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// regenerateKeysHandleError handles the RegenerateKeys error response. +func (client *SpatialAnchorsAccountsClient) regenerateKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updating a Spatial Anchors Account +// If the operation fails it returns the *CloudError error type. +func (client *SpatialAnchorsAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, spatialAnchorsAccount SpatialAnchorsAccount, options *SpatialAnchorsAccountsUpdateOptions) (SpatialAnchorsAccountsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, spatialAnchorsAccount, options) + if err != nil { + return SpatialAnchorsAccountsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SpatialAnchorsAccountsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SpatialAnchorsAccountsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *SpatialAnchorsAccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, spatialAnchorsAccount SpatialAnchorsAccount, options *SpatialAnchorsAccountsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, spatialAnchorsAccount) +} + +// updateHandleResponse handles the Update response. +func (client *SpatialAnchorsAccountsClient) updateHandleResponse(resp *http.Response) (SpatialAnchorsAccountsUpdateResponse, error) { + result := SpatialAnchorsAccountsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccount); err != nil { + return SpatialAnchorsAccountsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *SpatialAnchorsAccountsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..6a5c42e9c353 --- /dev/null +++ b/sdk/resourcemanager/mixedreality/armmixedreality/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmixedreality + +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 +}