From d0f90464af2e6d71eb42297cc41a3969f17ecee1 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 7 Dec 2021 02:55:43 +0000 Subject: [PATCH] CodeGen from PR 16949 in Azure/azure-rest-api-specs Track2 modify readme.go.md 6 (#16949) * Track2 modify readme.go.md 6 * mariadb derective description --- .../armmanagedservices/CHANGELOG.md | 5 + .../armmanagedservices/LICENSE.txt | 21 + .../armmanagedservices/README.md | 75 +++ .../armmanagedservices/autorest.md | 13 + .../armmanagedservices/build.go | 7 + .../managedservices/armmanagedservices/ci.yml | 27 + .../managedservices/armmanagedservices/go.mod | 8 + .../managedservices/armmanagedservices/go.sum | 37 ++ .../armmanagedservices/go_mod_tidy_hack.go | 13 + .../zz_generated_constants.go | 76 +++ ...rketplaceregistrationdefinitions_client.go | 154 ++++++ ...istrationdefinitionswithoutscope_client.go | 152 +++++ .../armmanagedservices/zz_generated_models.go | 523 ++++++++++++++++++ .../zz_generated_operations_client.go | 92 +++ .../armmanagedservices/zz_generated_pagers.go | 233 ++++++++ .../zz_generated_pollers.go | 144 +++++ ...enerated_registrationassignments_client.go | 296 ++++++++++ ...enerated_registrationdefinitions_client.go | 269 +++++++++ .../zz_generated_response_types.go | 280 ++++++++++ 19 files changed, 2425 insertions(+) create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/CHANGELOG.md create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/LICENSE.txt create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/README.md create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/autorest.md create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/build.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/ci.yml create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/go.mod create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/go.sum create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_constants.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitions_client.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitionswithoutscope_client.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_models.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationassignments_client.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationdefinitions_client.go create mode 100644 sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_response_types.go diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/CHANGELOG.md b/sdk/resourcemanager/managedservices/armmanagedservices/CHANGELOG.md new file mode 100644 index 000000000000..925a954ff70d --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-07) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/LICENSE.txt b/sdk/resourcemanager/managedservices/armmanagedservices/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/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/managedservices/armmanagedservices/README.md b/sdk/resourcemanager/managedservices/armmanagedservices/README.md new file mode 100644 index 000000000000..8390a0f1467b --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/README.md @@ -0,0 +1,75 @@ +# Azure Managedservices Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managedservices/armmanagedservices)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managedservices/armmanagedservices) + +The `armmanagedservices` module provides operations for working with Azure Managedservices. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/managedservices/armmanagedservices) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Managedservices module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managedservices/armmanagedservices +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Managedservices. 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 Managedservices 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 := armmanagedservices.(, 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 := armmanagedservices.(, 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 `Managedservices` 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/managedservices/armmanagedservices/autorest.md b/sdk/resourcemanager/managedservices/armmanagedservices/autorest.md new file mode 100644 index 000000000000..6a38fdfeab49 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/managedservices/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/managedservices/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/managedservices/armmanagedservices/build.go b/sdk/resourcemanager/managedservices/armmanagedservices/build.go new file mode 100644 index 000000000000..8d48b773b1f8 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/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/managedservices/armmanagedservices + +package armmanagedservices diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/ci.yml b/sdk/resourcemanager/managedservices/armmanagedservices/ci.yml new file mode 100644 index 000000000000..6ad23905f0b3 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/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/managedservices/armmanagedservices/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/managedservices/armmanagedservices/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/managedservices/armmanagedservices' diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/go.mod b/sdk/resourcemanager/managedservices/armmanagedservices/go.mod new file mode 100644 index 000000000000..9352b8d8d5e2 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managedservices/armmanagedservices + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.0.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/go.sum b/sdk/resourcemanager/managedservices/armmanagedservices/go.sum new file mode 100644 index 000000000000..4cb1a2cbfc46 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible h1:vVRJhSSTwhIHQTzTjqoZCItFJeBwfdNSqHcgGV10FHQ= +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/go_mod_tidy_hack.go b/sdk/resourcemanager/managedservices/armmanagedservices/go_mod_tidy_hack.go new file mode 100644 index 000000000000..80374af33fdd --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/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 armmanagedservices + +// 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/managedservices/armmanagedservices/zz_generated_constants.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_constants.go new file mode 100644 index 000000000000..6a583fec1dd0 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_constants.go @@ -0,0 +1,76 @@ +//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 armmanagedservices + +const ( + module = "armmanagedservices" + version = "v0.1.0" +) + +// MultiFactorAuthProvider - The multi-factor authorization provider to be used for just-in-time access requests. +type MultiFactorAuthProvider string + +const ( + MultiFactorAuthProviderAzure MultiFactorAuthProvider = "Azure" + MultiFactorAuthProviderNone MultiFactorAuthProvider = "None" +) + +// PossibleMultiFactorAuthProviderValues returns the possible values for the MultiFactorAuthProvider const type. +func PossibleMultiFactorAuthProviderValues() []MultiFactorAuthProvider { + return []MultiFactorAuthProvider{ + MultiFactorAuthProviderAzure, + MultiFactorAuthProviderNone, + } +} + +// ToPtr returns a *MultiFactorAuthProvider pointing to the current value. +func (c MultiFactorAuthProvider) ToPtr() *MultiFactorAuthProvider { + return &c +} + +// ProvisioningState - The current provisioning state of the registration definition. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateReady ProvisioningState = "Ready" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreated, + ProvisioningStateCreating, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateNotSpecified, + ProvisioningStateReady, + ProvisioningStateRunning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitions_client.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitions_client.go new file mode 100644 index 000000000000..f935d371a989 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitions_client.go @@ -0,0 +1,154 @@ +//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 armmanagedservices + +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" +) + +// MarketplaceRegistrationDefinitionsClient contains the methods for the MarketplaceRegistrationDefinitions group. +// Don't use this type directly, use NewMarketplaceRegistrationDefinitionsClient() instead. +type MarketplaceRegistrationDefinitionsClient struct { + ep string + pl runtime.Pipeline +} + +// NewMarketplaceRegistrationDefinitionsClient creates a new instance of MarketplaceRegistrationDefinitionsClient with the specified values. +func NewMarketplaceRegistrationDefinitionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *MarketplaceRegistrationDefinitionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &MarketplaceRegistrationDefinitionsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get the marketplace registration definition for the marketplace identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MarketplaceRegistrationDefinitionsClient) Get(ctx context.Context, scope string, marketplaceIdentifier string, options *MarketplaceRegistrationDefinitionsGetOptions) (MarketplaceRegistrationDefinitionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, scope, marketplaceIdentifier, options) + if err != nil { + return MarketplaceRegistrationDefinitionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MarketplaceRegistrationDefinitionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MarketplaceRegistrationDefinitionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *MarketplaceRegistrationDefinitionsClient) getCreateRequest(ctx context.Context, scope string, marketplaceIdentifier string, options *MarketplaceRegistrationDefinitionsGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if marketplaceIdentifier == "" { + return nil, errors.New("parameter marketplaceIdentifier cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{marketplaceIdentifier}", url.PathEscape(marketplaceIdentifier)) + 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", "2020-02-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 *MarketplaceRegistrationDefinitionsClient) getHandleResponse(resp *http.Response) (MarketplaceRegistrationDefinitionsGetResponse, error) { + result := MarketplaceRegistrationDefinitionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MarketplaceRegistrationDefinition); err != nil { + return MarketplaceRegistrationDefinitionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *MarketplaceRegistrationDefinitionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets a list of the marketplace registration definitions for the marketplace identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MarketplaceRegistrationDefinitionsClient) List(scope string, options *MarketplaceRegistrationDefinitionsListOptions) *MarketplaceRegistrationDefinitionsListPager { + return &MarketplaceRegistrationDefinitionsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, scope, options) + }, + advancer: func(ctx context.Context, resp MarketplaceRegistrationDefinitionsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MarketplaceRegistrationDefinitionList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *MarketplaceRegistrationDefinitionsClient) listCreateRequest(ctx context.Context, scope string, options *MarketplaceRegistrationDefinitionsListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + reqQP.Set("api-version", "2020-02-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 *MarketplaceRegistrationDefinitionsClient) listHandleResponse(resp *http.Response) (MarketplaceRegistrationDefinitionsListResponse, error) { + result := MarketplaceRegistrationDefinitionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MarketplaceRegistrationDefinitionList); err != nil { + return MarketplaceRegistrationDefinitionsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *MarketplaceRegistrationDefinitionsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitionswithoutscope_client.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitionswithoutscope_client.go new file mode 100644 index 000000000000..c56348be126c --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_marketplaceregistrationdefinitionswithoutscope_client.go @@ -0,0 +1,152 @@ +//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 armmanagedservices + +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" +) + +// MarketplaceRegistrationDefinitionsWithoutScopeClient contains the methods for the MarketplaceRegistrationDefinitionsWithoutScope group. +// Don't use this type directly, use NewMarketplaceRegistrationDefinitionsWithoutScopeClient() instead. +type MarketplaceRegistrationDefinitionsWithoutScopeClient struct { + ep string + pl runtime.Pipeline +} + +// NewMarketplaceRegistrationDefinitionsWithoutScopeClient creates a new instance of MarketplaceRegistrationDefinitionsWithoutScopeClient with the specified values. +func NewMarketplaceRegistrationDefinitionsWithoutScopeClient(credential azcore.TokenCredential, options *arm.ClientOptions) *MarketplaceRegistrationDefinitionsWithoutScopeClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &MarketplaceRegistrationDefinitionsWithoutScopeClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get the marketplace registration definition for the marketplace identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MarketplaceRegistrationDefinitionsWithoutScopeClient) Get(ctx context.Context, marketplaceIdentifier string, options *MarketplaceRegistrationDefinitionsWithoutScopeGetOptions) (MarketplaceRegistrationDefinitionsWithoutScopeGetResponse, error) { + req, err := client.getCreateRequest(ctx, marketplaceIdentifier, options) + if err != nil { + return MarketplaceRegistrationDefinitionsWithoutScopeGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MarketplaceRegistrationDefinitionsWithoutScopeGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MarketplaceRegistrationDefinitionsWithoutScopeGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *MarketplaceRegistrationDefinitionsWithoutScopeClient) getCreateRequest(ctx context.Context, marketplaceIdentifier string, options *MarketplaceRegistrationDefinitionsWithoutScopeGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}" + if marketplaceIdentifier == "" { + return nil, errors.New("parameter marketplaceIdentifier cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{marketplaceIdentifier}", url.PathEscape(marketplaceIdentifier)) + 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", "2020-02-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 *MarketplaceRegistrationDefinitionsWithoutScopeClient) getHandleResponse(resp *http.Response) (MarketplaceRegistrationDefinitionsWithoutScopeGetResponse, error) { + result := MarketplaceRegistrationDefinitionsWithoutScopeGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MarketplaceRegistrationDefinition); err != nil { + return MarketplaceRegistrationDefinitionsWithoutScopeGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *MarketplaceRegistrationDefinitionsWithoutScopeClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets a list of the marketplace registration definitions for the marketplace identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MarketplaceRegistrationDefinitionsWithoutScopeClient) List(options *MarketplaceRegistrationDefinitionsWithoutScopeListOptions) *MarketplaceRegistrationDefinitionsWithoutScopeListPager { + return &MarketplaceRegistrationDefinitionsWithoutScopeListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp MarketplaceRegistrationDefinitionsWithoutScopeListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MarketplaceRegistrationDefinitionList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *MarketplaceRegistrationDefinitionsWithoutScopeClient) listCreateRequest(ctx context.Context, options *MarketplaceRegistrationDefinitionsWithoutScopeListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + reqQP.Set("api-version", "2020-02-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 *MarketplaceRegistrationDefinitionsWithoutScopeClient) listHandleResponse(resp *http.Response) (MarketplaceRegistrationDefinitionsWithoutScopeListResponse, error) { + result := MarketplaceRegistrationDefinitionsWithoutScopeListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MarketplaceRegistrationDefinitionList); err != nil { + return MarketplaceRegistrationDefinitionsWithoutScopeListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *MarketplaceRegistrationDefinitionsWithoutScopeClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_models.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_models.go new file mode 100644 index 000000000000..af20d8ad643e --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_models.go @@ -0,0 +1,523 @@ +//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 armmanagedservices + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// Authorization - The Azure Active Directory principal identifier and Azure built-in role that describes the access the principal will receive on the delegated +// resource in the managed tenant. +type Authorization struct { + // REQUIRED; The identifier of the Azure Active Directory principal. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; The identifier of the Azure built-in role that defines the permissions that the Azure Active Directory principal will have on the projected + // scope. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + + // The delegatedRoleDefinitionIds field is required when the roleDefinitionId refers to the User Access Administrator Role. It is the list of role definition + // ids which define all the permissions that the + // user in the authorization can assign to other principals. + DelegatedRoleDefinitionIDs []*string `json:"delegatedRoleDefinitionIds,omitempty"` + + // The display name of the Azure Active Directory principal. + PrincipalIDDisplayName *string `json:"principalIdDisplayName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Authorization. +func (a Authorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "delegatedRoleDefinitionIds", a.DelegatedRoleDefinitionIDs) + populate(objectMap, "principalId", a.PrincipalID) + populate(objectMap, "principalIdDisplayName", a.PrincipalIDDisplayName) + populate(objectMap, "roleDefinitionId", a.RoleDefinitionID) + return json.Marshal(objectMap) +} + +// EligibleApprover - Defines the Azure Active Directory principal that can approve any just-in-time access requests by the principal defined in the EligibleAuthorization. +type EligibleApprover struct { + // REQUIRED; The identifier of the Azure Active Directory principal. + PrincipalID *string `json:"principalId,omitempty"` + + // The display name of the Azure Active Directory principal. + PrincipalIDDisplayName *string `json:"principalIdDisplayName,omitempty"` +} + +// EligibleAuthorization - The Azure Active Directory principal identifier, Azure built-in role, and just-in-time access policy that describes the just-in-time +// access the principal will receive on the delegated resource in the +// managed tenant. +type EligibleAuthorization struct { + // REQUIRED; The identifier of the Azure Active Directory principal. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; The identifier of the Azure built-in role that defines the permissions that the Azure Active Directory principal will have on the projected + // scope. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + + // The just-in-time access policy setting. + JustInTimeAccessPolicy *JustInTimeAccessPolicy `json:"justInTimeAccessPolicy,omitempty"` + + // The display name of the Azure Active Directory principal. + PrincipalIDDisplayName *string `json:"principalIdDisplayName,omitempty"` +} + +// ErrorDefinition - The error response indicating why the incoming request wasn’t able to be processed +type ErrorDefinition struct { + // REQUIRED; The error code. + Code *string `json:"code,omitempty"` + + // REQUIRED; The error message indicating why the operation failed. + Message *string `json:"message,omitempty"` + + // The internal error details. + Details []*ErrorDefinition `json:"details,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. +func (e ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// ErrorResponse - Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error details. + InnerError *ErrorDefinition `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// JustInTimeAccessPolicy - Just-in-time access policy setting. +type JustInTimeAccessPolicy struct { + // REQUIRED; The multi-factor authorization provider to be used for just-in-time access requests. + MultiFactorAuthProvider *MultiFactorAuthProvider `json:"multiFactorAuthProvider,omitempty"` + + // The list of managedByTenant approvers for the eligible authorization. + ManagedByTenantApprovers []*EligibleApprover `json:"managedByTenantApprovers,omitempty"` + + // The maximum access duration in ISO 8601 format for just-in-time access requests. + MaximumActivationDuration *string `json:"maximumActivationDuration,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type JustInTimeAccessPolicy. +func (j JustInTimeAccessPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "managedByTenantApprovers", j.ManagedByTenantApprovers) + populate(objectMap, "maximumActivationDuration", j.MaximumActivationDuration) + populate(objectMap, "multiFactorAuthProvider", j.MultiFactorAuthProvider) + return json.Marshal(objectMap) +} + +type MarketplaceRegistrationDefinition struct { + // The details for the Managed Services offer’s plan in Azure Marketplace. + Plan *Plan `json:"plan,omitempty"` + + // The properties of the marketplace registration definition. + Properties *MarketplaceRegistrationDefinitionProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified path of the marketplace registration definition. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the marketplace registration definition. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the Azure resource (Microsoft.ManagedServices/marketplaceRegistrationDefinitions). + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarketplaceRegistrationDefinitionList - The list of marketplace registration definitions. +type MarketplaceRegistrationDefinitionList struct { + // READ-ONLY; The link to the next page of marketplace registration definitions. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of marketplace registration definitions. + Value []*MarketplaceRegistrationDefinition `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MarketplaceRegistrationDefinitionList. +func (m MarketplaceRegistrationDefinitionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MarketplaceRegistrationDefinitionProperties - The properties of the marketplace registration definition. +type MarketplaceRegistrationDefinitionProperties struct { + // REQUIRED; The collection of authorization objects describing the access Azure Active Directory principals in the managedBy tenant will receive on the + // delegated resource in the managed tenant. + Authorizations []*Authorization `json:"authorizations,omitempty"` + + // REQUIRED; The identifier of the managedBy tenant. + ManagedByTenantID *string `json:"managedByTenantId,omitempty"` + + // The collection of eligible authorization objects describing the just-in-time access Azure Active Directory principals in the managedBy tenant will receive + // on the delegated resource in the managed + // tenant. + EligibleAuthorizations []*EligibleAuthorization `json:"eligibleAuthorizations,omitempty"` + + // The marketplace offer display name. + OfferDisplayName *string `json:"offerDisplayName,omitempty"` + + // The marketplace plan display name. + PlanDisplayName *string `json:"planDisplayName,omitempty"` + + // The marketplace publisher display name. + PublisherDisplayName *string `json:"publisherDisplayName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MarketplaceRegistrationDefinitionProperties. +func (m MarketplaceRegistrationDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizations", m.Authorizations) + populate(objectMap, "eligibleAuthorizations", m.EligibleAuthorizations) + populate(objectMap, "managedByTenantId", m.ManagedByTenantID) + populate(objectMap, "offerDisplayName", m.OfferDisplayName) + populate(objectMap, "planDisplayName", m.PlanDisplayName) + populate(objectMap, "publisherDisplayName", m.PublisherDisplayName) + return json.Marshal(objectMap) +} + +// MarketplaceRegistrationDefinitionsGetOptions contains the optional parameters for the MarketplaceRegistrationDefinitions.Get method. +type MarketplaceRegistrationDefinitionsGetOptions struct { + // placeholder for future optional parameters +} + +// MarketplaceRegistrationDefinitionsListOptions contains the optional parameters for the MarketplaceRegistrationDefinitions.List method. +type MarketplaceRegistrationDefinitionsListOptions struct { + // The filter query parameter to filter marketplace registration definitions by plan identifier, publisher, version etc. + Filter *string +} + +// MarketplaceRegistrationDefinitionsWithoutScopeGetOptions contains the optional parameters for the MarketplaceRegistrationDefinitionsWithoutScope.Get +// method. +type MarketplaceRegistrationDefinitionsWithoutScopeGetOptions struct { + // placeholder for future optional parameters +} + +// MarketplaceRegistrationDefinitionsWithoutScopeListOptions contains the optional parameters for the MarketplaceRegistrationDefinitionsWithoutScope.List +// method. +type MarketplaceRegistrationDefinitionsWithoutScopeListOptions struct { + // The filter query parameter to filter marketplace registration definitions by plan identifier, publisher, version etc. + Filter *string +} + +// Operation - The object that describes a single Microsoft.ManagedServices operation. +type Operation struct { + // READ-ONLY; The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; The operation name with the format: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty" azure:"ro"` +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // The description of the operation. + Description *string `json:"description,omitempty"` + + // The operation type. + Operation *string `json:"operation,omitempty"` + + // The service provider. + Provider *string `json:"provider,omitempty"` + + // The resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationList - The list of the operations. +type OperationList struct { + // READ-ONLY; The list of Microsoft.ManagedServices operations. + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// Plan - The details for the Managed Services offer’s plan in Azure Marketplace. +type Plan struct { + // REQUIRED; Azure Marketplace plan name. + Name *string `json:"name,omitempty"` + + // REQUIRED; Azure Marketplace product code. + Product *string `json:"product,omitempty"` + + // REQUIRED; Azure Marketplace publisher ID. + Publisher *string `json:"publisher,omitempty"` + + // REQUIRED; Azure Marketplace plan's version. + Version *string `json:"version,omitempty"` +} + +// RegistrationAssignment - The registration assignment. +type RegistrationAssignment struct { + // The properties of a registration assignment. + Properties *RegistrationAssignmentProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified path of the registration assignment. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the registration assignment. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the Azure resource (Microsoft.ManagedServices/registrationAssignments). + Type *string `json:"type,omitempty" azure:"ro"` +} + +// RegistrationAssignmentList - The list of registration assignments. +type RegistrationAssignmentList struct { + // READ-ONLY; The link to the next page of registration assignments. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of registration assignments. + Value []*RegistrationAssignment `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistrationAssignmentList. +func (r RegistrationAssignmentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RegistrationAssignmentProperties - The properties of the registration assignment. +type RegistrationAssignmentProperties struct { + // REQUIRED; The fully qualified path of the registration definition. + RegistrationDefinitionID *string `json:"registrationDefinitionId,omitempty"` + + // READ-ONLY; The current provisioning state of the registration assignment. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The registration definition associated with the registration assignment. + RegistrationDefinition *RegistrationAssignmentPropertiesRegistrationDefinition `json:"registrationDefinition,omitempty" azure:"ro"` +} + +// RegistrationAssignmentPropertiesRegistrationDefinition - The registration definition associated with the registration assignment. +type RegistrationAssignmentPropertiesRegistrationDefinition struct { + // The details for the Managed Services offer’s plan in Azure Marketplace. + Plan *Plan `json:"plan,omitempty"` + + // The properties of the registration definition associated with the registration assignment. + Properties *RegistrationAssignmentPropertiesRegistrationDefinitionProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified path of the registration definition. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the registration definition. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the Azure resource (Microsoft.ManagedServices/registrationDefinitions). + Type *string `json:"type,omitempty" azure:"ro"` +} + +// RegistrationAssignmentPropertiesRegistrationDefinitionProperties - The properties of the registration definition associated with the registration assignment. +type RegistrationAssignmentPropertiesRegistrationDefinitionProperties struct { + // The collection of authorization objects describing the access Azure Active Directory principals in the managedBy tenant will receive on the delegated + // resource in the managed tenant. + Authorizations []*Authorization `json:"authorizations,omitempty"` + + // The description of the registration definition. + Description *string `json:"description,omitempty"` + + // The collection of eligible authorization objects describing the just-in-time access Azure Active Directory principals in the managedBy tenant will receive + // on the delegated resource in the managed + // tenant. + EligibleAuthorizations []*EligibleAuthorization `json:"eligibleAuthorizations,omitempty"` + + // The identifier of the managedBy tenant. + ManagedByTenantID *string `json:"managedByTenantId,omitempty"` + + // The name of the managedBy tenant. + ManagedByTenantName *string `json:"managedByTenantName,omitempty"` + + // The identifier of the managed tenant. + ManageeTenantID *string `json:"manageeTenantId,omitempty"` + + // The name of the managed tenant. + ManageeTenantName *string `json:"manageeTenantName,omitempty"` + + // The current provisioning state of the registration definition. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // The name of the registration definition. + RegistrationDefinitionName *string `json:"registrationDefinitionName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistrationAssignmentPropertiesRegistrationDefinitionProperties. +func (r RegistrationAssignmentPropertiesRegistrationDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizations", r.Authorizations) + populate(objectMap, "description", r.Description) + populate(objectMap, "eligibleAuthorizations", r.EligibleAuthorizations) + populate(objectMap, "managedByTenantId", r.ManagedByTenantID) + populate(objectMap, "managedByTenantName", r.ManagedByTenantName) + populate(objectMap, "manageeTenantId", r.ManageeTenantID) + populate(objectMap, "manageeTenantName", r.ManageeTenantName) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "registrationDefinitionName", r.RegistrationDefinitionName) + return json.Marshal(objectMap) +} + +// RegistrationAssignmentsBeginCreateOrUpdateOptions contains the optional parameters for the RegistrationAssignments.BeginCreateOrUpdate method. +type RegistrationAssignmentsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// RegistrationAssignmentsBeginDeleteOptions contains the optional parameters for the RegistrationAssignments.BeginDelete method. +type RegistrationAssignmentsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// RegistrationAssignmentsGetOptions contains the optional parameters for the RegistrationAssignments.Get method. +type RegistrationAssignmentsGetOptions struct { + // The flag indicating whether to return the registration definition details along with the registration assignment details. + ExpandRegistrationDefinition *bool +} + +// RegistrationAssignmentsListOptions contains the optional parameters for the RegistrationAssignments.List method. +type RegistrationAssignmentsListOptions struct { + // The flag indicating whether to return the registration definition details along with the registration assignment details. + ExpandRegistrationDefinition *bool +} + +// RegistrationDefinition - The registration definition. +type RegistrationDefinition struct { + // The details for the Managed Services offer’s plan in Azure Marketplace. + Plan *Plan `json:"plan,omitempty"` + + // The properties of a registration definition. + Properties *RegistrationDefinitionProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified path of the registration definition. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the registration definition. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the Azure resource (Microsoft.ManagedServices/registrationDefinitions). + Type *string `json:"type,omitempty" azure:"ro"` +} + +// RegistrationDefinitionList - The list of registration definitions. +type RegistrationDefinitionList struct { + // READ-ONLY; The link to the next page of registration definitions. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of registration definitions. + Value []*RegistrationDefinition `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistrationDefinitionList. +func (r RegistrationDefinitionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RegistrationDefinitionProperties - The properties of a registration definition. +type RegistrationDefinitionProperties struct { + // REQUIRED; The collection of authorization objects describing the access Azure Active Directory principals in the managedBy tenant will receive on the + // delegated resource in the managed tenant. + Authorizations []*Authorization `json:"authorizations,omitempty"` + + // REQUIRED; The identifier of the managedBy tenant. + ManagedByTenantID *string `json:"managedByTenantId,omitempty"` + + // The description of the registration definition. + Description *string `json:"description,omitempty"` + + // The collection of eligible authorization objects describing the just-in-time access Azure Active Directory principals in the managedBy tenant will receive + // on the delegated resource in the managed + // tenant. + EligibleAuthorizations []*EligibleAuthorization `json:"eligibleAuthorizations,omitempty"` + + // The name of the registration definition. + RegistrationDefinitionName *string `json:"registrationDefinitionName,omitempty"` + + // READ-ONLY; The name of the managedBy tenant. + ManagedByTenantName *string `json:"managedByTenantName,omitempty" azure:"ro"` + + // READ-ONLY; The identifier of the managed tenant. + ManageeTenantID *string `json:"manageeTenantId,omitempty" azure:"ro"` + + // READ-ONLY; The name of the managed tenant. + ManageeTenantName *string `json:"manageeTenantName,omitempty" azure:"ro"` + + // READ-ONLY; The current provisioning state of the registration definition. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistrationDefinitionProperties. +func (r RegistrationDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizations", r.Authorizations) + populate(objectMap, "description", r.Description) + populate(objectMap, "eligibleAuthorizations", r.EligibleAuthorizations) + populate(objectMap, "managedByTenantId", r.ManagedByTenantID) + populate(objectMap, "managedByTenantName", r.ManagedByTenantName) + populate(objectMap, "manageeTenantId", r.ManageeTenantID) + populate(objectMap, "manageeTenantName", r.ManageeTenantName) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "registrationDefinitionName", r.RegistrationDefinitionName) + return json.Marshal(objectMap) +} + +// RegistrationDefinitionsBeginCreateOrUpdateOptions contains the optional parameters for the RegistrationDefinitions.BeginCreateOrUpdate method. +type RegistrationDefinitionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// RegistrationDefinitionsDeleteOptions contains the optional parameters for the RegistrationDefinitions.Delete method. +type RegistrationDefinitionsDeleteOptions struct { + // placeholder for future optional parameters +} + +// RegistrationDefinitionsGetOptions contains the optional parameters for the RegistrationDefinitions.Get method. +type RegistrationDefinitionsGetOptions struct { + // placeholder for future optional parameters +} + +// RegistrationDefinitionsListOptions contains the optional parameters for the RegistrationDefinitions.List method. +type RegistrationDefinitionsListOptions struct { + // placeholder for future optional parameters +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_operations_client.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_operations_client.go new file mode 100644 index 000000000000..4a0e0a325acc --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_operations_client.go @@ -0,0 +1,92 @@ +//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 armmanagedservices + +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 - Gets a list of the operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ManagedServices/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", "2020-02-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.OperationList); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pagers.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pagers.go new file mode 100644 index 000000000000..5af2b22473fb --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pagers.go @@ -0,0 +1,233 @@ +//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 armmanagedservices + +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" +) + +// MarketplaceRegistrationDefinitionsListPager provides operations for iterating over paged responses. +type MarketplaceRegistrationDefinitionsListPager struct { + client *MarketplaceRegistrationDefinitionsClient + current MarketplaceRegistrationDefinitionsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MarketplaceRegistrationDefinitionsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MarketplaceRegistrationDefinitionsListPager) 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 *MarketplaceRegistrationDefinitionsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MarketplaceRegistrationDefinitionList.NextLink == nil || len(*p.current.MarketplaceRegistrationDefinitionList.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 MarketplaceRegistrationDefinitionsListResponse page. +func (p *MarketplaceRegistrationDefinitionsListPager) PageResponse() MarketplaceRegistrationDefinitionsListResponse { + return p.current +} + +// MarketplaceRegistrationDefinitionsWithoutScopeListPager provides operations for iterating over paged responses. +type MarketplaceRegistrationDefinitionsWithoutScopeListPager struct { + client *MarketplaceRegistrationDefinitionsWithoutScopeClient + current MarketplaceRegistrationDefinitionsWithoutScopeListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MarketplaceRegistrationDefinitionsWithoutScopeListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MarketplaceRegistrationDefinitionsWithoutScopeListPager) 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 *MarketplaceRegistrationDefinitionsWithoutScopeListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MarketplaceRegistrationDefinitionList.NextLink == nil || len(*p.current.MarketplaceRegistrationDefinitionList.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 MarketplaceRegistrationDefinitionsWithoutScopeListResponse page. +func (p *MarketplaceRegistrationDefinitionsWithoutScopeListPager) PageResponse() MarketplaceRegistrationDefinitionsWithoutScopeListResponse { + return p.current +} + +// RegistrationAssignmentsListPager provides operations for iterating over paged responses. +type RegistrationAssignmentsListPager struct { + client *RegistrationAssignmentsClient + current RegistrationAssignmentsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, RegistrationAssignmentsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *RegistrationAssignmentsListPager) 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 *RegistrationAssignmentsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RegistrationAssignmentList.NextLink == nil || len(*p.current.RegistrationAssignmentList.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 RegistrationAssignmentsListResponse page. +func (p *RegistrationAssignmentsListPager) PageResponse() RegistrationAssignmentsListResponse { + return p.current +} + +// RegistrationDefinitionsListPager provides operations for iterating over paged responses. +type RegistrationDefinitionsListPager struct { + client *RegistrationDefinitionsClient + current RegistrationDefinitionsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, RegistrationDefinitionsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *RegistrationDefinitionsListPager) 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 *RegistrationDefinitionsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RegistrationDefinitionList.NextLink == nil || len(*p.current.RegistrationDefinitionList.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 RegistrationDefinitionsListResponse page. +func (p *RegistrationDefinitionsListPager) PageResponse() RegistrationDefinitionsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pollers.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pollers.go new file mode 100644 index 000000000000..9ff61e003993 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_pollers.go @@ -0,0 +1,144 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmanagedservices + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// RegistrationAssignmentsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type RegistrationAssignmentsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *RegistrationAssignmentsCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *RegistrationAssignmentsCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final RegistrationAssignmentsCreateOrUpdateResponse will be returned. +func (p *RegistrationAssignmentsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (RegistrationAssignmentsCreateOrUpdateResponse, error) { + respType := RegistrationAssignmentsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.RegistrationAssignment) + if err != nil { + return RegistrationAssignmentsCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *RegistrationAssignmentsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// RegistrationAssignmentsDeletePoller provides polling facilities until the operation reaches a terminal state. +type RegistrationAssignmentsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *RegistrationAssignmentsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *RegistrationAssignmentsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final RegistrationAssignmentsDeleteResponse will be returned. +func (p *RegistrationAssignmentsDeletePoller) FinalResponse(ctx context.Context) (RegistrationAssignmentsDeleteResponse, error) { + respType := RegistrationAssignmentsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return RegistrationAssignmentsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *RegistrationAssignmentsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// RegistrationDefinitionsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type RegistrationDefinitionsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *RegistrationDefinitionsCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *RegistrationDefinitionsCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final RegistrationDefinitionsCreateOrUpdateResponse will be returned. +func (p *RegistrationDefinitionsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (RegistrationDefinitionsCreateOrUpdateResponse, error) { + respType := RegistrationDefinitionsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.RegistrationDefinition) + if err != nil { + return RegistrationDefinitionsCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *RegistrationDefinitionsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationassignments_client.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationassignments_client.go new file mode 100644 index 000000000000..4dc450a429f6 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationassignments_client.go @@ -0,0 +1,296 @@ +//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 armmanagedservices + +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" + "strconv" + "strings" +) + +// RegistrationAssignmentsClient contains the methods for the RegistrationAssignments group. +// Don't use this type directly, use NewRegistrationAssignmentsClient() instead. +type RegistrationAssignmentsClient struct { + ep string + pl runtime.Pipeline +} + +// NewRegistrationAssignmentsClient creates a new instance of RegistrationAssignmentsClient with the specified values. +func NewRegistrationAssignmentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *RegistrationAssignmentsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &RegistrationAssignmentsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Creates or updates a registration assignment. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationAssignmentsClient) BeginCreateOrUpdate(ctx context.Context, scope string, registrationAssignmentID string, requestBody RegistrationAssignment, options *RegistrationAssignmentsBeginCreateOrUpdateOptions) (RegistrationAssignmentsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, scope, registrationAssignmentID, requestBody, options) + if err != nil { + return RegistrationAssignmentsCreateOrUpdatePollerResponse{}, err + } + result := RegistrationAssignmentsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("RegistrationAssignmentsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return RegistrationAssignmentsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &RegistrationAssignmentsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a registration assignment. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationAssignmentsClient) createOrUpdate(ctx context.Context, scope string, registrationAssignmentID string, requestBody RegistrationAssignment, options *RegistrationAssignmentsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, scope, registrationAssignmentID, requestBody, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RegistrationAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, registrationAssignmentID string, requestBody RegistrationAssignment, options *RegistrationAssignmentsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if registrationAssignmentID == "" { + return nil, errors.New("parameter registrationAssignmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationAssignmentId}", url.PathEscape(registrationAssignmentID)) + 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", "2020-02-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, requestBody) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *RegistrationAssignmentsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Deletes the specified registration assignment. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationAssignmentsClient) BeginDelete(ctx context.Context, scope string, registrationAssignmentID string, options *RegistrationAssignmentsBeginDeleteOptions) (RegistrationAssignmentsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, scope, registrationAssignmentID, options) + if err != nil { + return RegistrationAssignmentsDeletePollerResponse{}, err + } + result := RegistrationAssignmentsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("RegistrationAssignmentsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return RegistrationAssignmentsDeletePollerResponse{}, err + } + result.Poller = &RegistrationAssignmentsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the specified registration assignment. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationAssignmentsClient) deleteOperation(ctx context.Context, scope string, registrationAssignmentID string, options *RegistrationAssignmentsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, scope, registrationAssignmentID, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RegistrationAssignmentsClient) deleteCreateRequest(ctx context.Context, scope string, registrationAssignmentID string, options *RegistrationAssignmentsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if registrationAssignmentID == "" { + return nil, errors.New("parameter registrationAssignmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationAssignmentId}", url.PathEscape(registrationAssignmentID)) + 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", "2020-02-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 *RegistrationAssignmentsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the details of the specified registration assignment. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationAssignmentsClient) Get(ctx context.Context, scope string, registrationAssignmentID string, options *RegistrationAssignmentsGetOptions) (RegistrationAssignmentsGetResponse, error) { + req, err := client.getCreateRequest(ctx, scope, registrationAssignmentID, options) + if err != nil { + return RegistrationAssignmentsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationAssignmentsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationAssignmentsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RegistrationAssignmentsClient) getCreateRequest(ctx context.Context, scope string, registrationAssignmentID string, options *RegistrationAssignmentsGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if registrationAssignmentID == "" { + return nil, errors.New("parameter registrationAssignmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationAssignmentId}", url.PathEscape(registrationAssignmentID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ExpandRegistrationDefinition != nil { + reqQP.Set("$expandRegistrationDefinition", strconv.FormatBool(*options.ExpandRegistrationDefinition)) + } + reqQP.Set("api-version", "2020-02-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 *RegistrationAssignmentsClient) getHandleResponse(resp *http.Response) (RegistrationAssignmentsGetResponse, error) { + result := RegistrationAssignmentsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RegistrationAssignment); err != nil { + return RegistrationAssignmentsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *RegistrationAssignmentsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets a list of the registration assignments. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationAssignmentsClient) List(scope string, options *RegistrationAssignmentsListOptions) *RegistrationAssignmentsListPager { + return &RegistrationAssignmentsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, scope, options) + }, + advancer: func(ctx context.Context, resp RegistrationAssignmentsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.RegistrationAssignmentList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *RegistrationAssignmentsClient) listCreateRequest(ctx context.Context, scope string, options *RegistrationAssignmentsListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationAssignments" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ExpandRegistrationDefinition != nil { + reqQP.Set("$expandRegistrationDefinition", strconv.FormatBool(*options.ExpandRegistrationDefinition)) + } + reqQP.Set("api-version", "2020-02-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 *RegistrationAssignmentsClient) listHandleResponse(resp *http.Response) (RegistrationAssignmentsListResponse, error) { + result := RegistrationAssignmentsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RegistrationAssignmentList); err != nil { + return RegistrationAssignmentsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *RegistrationAssignmentsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationdefinitions_client.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationdefinitions_client.go new file mode 100644 index 000000000000..bd0e90d39b71 --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_registrationdefinitions_client.go @@ -0,0 +1,269 @@ +//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 armmanagedservices + +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" +) + +// RegistrationDefinitionsClient contains the methods for the RegistrationDefinitions group. +// Don't use this type directly, use NewRegistrationDefinitionsClient() instead. +type RegistrationDefinitionsClient struct { + ep string + pl runtime.Pipeline +} + +// NewRegistrationDefinitionsClient creates a new instance of RegistrationDefinitionsClient with the specified values. +func NewRegistrationDefinitionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *RegistrationDefinitionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &RegistrationDefinitionsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Creates or updates a registration definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationDefinitionsClient) BeginCreateOrUpdate(ctx context.Context, registrationDefinitionID string, scope string, requestBody RegistrationDefinition, options *RegistrationDefinitionsBeginCreateOrUpdateOptions) (RegistrationDefinitionsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, registrationDefinitionID, scope, requestBody, options) + if err != nil { + return RegistrationDefinitionsCreateOrUpdatePollerResponse{}, err + } + result := RegistrationDefinitionsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("RegistrationDefinitionsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return RegistrationDefinitionsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &RegistrationDefinitionsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a registration definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationDefinitionsClient) createOrUpdate(ctx context.Context, registrationDefinitionID string, scope string, requestBody RegistrationDefinition, options *RegistrationDefinitionsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, registrationDefinitionID, scope, requestBody, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RegistrationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, registrationDefinitionID string, scope string, requestBody RegistrationDefinition, options *RegistrationDefinitionsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}" + if registrationDefinitionID == "" { + return nil, errors.New("parameter registrationDefinitionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationDefinitionId}", url.PathEscape(registrationDefinitionID)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + 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", "2020-02-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, requestBody) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *RegistrationDefinitionsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes the registration definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationDefinitionsClient) Delete(ctx context.Context, registrationDefinitionID string, scope string, options *RegistrationDefinitionsDeleteOptions) (RegistrationDefinitionsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, registrationDefinitionID, scope, options) + if err != nil { + return RegistrationDefinitionsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationDefinitionsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return RegistrationDefinitionsDeleteResponse{}, client.deleteHandleError(resp) + } + return RegistrationDefinitionsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RegistrationDefinitionsClient) deleteCreateRequest(ctx context.Context, registrationDefinitionID string, scope string, options *RegistrationDefinitionsDeleteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}" + if registrationDefinitionID == "" { + return nil, errors.New("parameter registrationDefinitionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationDefinitionId}", url.PathEscape(registrationDefinitionID)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + 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", "2020-02-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 *RegistrationDefinitionsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the registration definition details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationDefinitionsClient) Get(ctx context.Context, scope string, registrationDefinitionID string, options *RegistrationDefinitionsGetOptions) (RegistrationDefinitionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, scope, registrationDefinitionID, options) + if err != nil { + return RegistrationDefinitionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationDefinitionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationDefinitionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RegistrationDefinitionsClient) getCreateRequest(ctx context.Context, scope string, registrationDefinitionID string, options *RegistrationDefinitionsGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if registrationDefinitionID == "" { + return nil, errors.New("parameter registrationDefinitionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationDefinitionId}", url.PathEscape(registrationDefinitionID)) + 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", "2020-02-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 *RegistrationDefinitionsClient) getHandleResponse(resp *http.Response) (RegistrationDefinitionsGetResponse, error) { + result := RegistrationDefinitionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RegistrationDefinition); err != nil { + return RegistrationDefinitionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *RegistrationDefinitionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets a list of the registration definitions. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistrationDefinitionsClient) List(scope string, options *RegistrationDefinitionsListOptions) *RegistrationDefinitionsListPager { + return &RegistrationDefinitionsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, scope, options) + }, + advancer: func(ctx context.Context, resp RegistrationDefinitionsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.RegistrationDefinitionList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *RegistrationDefinitionsClient) listCreateRequest(ctx context.Context, scope string, options *RegistrationDefinitionsListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + 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", "2020-02-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 *RegistrationDefinitionsClient) listHandleResponse(resp *http.Response) (RegistrationDefinitionsListResponse, error) { + result := RegistrationDefinitionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RegistrationDefinitionList); err != nil { + return RegistrationDefinitionsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *RegistrationDefinitionsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_response_types.go b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_response_types.go new file mode 100644 index 000000000000..267c6a4fc36d --- /dev/null +++ b/sdk/resourcemanager/managedservices/armmanagedservices/zz_generated_response_types.go @@ -0,0 +1,280 @@ +//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 armmanagedservices + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// MarketplaceRegistrationDefinitionsGetResponse contains the response from method MarketplaceRegistrationDefinitions.Get. +type MarketplaceRegistrationDefinitionsGetResponse struct { + MarketplaceRegistrationDefinitionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MarketplaceRegistrationDefinitionsGetResult contains the result from method MarketplaceRegistrationDefinitions.Get. +type MarketplaceRegistrationDefinitionsGetResult struct { + MarketplaceRegistrationDefinition +} + +// MarketplaceRegistrationDefinitionsListResponse contains the response from method MarketplaceRegistrationDefinitions.List. +type MarketplaceRegistrationDefinitionsListResponse struct { + MarketplaceRegistrationDefinitionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MarketplaceRegistrationDefinitionsListResult contains the result from method MarketplaceRegistrationDefinitions.List. +type MarketplaceRegistrationDefinitionsListResult struct { + MarketplaceRegistrationDefinitionList +} + +// MarketplaceRegistrationDefinitionsWithoutScopeGetResponse contains the response from method MarketplaceRegistrationDefinitionsWithoutScope.Get. +type MarketplaceRegistrationDefinitionsWithoutScopeGetResponse struct { + MarketplaceRegistrationDefinitionsWithoutScopeGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MarketplaceRegistrationDefinitionsWithoutScopeGetResult contains the result from method MarketplaceRegistrationDefinitionsWithoutScope.Get. +type MarketplaceRegistrationDefinitionsWithoutScopeGetResult struct { + MarketplaceRegistrationDefinition +} + +// MarketplaceRegistrationDefinitionsWithoutScopeListResponse contains the response from method MarketplaceRegistrationDefinitionsWithoutScope.List. +type MarketplaceRegistrationDefinitionsWithoutScopeListResponse struct { + MarketplaceRegistrationDefinitionsWithoutScopeListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MarketplaceRegistrationDefinitionsWithoutScopeListResult contains the result from method MarketplaceRegistrationDefinitionsWithoutScope.List. +type MarketplaceRegistrationDefinitionsWithoutScopeListResult struct { + MarketplaceRegistrationDefinitionList +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationList +} + +// RegistrationAssignmentsCreateOrUpdatePollerResponse contains the response from method RegistrationAssignments.CreateOrUpdate. +type RegistrationAssignmentsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *RegistrationAssignmentsCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l RegistrationAssignmentsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (RegistrationAssignmentsCreateOrUpdateResponse, error) { + respType := RegistrationAssignmentsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.RegistrationAssignment) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a RegistrationAssignmentsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *RegistrationAssignmentsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *RegistrationAssignmentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("RegistrationAssignmentsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &RegistrationAssignmentsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// RegistrationAssignmentsCreateOrUpdateResponse contains the response from method RegistrationAssignments.CreateOrUpdate. +type RegistrationAssignmentsCreateOrUpdateResponse struct { + RegistrationAssignmentsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationAssignmentsCreateOrUpdateResult contains the result from method RegistrationAssignments.CreateOrUpdate. +type RegistrationAssignmentsCreateOrUpdateResult struct { + RegistrationAssignment +} + +// RegistrationAssignmentsDeletePollerResponse contains the response from method RegistrationAssignments.Delete. +type RegistrationAssignmentsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *RegistrationAssignmentsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l RegistrationAssignmentsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (RegistrationAssignmentsDeleteResponse, error) { + respType := RegistrationAssignmentsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a RegistrationAssignmentsDeletePollerResponse from the provided client and resume token. +func (l *RegistrationAssignmentsDeletePollerResponse) Resume(ctx context.Context, client *RegistrationAssignmentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("RegistrationAssignmentsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &RegistrationAssignmentsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// RegistrationAssignmentsDeleteResponse contains the response from method RegistrationAssignments.Delete. +type RegistrationAssignmentsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationAssignmentsGetResponse contains the response from method RegistrationAssignments.Get. +type RegistrationAssignmentsGetResponse struct { + RegistrationAssignmentsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationAssignmentsGetResult contains the result from method RegistrationAssignments.Get. +type RegistrationAssignmentsGetResult struct { + RegistrationAssignment +} + +// RegistrationAssignmentsListResponse contains the response from method RegistrationAssignments.List. +type RegistrationAssignmentsListResponse struct { + RegistrationAssignmentsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationAssignmentsListResult contains the result from method RegistrationAssignments.List. +type RegistrationAssignmentsListResult struct { + RegistrationAssignmentList +} + +// RegistrationDefinitionsCreateOrUpdatePollerResponse contains the response from method RegistrationDefinitions.CreateOrUpdate. +type RegistrationDefinitionsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *RegistrationDefinitionsCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l RegistrationDefinitionsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (RegistrationDefinitionsCreateOrUpdateResponse, error) { + respType := RegistrationDefinitionsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.RegistrationDefinition) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a RegistrationDefinitionsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *RegistrationDefinitionsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *RegistrationDefinitionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("RegistrationDefinitionsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &RegistrationDefinitionsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// RegistrationDefinitionsCreateOrUpdateResponse contains the response from method RegistrationDefinitions.CreateOrUpdate. +type RegistrationDefinitionsCreateOrUpdateResponse struct { + RegistrationDefinitionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationDefinitionsCreateOrUpdateResult contains the result from method RegistrationDefinitions.CreateOrUpdate. +type RegistrationDefinitionsCreateOrUpdateResult struct { + RegistrationDefinition +} + +// RegistrationDefinitionsDeleteResponse contains the response from method RegistrationDefinitions.Delete. +type RegistrationDefinitionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationDefinitionsGetResponse contains the response from method RegistrationDefinitions.Get. +type RegistrationDefinitionsGetResponse struct { + RegistrationDefinitionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationDefinitionsGetResult contains the result from method RegistrationDefinitions.Get. +type RegistrationDefinitionsGetResult struct { + RegistrationDefinition +} + +// RegistrationDefinitionsListResponse contains the response from method RegistrationDefinitions.List. +type RegistrationDefinitionsListResponse struct { + RegistrationDefinitionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistrationDefinitionsListResult contains the result from method RegistrationDefinitions.List. +type RegistrationDefinitionsListResult struct { + RegistrationDefinitionList +}