diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md b/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md new file mode 100644 index 000000000000..f3d80a0b8362 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-10-26) + +- Initial preview release. diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/LICENSE.txt b/sdk/resourcemanager/managementgroups/armmanagementgroups/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/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/managementgroups/armmanagementgroups/README.md b/sdk/resourcemanager/managementgroups/armmanagementgroups/README.md new file mode 100644 index 000000000000..512caf665c88 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/README.md @@ -0,0 +1,76 @@ +# Azure Management Groups Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups) + +The `armmanagementgroups` module provides operations for working with Azure Management Groups. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/managementgroups/armmanagementgroups) + +# 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 Management Groups module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Management Groups. 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). + +## Connecting to Azure Management Groups + +Once you have a credential, create a connection to the desired ARM endpoint. The `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := arm.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, 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). + +## Clients + +Azure Management Groups 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 `arm.Connection`. + +```go +client := armmanagementgroups.NewOperationsClient(con) +``` + +## 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 `Management Groups` 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/managementgroups/armmanagementgroups/autorest.md b/sdk/resourcemanager/managementgroups/armmanagementgroups/autorest.md new file mode 100644 index 000000000000..8fcc2434a01c --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/4aebac1bd77282ae8efe3dd2886e864537d31762/specification/managementgroups/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/4aebac1bd77282ae8efe3dd2886e864537d31762/specification/managementgroups/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/managementgroups/armmanagementgroups/build.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/build.go new file mode 100644 index 000000000000..5dedc4677f5d --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/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/managementgroups/armmanagementgroups + +package armmanagementgroups diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/ci.yml b/sdk/resourcemanager/managementgroups/armmanagementgroups/ci.yml new file mode 100644 index 000000000000..b3871741b886 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/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/managementgroups/armmanagementgroups/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/managementgroups/armmanagementgroups/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/managementgroups/armmanagementgroups' diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod new file mode 100644 index 000000000000..9fb28f78dd96 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v58.3.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 +) diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum new file mode 100644 index 000000000000..af10d0f1292e --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go v58.3.0+incompatible h1:lb9OWePNuJMiibdxg9XvdbiOldR0Yifge37L4LoOxIs= +github.com/Azure/azure-sdk-for-go v58.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +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/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-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.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.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/go_mod_tidy_hack.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/go_mod_tidy_hack.go new file mode 100644 index 000000000000..1c1429b2ee5f --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/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 armmanagementgroups + +// 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/managementgroups/armmanagementgroups/zz_generated_constants.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_constants.go new file mode 100644 index 000000000000..ada4ee899d49 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_constants.go @@ -0,0 +1,184 @@ +//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 armmanagementgroups + +const ( + module = "armmanagementgroups" + version = "v0.1.0" +) + +type Enum0 string + +const ( + Enum0Ancestors Enum0 = "ancestors" + Enum0Children Enum0 = "children" + Enum0Path Enum0 = "path" +) + +// PossibleEnum0Values returns the possible values for the Enum0 const type. +func PossibleEnum0Values() []Enum0 { + return []Enum0{ + Enum0Ancestors, + Enum0Children, + Enum0Path, + } +} + +// ToPtr returns a *Enum0 pointing to the current value. +func (c Enum0) ToPtr() *Enum0 { + return &c +} + +type Enum2 string + +const ( + Enum2AllowedChildren Enum2 = "AllowedChildren" + Enum2AllowedParents Enum2 = "AllowedParents" + Enum2ChildrenOnly Enum2 = "ChildrenOnly" + Enum2ParentAndFirstLevelChildren Enum2 = "ParentAndFirstLevelChildren" + Enum2ParentOnly Enum2 = "ParentOnly" +) + +// PossibleEnum2Values returns the possible values for the Enum2 const type. +func PossibleEnum2Values() []Enum2 { + return []Enum2{ + Enum2AllowedChildren, + Enum2AllowedParents, + Enum2ChildrenOnly, + Enum2ParentAndFirstLevelChildren, + Enum2ParentOnly, + } +} + +// ToPtr returns a *Enum2 pointing to the current value. +func (c Enum2) ToPtr() *Enum2 { + return &c +} + +type Enum3 string + +const ( + Enum3Audit Enum3 = "Audit" + Enum3FullHierarchy Enum3 = "FullHierarchy" + Enum3GroupsOnly Enum3 = "GroupsOnly" + Enum3SubscriptionsOnly Enum3 = "SubscriptionsOnly" +) + +// PossibleEnum3Values returns the possible values for the Enum3 const type. +func PossibleEnum3Values() []Enum3 { + return []Enum3{ + Enum3Audit, + Enum3FullHierarchy, + Enum3GroupsOnly, + Enum3SubscriptionsOnly, + } +} + +// ToPtr returns a *Enum3 pointing to the current value. +func (c Enum3) ToPtr() *Enum3 { + return &c +} + +// ManagementGroupChildType - The type of child resource. +type ManagementGroupChildType string + +const ( + ManagementGroupChildTypeMicrosoftManagementManagementGroups ManagementGroupChildType = "Microsoft.Management/managementGroups" + ManagementGroupChildTypeSubscriptions ManagementGroupChildType = "/subscriptions" +) + +// PossibleManagementGroupChildTypeValues returns the possible values for the ManagementGroupChildType const type. +func PossibleManagementGroupChildTypeValues() []ManagementGroupChildType { + return []ManagementGroupChildType{ + ManagementGroupChildTypeMicrosoftManagementManagementGroups, + ManagementGroupChildTypeSubscriptions, + } +} + +// ToPtr returns a *ManagementGroupChildType pointing to the current value. +func (c ManagementGroupChildType) ToPtr() *ManagementGroupChildType { + return &c +} + +// Permissions - The users specific permissions to this item. +type Permissions string + +const ( + PermissionsDelete Permissions = "delete" + PermissionsEdit Permissions = "edit" + PermissionsNoaccess Permissions = "noaccess" + PermissionsView Permissions = "view" +) + +// PossiblePermissionsValues returns the possible values for the Permissions const type. +func PossiblePermissionsValues() []Permissions { + return []Permissions{ + PermissionsDelete, + PermissionsEdit, + PermissionsNoaccess, + PermissionsView, + } +} + +// ToPtr returns a *Permissions pointing to the current value. +func (c Permissions) ToPtr() *Permissions { + return &c +} + +// Reason - Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect +// length, unsupported characters, etc.) AlreadyExists +// indicates that the name is already in use and is therefore unavailable. +type Reason string + +const ( + ReasonInvalid Reason = "Invalid" + ReasonAlreadyExists Reason = "AlreadyExists" +) + +// PossibleReasonValues returns the possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonInvalid, + ReasonAlreadyExists, + } +} + +// ToPtr returns a *Reason pointing to the current value. +func (c Reason) ToPtr() *Reason { + return &c +} + +// Status - The status of the Tenant Backfill +type Status string + +const ( + StatusNotStarted Status = "NotStarted" + StatusNotStartedButGroupsExist Status = "NotStartedButGroupsExist" + StatusStarted Status = "Started" + StatusFailed Status = "Failed" + StatusCancelled Status = "Cancelled" + StatusCompleted Status = "Completed" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusNotStarted, + StatusNotStartedButGroupsExist, + StatusStarted, + StatusFailed, + StatusCancelled, + StatusCompleted, + } +} + +// ToPtr returns a *Status pointing to the current value. +func (c Status) ToPtr() *Status { + return &c +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_entities_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_entities_client.go new file mode 100644 index 000000000000..796b709ae3f4 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_entities_client.go @@ -0,0 +1,109 @@ +//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 armmanagementgroups + +import ( + "context" + "fmt" + "net/http" + "strconv" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// EntitiesClient contains the methods for the Entities group. +// Don't use this type directly, use NewEntitiesClient() instead. +type EntitiesClient struct { + ep string + pl runtime.Pipeline +} + +// NewEntitiesClient creates a new instance of EntitiesClient with the specified values. +func NewEntitiesClient(con *arm.Connection) *EntitiesClient { + return &EntitiesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// List - List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EntitiesClient) List(options *EntitiesListOptions) *EntitiesListPager { + return &EntitiesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp EntitiesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.EntityListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *EntitiesClient) listCreateRequest(ctx context.Context, options *EntitiesListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/getEntities" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + if options != nil && options.Search != nil { + reqQP.Set("$search", string(*options.Search)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.View != nil { + reqQP.Set("$view", string(*options.View)) + } + if options != nil && options.GroupName != nil { + reqQP.Set("groupName", *options.GroupName) + } + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EntitiesClient) listHandleResponse(resp *http.Response) (EntitiesListResponse, error) { + result := EntitiesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EntityListResult); err != nil { + return EntitiesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *EntitiesClient) 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/managementgroups/armmanagementgroups/zz_generated_hierarchysettings_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_hierarchysettings_client.go new file mode 100644 index 000000000000..93a98163ad68 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_hierarchysettings_client.go @@ -0,0 +1,310 @@ +//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 armmanagementgroups + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// HierarchySettingsClient contains the methods for the HierarchySettings group. +// Don't use this type directly, use NewHierarchySettingsClient() instead. +type HierarchySettingsClient struct { + ep string + pl runtime.Pipeline +} + +// NewHierarchySettingsClient creates a new instance of HierarchySettingsClient with the specified values. +func NewHierarchySettingsClient(con *arm.Connection) *HierarchySettingsClient { + return &HierarchySettingsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// CreateOrUpdate - Creates or updates the hierarchy settings defined at the Management Group level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *HierarchySettingsClient) CreateOrUpdate(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, options *HierarchySettingsCreateOrUpdateOptions) (HierarchySettingsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, groupID, createTenantSettingsRequest, options) + if err != nil { + return HierarchySettingsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HierarchySettingsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HierarchySettingsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *HierarchySettingsClient) createOrUpdateCreateRequest(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, options *HierarchySettingsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, createTenantSettingsRequest) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *HierarchySettingsClient) createOrUpdateHandleResponse(resp *http.Response) (HierarchySettingsCreateOrUpdateResponse, error) { + result := HierarchySettingsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HierarchySettings); err != nil { + return HierarchySettingsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *HierarchySettingsClient) 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 hierarchy settings defined at the Management Group level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *HierarchySettingsClient) Delete(ctx context.Context, groupID string, options *HierarchySettingsDeleteOptions) (HierarchySettingsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, groupID, options) + if err != nil { + return HierarchySettingsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HierarchySettingsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HierarchySettingsDeleteResponse{}, client.deleteHandleError(resp) + } + return HierarchySettingsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *HierarchySettingsClient) deleteCreateRequest(ctx context.Context, groupID string, options *HierarchySettingsDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *HierarchySettingsClient) 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 hierarchy settings defined at the Management Group level. Settings can only be set on the root Management Group of the hierarchy. +// If the operation fails it returns the *ErrorResponse error type. +func (client *HierarchySettingsClient) Get(ctx context.Context, groupID string, options *HierarchySettingsGetOptions) (HierarchySettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, groupID, options) + if err != nil { + return HierarchySettingsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HierarchySettingsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HierarchySettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *HierarchySettingsClient) getCreateRequest(ctx context.Context, groupID string, options *HierarchySettingsGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *HierarchySettingsClient) getHandleResponse(resp *http.Response) (HierarchySettingsGetResponse, error) { + result := HierarchySettingsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HierarchySettings); err != nil { + return HierarchySettingsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *HierarchySettingsClient) 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 all the hierarchy settings defined at the Management Group level. Settings can only be set on the root Management Group of the hierarchy. +// If the operation fails it returns the *ErrorResponse error type. +func (client *HierarchySettingsClient) List(ctx context.Context, groupID string, options *HierarchySettingsListOptions) (HierarchySettingsListResponse, error) { + req, err := client.listCreateRequest(ctx, groupID, options) + if err != nil { + return HierarchySettingsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HierarchySettingsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HierarchySettingsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *HierarchySettingsClient) listCreateRequest(ctx context.Context, groupID string, options *HierarchySettingsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *HierarchySettingsClient) listHandleResponse(resp *http.Response) (HierarchySettingsListResponse, error) { + result := HierarchySettingsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HierarchySettingsList); err != nil { + return HierarchySettingsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *HierarchySettingsClient) 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) +} + +// Update - Updates the hierarchy settings defined at the Management Group level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *HierarchySettingsClient) Update(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, options *HierarchySettingsUpdateOptions) (HierarchySettingsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, groupID, createTenantSettingsRequest, options) + if err != nil { + return HierarchySettingsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HierarchySettingsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HierarchySettingsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *HierarchySettingsClient) updateCreateRequest(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, options *HierarchySettingsUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, createTenantSettingsRequest) +} + +// updateHandleResponse handles the Update response. +func (client *HierarchySettingsClient) updateHandleResponse(resp *http.Response) (HierarchySettingsUpdateResponse, error) { + result := HierarchySettingsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HierarchySettings); err != nil { + return HierarchySettingsUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *HierarchySettingsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroups_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroups_client.go new file mode 100644 index 000000000000..6a85cd1aa352 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroups_client.go @@ -0,0 +1,425 @@ +//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 armmanagementgroups + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strconv" + "strings" + + "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" +) + +// ManagementGroupsClient contains the methods for the ManagementGroups group. +// Don't use this type directly, use NewManagementGroupsClient() instead. +type ManagementGroupsClient struct { + ep string + pl runtime.Pipeline +} + +// NewManagementGroupsClient creates a new instance of ManagementGroupsClient with the specified values. +func NewManagementGroupsClient(con *arm.Connection) *ManagementGroupsClient { + return &ManagementGroupsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// BeginCreateOrUpdate - Create or update a management group. If a management group is already created and a subsequent create request is issued with different +// properties, the management group properties will be updated. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) BeginCreateOrUpdate(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, options *ManagementGroupsBeginCreateOrUpdateOptions) (ManagementGroupsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, groupID, createManagementGroupRequest, options) + if err != nil { + return ManagementGroupsCreateOrUpdatePollerResponse{}, err + } + result := ManagementGroupsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ManagementGroupsClient.CreateOrUpdate", "azure-async-operation", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ManagementGroupsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ManagementGroupsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a management group. If a management group is already created and a subsequent create request is issued with different +// properties, the management group properties will be updated. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) createOrUpdate(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, options *ManagementGroupsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, groupID, createManagementGroupRequest, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ManagementGroupsClient) createOrUpdateCreateRequest(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, options *ManagementGroupsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, createManagementGroupRequest) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ManagementGroupsClient) 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 - Delete management group. If a management group contains child resources, the request will fail. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) BeginDelete(ctx context.Context, groupID string, options *ManagementGroupsBeginDeleteOptions) (ManagementGroupsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, groupID, options) + if err != nil { + return ManagementGroupsDeletePollerResponse{}, err + } + result := ManagementGroupsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ManagementGroupsClient.Delete", "azure-async-operation", resp, client.pl, client.deleteHandleError) + if err != nil { + return ManagementGroupsDeletePollerResponse{}, err + } + result.Poller = &ManagementGroupsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete management group. If a management group contains child resources, the request will fail. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) deleteOperation(ctx context.Context, groupID string, options *ManagementGroupsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, groupID, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ManagementGroupsClient) deleteCreateRequest(ctx context.Context, groupID string, options *ManagementGroupsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ManagementGroupsClient) 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 - Get the details of the management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) Get(ctx context.Context, groupID string, options *ManagementGroupsGetOptions) (ManagementGroupsGetResponse, error) { + req, err := client.getCreateRequest(ctx, groupID, options) + if err != nil { + return ManagementGroupsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ManagementGroupsClient) getCreateRequest(ctx context.Context, groupID string, options *ManagementGroupsGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", string(*options.Expand)) + } + if options != nil && options.Recurse != nil { + reqQP.Set("$recurse", strconv.FormatBool(*options.Recurse)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ManagementGroupsClient) getHandleResponse(resp *http.Response) (ManagementGroupsGetResponse, error) { + result := ManagementGroupsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagementGroup); err != nil { + return ManagementGroupsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ManagementGroupsClient) 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) +} + +// GetDescendants - List all entities that descend from a management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) GetDescendants(groupID string, options *ManagementGroupsGetDescendantsOptions) *ManagementGroupsGetDescendantsPager { + return &ManagementGroupsGetDescendantsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.getDescendantsCreateRequest(ctx, groupID, options) + }, + advancer: func(ctx context.Context, resp ManagementGroupsGetDescendantsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.DescendantListResult.NextLink) + }, + } +} + +// getDescendantsCreateRequest creates the GetDescendants request. +func (client *ManagementGroupsClient) getDescendantsCreateRequest(ctx context.Context, groupID string, options *ManagementGroupsGetDescendantsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/descendants" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getDescendantsHandleResponse handles the GetDescendants response. +func (client *ManagementGroupsClient) getDescendantsHandleResponse(resp *http.Response) (ManagementGroupsGetDescendantsResponse, error) { + result := ManagementGroupsGetDescendantsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DescendantListResult); err != nil { + return ManagementGroupsGetDescendantsResponse{}, err + } + return result, nil +} + +// getDescendantsHandleError handles the GetDescendants error response. +func (client *ManagementGroupsClient) getDescendantsHandleError(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 - List management groups for the authenticated user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) List(options *ManagementGroupsListOptions) *ManagementGroupsListPager { + return &ManagementGroupsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ManagementGroupsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ManagementGroupListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ManagementGroupsClient) listCreateRequest(ctx context.Context, options *ManagementGroupsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ManagementGroupsClient) listHandleResponse(resp *http.Response) (ManagementGroupsListResponse, error) { + result := ManagementGroupsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagementGroupListResult); err != nil { + return ManagementGroupsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ManagementGroupsClient) 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) +} + +// Update - Update a management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsClient) Update(ctx context.Context, groupID string, patchGroupRequest PatchManagementGroupRequest, options *ManagementGroupsUpdateOptions) (ManagementGroupsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, groupID, patchGroupRequest, options) + if err != nil { + return ManagementGroupsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ManagementGroupsClient) updateCreateRequest(ctx context.Context, groupID string, patchGroupRequest PatchManagementGroupRequest, options *ManagementGroupsUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, patchGroupRequest) +} + +// updateHandleResponse handles the Update response. +func (client *ManagementGroupsClient) updateHandleResponse(resp *http.Response) (ManagementGroupsUpdateResponse, error) { + result := ManagementGroupsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagementGroup); err != nil { + return ManagementGroupsUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ManagementGroupsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroupsapi_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroupsapi_client.go new file mode 100644 index 000000000000..84fa10a06def --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroupsapi_client.go @@ -0,0 +1,190 @@ +//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 armmanagementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// ManagementGroupsAPIClient contains the methods for the ManagementGroupsAPI group. +// Don't use this type directly, use NewManagementGroupsAPIClient() instead. +type ManagementGroupsAPIClient struct { + ep string + pl runtime.Pipeline +} + +// NewManagementGroupsAPIClient creates a new instance of ManagementGroupsAPIClient with the specified values. +func NewManagementGroupsAPIClient(con *arm.Connection) *ManagementGroupsAPIClient { + return &ManagementGroupsAPIClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// CheckNameAvailability - Checks if the specified management group name is valid and unique +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsAPIClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ManagementGroupsAPICheckNameAvailabilityOptions) (ManagementGroupsAPICheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, checkNameAvailabilityRequest, options) + if err != nil { + return ManagementGroupsAPICheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupsAPICheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupsAPICheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *ManagementGroupsAPIClient) checkNameAvailabilityCreateRequest(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ManagementGroupsAPICheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/checkNameAvailability" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, checkNameAvailabilityRequest) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *ManagementGroupsAPIClient) checkNameAvailabilityHandleResponse(resp *http.Response) (ManagementGroupsAPICheckNameAvailabilityResponse, error) { + result := ManagementGroupsAPICheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResult); err != nil { + return ManagementGroupsAPICheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *ManagementGroupsAPIClient) checkNameAvailabilityHandleError(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) +} + +// StartTenantBackfill - Starts backfilling subscriptions for the Tenant. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsAPIClient) StartTenantBackfill(ctx context.Context, options *ManagementGroupsAPIStartTenantBackfillOptions) (ManagementGroupsAPIStartTenantBackfillResponse, error) { + req, err := client.startTenantBackfillCreateRequest(ctx, options) + if err != nil { + return ManagementGroupsAPIStartTenantBackfillResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupsAPIStartTenantBackfillResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupsAPIStartTenantBackfillResponse{}, client.startTenantBackfillHandleError(resp) + } + return client.startTenantBackfillHandleResponse(resp) +} + +// startTenantBackfillCreateRequest creates the StartTenantBackfill request. +func (client *ManagementGroupsAPIClient) startTenantBackfillCreateRequest(ctx context.Context, options *ManagementGroupsAPIStartTenantBackfillOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/startTenantBackfill" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// startTenantBackfillHandleResponse handles the StartTenantBackfill response. +func (client *ManagementGroupsAPIClient) startTenantBackfillHandleResponse(resp *http.Response) (ManagementGroupsAPIStartTenantBackfillResponse, error) { + result := ManagementGroupsAPIStartTenantBackfillResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TenantBackfillStatusResult); err != nil { + return ManagementGroupsAPIStartTenantBackfillResponse{}, err + } + return result, nil +} + +// startTenantBackfillHandleError handles the StartTenantBackfill error response. +func (client *ManagementGroupsAPIClient) startTenantBackfillHandleError(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) +} + +// TenantBackfillStatus - Gets tenant backfill status +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupsAPIClient) TenantBackfillStatus(ctx context.Context, options *ManagementGroupsAPITenantBackfillStatusOptions) (ManagementGroupsAPITenantBackfillStatusResponse, error) { + req, err := client.tenantBackfillStatusCreateRequest(ctx, options) + if err != nil { + return ManagementGroupsAPITenantBackfillStatusResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupsAPITenantBackfillStatusResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupsAPITenantBackfillStatusResponse{}, client.tenantBackfillStatusHandleError(resp) + } + return client.tenantBackfillStatusHandleResponse(resp) +} + +// tenantBackfillStatusCreateRequest creates the TenantBackfillStatus request. +func (client *ManagementGroupsAPIClient) tenantBackfillStatusCreateRequest(ctx context.Context, options *ManagementGroupsAPITenantBackfillStatusOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/tenantBackfillStatus" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// tenantBackfillStatusHandleResponse handles the TenantBackfillStatus response. +func (client *ManagementGroupsAPIClient) tenantBackfillStatusHandleResponse(resp *http.Response) (ManagementGroupsAPITenantBackfillStatusResponse, error) { + result := ManagementGroupsAPITenantBackfillStatusResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TenantBackfillStatusResult); err != nil { + return ManagementGroupsAPITenantBackfillStatusResponse{}, err + } + return result, nil +} + +// tenantBackfillStatusHandleError handles the TenantBackfillStatus error response. +func (client *ManagementGroupsAPIClient) tenantBackfillStatusHandleError(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/managementgroups/armmanagementgroups/zz_generated_managementgroupsubscriptions_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroupsubscriptions_client.go new file mode 100644 index 000000000000..d9d4f84c13a4 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_managementgroupsubscriptions_client.go @@ -0,0 +1,274 @@ +//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 armmanagementgroups + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// ManagementGroupSubscriptionsClient contains the methods for the ManagementGroupSubscriptions group. +// Don't use this type directly, use NewManagementGroupSubscriptionsClient() instead. +type ManagementGroupSubscriptionsClient struct { + ep string + pl runtime.Pipeline +} + +// NewManagementGroupSubscriptionsClient creates a new instance of ManagementGroupSubscriptionsClient with the specified values. +func NewManagementGroupSubscriptionsClient(con *arm.Connection) *ManagementGroupSubscriptionsClient { + return &ManagementGroupSubscriptionsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// Create - Associates existing subscription with the management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupSubscriptionsClient) Create(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsCreateOptions) (ManagementGroupSubscriptionsCreateResponse, error) { + req, err := client.createCreateRequest(ctx, groupID, subscriptionID, options) + if err != nil { + return ManagementGroupSubscriptionsCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupSubscriptionsCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupSubscriptionsCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *ManagementGroupSubscriptionsClient) createCreateRequest(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsCreateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *ManagementGroupSubscriptionsClient) createHandleResponse(resp *http.Response) (ManagementGroupSubscriptionsCreateResponse, error) { + result := ManagementGroupSubscriptionsCreateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionUnderManagementGroup); err != nil { + return ManagementGroupSubscriptionsCreateResponse{}, err + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *ManagementGroupSubscriptionsClient) createHandleError(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 - De-associates subscription from the management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupSubscriptionsClient) Delete(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsDeleteOptions) (ManagementGroupSubscriptionsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, groupID, subscriptionID, options) + if err != nil { + return ManagementGroupSubscriptionsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupSubscriptionsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ManagementGroupSubscriptionsDeleteResponse{}, client.deleteHandleError(resp) + } + return ManagementGroupSubscriptionsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ManagementGroupSubscriptionsClient) deleteCreateRequest(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ManagementGroupSubscriptionsClient) 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) +} + +// GetSubscription - Retrieves details about given subscription which is associated with the management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupSubscriptionsClient) GetSubscription(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsGetSubscriptionOptions) (ManagementGroupSubscriptionsGetSubscriptionResponse, error) { + req, err := client.getSubscriptionCreateRequest(ctx, groupID, subscriptionID, options) + if err != nil { + return ManagementGroupSubscriptionsGetSubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ManagementGroupSubscriptionsGetSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ManagementGroupSubscriptionsGetSubscriptionResponse{}, client.getSubscriptionHandleError(resp) + } + return client.getSubscriptionHandleResponse(resp) +} + +// getSubscriptionCreateRequest creates the GetSubscription request. +func (client *ManagementGroupSubscriptionsClient) getSubscriptionCreateRequest(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsGetSubscriptionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.CacheControl != nil { + req.Raw().Header.Set("Cache-Control", *options.CacheControl) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getSubscriptionHandleResponse handles the GetSubscription response. +func (client *ManagementGroupSubscriptionsClient) getSubscriptionHandleResponse(resp *http.Response) (ManagementGroupSubscriptionsGetSubscriptionResponse, error) { + result := ManagementGroupSubscriptionsGetSubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionUnderManagementGroup); err != nil { + return ManagementGroupSubscriptionsGetSubscriptionResponse{}, err + } + return result, nil +} + +// getSubscriptionHandleError handles the GetSubscription error response. +func (client *ManagementGroupSubscriptionsClient) getSubscriptionHandleError(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) +} + +// GetSubscriptionsUnderManagementGroup - Retrieves details about all subscriptions which are associated with the management group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ManagementGroupSubscriptionsClient) GetSubscriptionsUnderManagementGroup(groupID string, options *ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions) *ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager { + return &ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.getSubscriptionsUnderManagementGroupCreateRequest(ctx, groupID, options) + }, + advancer: func(ctx context.Context, resp ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ListSubscriptionUnderManagementGroup.NextLink) + }, + } +} + +// getSubscriptionsUnderManagementGroupCreateRequest creates the GetSubscriptionsUnderManagementGroup request. +func (client *ManagementGroupSubscriptionsClient) getSubscriptionsUnderManagementGroupCreateRequest(ctx context.Context, groupID string, options *ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions" + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getSubscriptionsUnderManagementGroupHandleResponse handles the GetSubscriptionsUnderManagementGroup response. +func (client *ManagementGroupSubscriptionsClient) getSubscriptionsUnderManagementGroupHandleResponse(resp *http.Response) (ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse, error) { + result := ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ListSubscriptionUnderManagementGroup); err != nil { + return ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse{}, err + } + return result, nil +} + +// getSubscriptionsUnderManagementGroupHandleError handles the GetSubscriptionsUnderManagementGroup error response. +func (client *ManagementGroupSubscriptionsClient) getSubscriptionsUnderManagementGroupHandleError(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/managementgroups/armmanagementgroups/zz_generated_models.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_models.go new file mode 100644 index 000000000000..0a8991f58bcc --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_models.go @@ -0,0 +1,998 @@ +//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 armmanagementgroups + +import ( + "encoding/json" + "reflect" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// AzureAsyncOperationResults - The results of Azure-AsyncOperation. +type AzureAsyncOperationResults struct { + // The generic properties of a management group. + Properties *ManagementGroupInfoProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The current status of the asynchronous operation performed . For example, Running, Succeeded, Failed + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CheckNameAvailabilityRequest - Management group name availability check parameters. +type CheckNameAvailabilityRequest struct { + // the name to check for availability + Name *string `json:"name,omitempty"` + + // fully qualified resource type which includes provider namespace + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResult - Describes the result of the request to check management group name availability. +type CheckNameAvailabilityResult struct { + // READ-ONLY; Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the reason why the given name is invalid, and provide + // the resource naming requirements so that the user can + // select a valid name. If reason == AlreadyExists, explain that is already in use, and direct them to select a different name. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both. + NameAvailable *bool `json:"nameAvailable,omitempty" azure:"ro"` + + // READ-ONLY; Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect + // length, unsupported characters, etc.) AlreadyExists + // indicates that the name is already in use and is therefore unavailable. + Reason *Reason `json:"reason,omitempty" azure:"ro"` +} + +// CreateManagementGroupChildInfo - The child information of a management group used during creation. +type CreateManagementGroupChildInfo struct { + // READ-ONLY; The list of children. + Children []*CreateManagementGroupChildInfo `json:"children,omitempty" azure:"ro"` + + // READ-ONLY; The friendly name of the child resource. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the child entity. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups) + Type *ManagementGroupChildType `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupChildInfo. +func (c CreateManagementGroupChildInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "children", c.Children) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// CreateManagementGroupDetails - The details of a management group used during creation. +type CreateManagementGroupDetails struct { + // (Optional) The ID of the parent management group used during creation. + Parent *CreateParentGroupInfo `json:"parent,omitempty"` + + // READ-ONLY; The identity of the principal or process that updated the object. + UpdatedBy *string `json:"updatedBy,omitempty" azure:"ro"` + + // READ-ONLY; The date and time when this object was last updated. + UpdatedTime *time.Time `json:"updatedTime,omitempty" azure:"ro"` + + // READ-ONLY; The version number of the object. + Version *int32 `json:"version,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupDetails. +func (c CreateManagementGroupDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "parent", c.Parent) + populate(objectMap, "updatedBy", c.UpdatedBy) + populate(objectMap, "updatedTime", (*timeRFC3339)(c.UpdatedTime)) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CreateManagementGroupDetails. +func (c *CreateManagementGroupDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "parent": + err = unpopulate(val, &c.Parent) + delete(rawMsg, key) + case "updatedBy": + err = unpopulate(val, &c.UpdatedBy) + delete(rawMsg, key) + case "updatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.UpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "version": + err = unpopulate(val, &c.Version) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CreateManagementGroupProperties - The generic properties of a management group used during creation. +type CreateManagementGroupProperties struct { + // The details of a management group used during creation. + Details *CreateManagementGroupDetails `json:"details,omitempty"` + + // The friendly name of the management group. If no value is passed then this field will be set to the groupId. + DisplayName *string `json:"displayName,omitempty"` + + // READ-ONLY; The list of children. + Children []*CreateManagementGroupChildInfo `json:"children,omitempty" azure:"ro"` + + // READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupProperties. +func (c CreateManagementGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "children", c.Children) + populate(objectMap, "details", c.Details) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "tenantId", c.TenantID) + return json.Marshal(objectMap) +} + +// CreateManagementGroupRequest - Management group creation parameters. +type CreateManagementGroupRequest struct { + // The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + + // The generic properties of a management group used during creation. + Properties *CreateManagementGroupProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CreateOrUpdateSettingsProperties - The properties of the request to create or update Management Group settings +type CreateOrUpdateSettingsProperties struct { + // Settings that sets the default Management Group under which new subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup + DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"` + + // Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write + // action on the root + // Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless + // they are given access. + RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"` +} + +// CreateOrUpdateSettingsRequest - Parameters for creating or updating Management Group settings +type CreateOrUpdateSettingsRequest struct { + // The properties of the request to create or update Management Group settings + Properties *CreateOrUpdateSettingsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreateOrUpdateSettingsRequest. +func (c CreateOrUpdateSettingsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// CreateParentGroupInfo - (Optional) The ID of the parent management group used during creation. +type CreateParentGroupInfo struct { + // The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + + // READ-ONLY; The friendly name of the parent management group. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; The name of the parent management group + Name *string `json:"name,omitempty" azure:"ro"` +} + +// DescendantInfo - The descendant. +type DescendantInfo struct { + // The generic properties of an descendant. + Properties *DescendantInfoProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the descendant. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + // or /subscriptions/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the descendant. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups or /subscriptions + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DescendantInfoProperties - The generic properties of an descendant. +type DescendantInfoProperties struct { + // The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + + // The ID of the parent management group. + Parent *DescendantParentGroupInfo `json:"parent,omitempty"` +} + +// DescendantListResult - Describes the result of the request to view descendants. +type DescendantListResult struct { + // The list of descendants. + Value []*DescendantInfo `json:"value,omitempty"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DescendantListResult. +func (d DescendantListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DescendantParentGroupInfo - The ID of the parent management group. +type DescendantParentGroupInfo struct { + // The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` +} + +// EntitiesListOptions contains the optional parameters for the Entities.List method. +type EntitiesListOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string + // The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') + // and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). + // Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + Filter *string + // A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'") + GroupName *string + // The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. + // With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by + // the user's permissions. + // With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity. + // With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect + // access via one of their descendants. + // With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. + // With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct + // access to the children entities or one of it's descendants for it to show up in the results. + Search *Enum2 + // This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, + // e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken. + Select *string + // Number of entities to skip over when retrieving results. Passing this in will override $skipToken. + Skip *int32 + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point + // to use for subsequent calls. + Skiptoken *string + // Number of elements to return when retrieving results. Passing this in will override $skipToken. + Top *int32 + // The view parameter allows clients to filter the type of data that is returned by the getEntities call. + View *Enum3 +} + +// EntityHierarchyItem - The management group details for the hierarchy view. +type EntityHierarchyItem struct { + // The generic properties of a management group. + Properties *EntityHierarchyItemProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// EntityHierarchyItemProperties - The generic properties of a management group. +type EntityHierarchyItemProperties struct { + // The list of children. + Children []*EntityHierarchyItem `json:"children,omitempty"` + + // The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + + // The users specific permissions to this item. + Permissions *Permissions `json:"permissions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EntityHierarchyItemProperties. +func (e EntityHierarchyItemProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "children", e.Children) + populate(objectMap, "displayName", e.DisplayName) + populate(objectMap, "permissions", e.Permissions) + return json.Marshal(objectMap) +} + +// EntityInfo - The entity. +type EntityInfo struct { + // The generic properties of an entity. + Properties *EntityInfoProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the entity. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the entity. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// EntityInfoProperties - The generic properties of an entity. +type EntityInfoProperties struct { + // The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + + // The users specific permissions to this item. + InheritedPermissions *Permissions `json:"inheritedPermissions,omitempty"` + + // Number of children is the number of Groups that are exactly one level underneath the current Group. + NumberOfChildGroups *int32 `json:"numberOfChildGroups,omitempty"` + + // Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group. + NumberOfChildren *int32 `json:"numberOfChildren,omitempty"` + + // Number of Descendants + NumberOfDescendants *int32 `json:"numberOfDescendants,omitempty"` + + // (Optional) The ID of the parent management group. + Parent *EntityParentGroupInfo `json:"parent,omitempty"` + + // The parent display name chain from the root group to the immediate parent + ParentDisplayNameChain []*string `json:"parentDisplayNameChain,omitempty"` + + // The parent name chain from the root group to the immediate parent + ParentNameChain []*string `json:"parentNameChain,omitempty"` + + // The users specific permissions to this item. + Permissions *Permissions `json:"permissions,omitempty"` + + // The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EntityInfoProperties. +func (e EntityInfoProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", e.DisplayName) + populate(objectMap, "inheritedPermissions", e.InheritedPermissions) + populate(objectMap, "numberOfChildGroups", e.NumberOfChildGroups) + populate(objectMap, "numberOfChildren", e.NumberOfChildren) + populate(objectMap, "numberOfDescendants", e.NumberOfDescendants) + populate(objectMap, "parent", e.Parent) + populate(objectMap, "parentDisplayNameChain", e.ParentDisplayNameChain) + populate(objectMap, "parentNameChain", e.ParentNameChain) + populate(objectMap, "permissions", e.Permissions) + populate(objectMap, "tenantId", e.TenantID) + return json.Marshal(objectMap) +} + +// EntityListResult - Describes the result of the request to view entities. +type EntityListResult struct { + // The list of entities. + Value []*EntityInfo `json:"value,omitempty"` + + // READ-ONLY; Total count of records that match the filter + Count *int32 `json:"count,omitempty" azure:"ro"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EntityListResult. +func (e EntityListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", e.Count) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// EntityParentGroupInfo - (Optional) The ID of the parent management group. +type EntityParentGroupInfo struct { + // The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` +} + +// ErrorDetails - The details of the error. +type ErrorDetails struct { + // One of a server-defined set of error codes. + Code *string `json:"code,omitempty"` + + // A human-readable representation of the error's details. + Details *string `json:"details,omitempty"` + + // A human-readable representation of the error. + Message *string `json:"message,omitempty"` +} + +// ErrorResponse - The error object. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The details of the error. + InnerError *ErrorDetails `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 +} + +// HierarchySettings - Settings defined at the Management Group scope. +type HierarchySettings struct { + // The generic properties of hierarchy settings. + Properties *HierarchySettingsProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the object. In this case, default. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// HierarchySettingsCreateOrUpdateOptions contains the optional parameters for the HierarchySettings.CreateOrUpdate method. +type HierarchySettingsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// HierarchySettingsDeleteOptions contains the optional parameters for the HierarchySettings.Delete method. +type HierarchySettingsDeleteOptions struct { + // placeholder for future optional parameters +} + +// HierarchySettingsGetOptions contains the optional parameters for the HierarchySettings.Get method. +type HierarchySettingsGetOptions struct { + // placeholder for future optional parameters +} + +// HierarchySettingsInfo - The hierarchy settings resource. +type HierarchySettingsInfo struct { + // The generic properties of hierarchy settings. + Properties *HierarchySettingsProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the object. In this case, default. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// HierarchySettingsList - Lists all hierarchy settings. +type HierarchySettingsList struct { + // The list of hierarchy settings. + Value []*HierarchySettingsInfo `json:"value,omitempty"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type HierarchySettingsList. +func (h HierarchySettingsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// HierarchySettingsListOptions contains the optional parameters for the HierarchySettings.List method. +type HierarchySettingsListOptions struct { + // placeholder for future optional parameters +} + +// HierarchySettingsProperties - The generic properties of hierarchy settings. +type HierarchySettingsProperties struct { + // Settings that sets the default Management Group under which new subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup + DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"` + + // Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write + // action on the root + // Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless + // they are given access. + RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"` + + // The AAD Tenant ID associated with the hierarchy settings. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` +} + +// HierarchySettingsUpdateOptions contains the optional parameters for the HierarchySettings.Update method. +type HierarchySettingsUpdateOptions struct { + // placeholder for future optional parameters +} + +// ListSubscriptionUnderManagementGroup - The details of all subscriptions under management group. +type ListSubscriptionUnderManagementGroup struct { + // The list of subscriptions. + Value []*SubscriptionUnderManagementGroup `json:"value,omitempty"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ListSubscriptionUnderManagementGroup. +func (l ListSubscriptionUnderManagementGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// ManagementGroup - The management group details. +type ManagementGroup struct { + // The generic properties of a management group. + Properties *ManagementGroupProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ManagementGroupChildInfo - The child information of a management group. +type ManagementGroupChildInfo struct { + // The list of children. + Children []*ManagementGroupChildInfo `json:"children,omitempty"` + + // The friendly name of the child resource. + DisplayName *string `json:"displayName,omitempty"` + + // The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + + // The name of the child entity. + Name *string `json:"name,omitempty"` + + // The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups) + Type *ManagementGroupChildType `json:"type,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementGroupChildInfo. +func (m ManagementGroupChildInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "children", m.Children) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "id", m.ID) + populate(objectMap, "name", m.Name) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// ManagementGroupDetails - The details of a management group. +type ManagementGroupDetails struct { + // The ancestors of the management group. + ManagementGroupAncestors []*string `json:"managementGroupAncestors,omitempty"` + + // The ancestors of the management group displayed in reversed order, from immediate parent to the root. + ManagementGroupAncestorsChain []*ManagementGroupPathElement `json:"managementGroupAncestorsChain,omitempty"` + + // (Optional) The ID of the parent management group. + Parent *ParentGroupInfo `json:"parent,omitempty"` + + // The path from the root to the current group. + Path []*ManagementGroupPathElement `json:"path,omitempty"` + + // The identity of the principal or process that updated the object. + UpdatedBy *string `json:"updatedBy,omitempty"` + + // The date and time when this object was last updated. + UpdatedTime *time.Time `json:"updatedTime,omitempty"` + + // The version number of the object. + Version *int32 `json:"version,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementGroupDetails. +func (m ManagementGroupDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "managementGroupAncestors", m.ManagementGroupAncestors) + populate(objectMap, "managementGroupAncestorsChain", m.ManagementGroupAncestorsChain) + populate(objectMap, "parent", m.Parent) + populate(objectMap, "path", m.Path) + populate(objectMap, "updatedBy", m.UpdatedBy) + populate(objectMap, "updatedTime", (*timeRFC3339)(m.UpdatedTime)) + populate(objectMap, "version", m.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementGroupDetails. +func (m *ManagementGroupDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "managementGroupAncestors": + err = unpopulate(val, &m.ManagementGroupAncestors) + delete(rawMsg, key) + case "managementGroupAncestorsChain": + err = unpopulate(val, &m.ManagementGroupAncestorsChain) + delete(rawMsg, key) + case "parent": + err = unpopulate(val, &m.Parent) + delete(rawMsg, key) + case "path": + err = unpopulate(val, &m.Path) + delete(rawMsg, key) + case "updatedBy": + err = unpopulate(val, &m.UpdatedBy) + delete(rawMsg, key) + case "updatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.UpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "version": + err = unpopulate(val, &m.Version) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ManagementGroupInfo - The management group resource. +type ManagementGroupInfo struct { + // The generic properties of a management group. + Properties *ManagementGroupInfoProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ManagementGroupInfoProperties - The generic properties of a management group. +type ManagementGroupInfoProperties struct { + // The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + + // The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` +} + +// ManagementGroupListResult - Describes the result of the request to list management groups. +type ManagementGroupListResult struct { + // The list of management groups. + Value []*ManagementGroupInfo `json:"value,omitempty"` + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementGroupListResult. +func (m ManagementGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// ManagementGroupPathElement - A path element of a management group ancestors. +type ManagementGroupPathElement struct { + // The friendly name of the group. + DisplayName *string `json:"displayName,omitempty"` + + // The name of the group. + Name *string `json:"name,omitempty"` +} + +// ManagementGroupProperties - The generic properties of a management group. +type ManagementGroupProperties struct { + // The list of children. + Children []*ManagementGroupChildInfo `json:"children,omitempty"` + + // The details of a management group. + Details *ManagementGroupDetails `json:"details,omitempty"` + + // The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + + // The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementGroupProperties. +func (m ManagementGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "children", m.Children) + populate(objectMap, "details", m.Details) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "tenantId", m.TenantID) + return json.Marshal(objectMap) +} + +// ManagementGroupSubscriptionsCreateOptions contains the optional parameters for the ManagementGroupSubscriptions.Create method. +type ManagementGroupSubscriptionsCreateOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string +} + +// ManagementGroupSubscriptionsDeleteOptions contains the optional parameters for the ManagementGroupSubscriptions.Delete method. +type ManagementGroupSubscriptionsDeleteOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string +} + +// ManagementGroupSubscriptionsGetSubscriptionOptions contains the optional parameters for the ManagementGroupSubscriptions.GetSubscription method. +type ManagementGroupSubscriptionsGetSubscriptionOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string +} + +// ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions contains the optional parameters for the ManagementGroupSubscriptions.GetSubscriptionsUnderManagementGroup +// method. +type ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupOptions struct { + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point + // to use for subsequent calls. + Skiptoken *string +} + +// ManagementGroupsAPICheckNameAvailabilityOptions contains the optional parameters for the ManagementGroupsAPI.CheckNameAvailability method. +type ManagementGroupsAPICheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ManagementGroupsAPIStartTenantBackfillOptions contains the optional parameters for the ManagementGroupsAPI.StartTenantBackfill method. +type ManagementGroupsAPIStartTenantBackfillOptions struct { + // placeholder for future optional parameters +} + +// ManagementGroupsAPITenantBackfillStatusOptions contains the optional parameters for the ManagementGroupsAPI.TenantBackfillStatus method. +type ManagementGroupsAPITenantBackfillStatusOptions struct { + // placeholder for future optional parameters +} + +// ManagementGroupsBeginCreateOrUpdateOptions contains the optional parameters for the ManagementGroups.BeginCreateOrUpdate method. +type ManagementGroupsBeginCreateOrUpdateOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string +} + +// ManagementGroupsBeginDeleteOptions contains the optional parameters for the ManagementGroups.BeginDelete method. +type ManagementGroupsBeginDeleteOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string +} + +// ManagementGroupsGetDescendantsOptions contains the optional parameters for the ManagementGroups.GetDescendants method. +type ManagementGroupsGetDescendantsOptions struct { + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point + // to use for subsequent calls. + Skiptoken *string + // Number of elements to return when retrieving results. Passing this in will override $skipToken. + Top *int32 +} + +// ManagementGroupsGetOptions contains the optional parameters for the ManagementGroups.Get method. +type ManagementGroupsGetOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string + // The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from + // the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. + Expand *Enum0 + // A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription') + Filter *string + // The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children + // must be passed up if $recurse is set to true. + Recurse *bool +} + +// ManagementGroupsListOptions contains the optional parameters for the ManagementGroups.List method. +type ManagementGroupsListOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point + // to use for subsequent calls. + Skiptoken *string +} + +// ManagementGroupsUpdateOptions contains the optional parameters for the ManagementGroups.Update method. +type ManagementGroupsUpdateOptions struct { + // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + CacheControl *string +} + +// Operation supported by the Microsoft.Management resource provider. +type Operation struct { + // The object that represents the operation. + Display *OperationDisplayProperties `json:"display,omitempty"` + + // READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty" azure:"ro"` +} + +// OperationDisplayProperties - The object that represents the operation. +type OperationDisplayProperties struct { + // READ-ONLY; Operation description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The operation that can be performed. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The name of the provider. + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The resource on which the operation is performed. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - Describes the result of the request to list Microsoft.Management operations. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the Microsoft.Management resource provider. + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationResults - The results of an asynchronous operation. +type OperationResults struct { + // The generic properties of a management group. + Properties *ManagementGroupInfoProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + Type *string `json:"type,omitempty" azure:"ro"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ParentGroupInfo - (Optional) The ID of the parent management group. +type ParentGroupInfo struct { + // The friendly name of the parent management group. + DisplayName *string `json:"displayName,omitempty"` + + // The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + + // The name of the parent management group + Name *string `json:"name,omitempty"` +} + +// PatchManagementGroupRequest - Management group patch parameters. +type PatchManagementGroupRequest struct { + // The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + + // (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ParentGroupID *string `json:"parentGroupId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PatchManagementGroupRequest. +func (p PatchManagementGroupRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "parentGroupId", p.ParentGroupID) + return json.Marshal(objectMap) +} + +// SubscriptionUnderManagementGroup - The details of subscription under management group. +type SubscriptionUnderManagementGroup struct { + // The generic properties of subscription under a management group. + Properties *SubscriptionUnderManagementGroupProperties `json:"properties,omitempty"` + + // READ-ONLY; The fully qualified ID for the subscription. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001 + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The stringified id of the subscription. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/subscriptions + Type *string `json:"type,omitempty" azure:"ro"` +} + +// SubscriptionUnderManagementGroupProperties - The generic properties of subscription under a management group. +type SubscriptionUnderManagementGroupProperties struct { + // The friendly name of the subscription. + DisplayName *string `json:"displayName,omitempty"` + + // The ID of the parent management group. + Parent *DescendantParentGroupInfo `json:"parent,omitempty"` + + // The state of the subscription. + State *string `json:"state,omitempty"` + + // The AAD Tenant ID associated with the subscription. For example, 00000000-0000-0000-0000-000000000000 + Tenant *string `json:"tenant,omitempty"` +} + +// TenantBackfillStatusResult - The tenant backfill status +type TenantBackfillStatusResult struct { + // READ-ONLY; The status of the Tenant Backfill + Status *Status `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_operations_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_operations_client.go new file mode 100644 index 000000000000..7b1f9955d427 --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_operations_client.go @@ -0,0 +1,81 @@ +//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 armmanagementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// 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(con *arm.Connection) *OperationsClient { + return &OperationsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// List - Lists all of the available Management REST API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + 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/managementgroups/armmanagementgroups/zz_generated_pagers.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_pagers.go new file mode 100644 index 000000000000..f8ee85597c9e --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_pagers.go @@ -0,0 +1,288 @@ +//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 armmanagementgroups + +import ( + "context" + "net/http" + "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// EntitiesListPager provides operations for iterating over paged responses. +type EntitiesListPager struct { + client *EntitiesClient + current EntitiesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, EntitiesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *EntitiesListPager) 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 *EntitiesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EntityListResult.NextLink == nil || len(*p.current.EntityListResult.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 EntitiesListResponse page. +func (p *EntitiesListPager) PageResponse() EntitiesListResponse { + return p.current +} + +// ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager provides operations for iterating over paged responses. +type ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager struct { + client *ManagementGroupSubscriptionsClient + current ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager) 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 *ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ListSubscriptionUnderManagementGroup.NextLink == nil || len(*p.current.ListSubscriptionUnderManagementGroup.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.getSubscriptionsUnderManagementGroupHandleError(resp) + return false + } + result, err := p.client.getSubscriptionsUnderManagementGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse page. +func (p *ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupPager) PageResponse() ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse { + return p.current +} + +// ManagementGroupsGetDescendantsPager provides operations for iterating over paged responses. +type ManagementGroupsGetDescendantsPager struct { + client *ManagementGroupsClient + current ManagementGroupsGetDescendantsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ManagementGroupsGetDescendantsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ManagementGroupsGetDescendantsPager) 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 *ManagementGroupsGetDescendantsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DescendantListResult.NextLink == nil || len(*p.current.DescendantListResult.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.getDescendantsHandleError(resp) + return false + } + result, err := p.client.getDescendantsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ManagementGroupsGetDescendantsResponse page. +func (p *ManagementGroupsGetDescendantsPager) PageResponse() ManagementGroupsGetDescendantsResponse { + return p.current +} + +// ManagementGroupsListPager provides operations for iterating over paged responses. +type ManagementGroupsListPager struct { + client *ManagementGroupsClient + current ManagementGroupsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ManagementGroupsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ManagementGroupsListPager) 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 *ManagementGroupsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ManagementGroupListResult.NextLink == nil || len(*p.current.ManagementGroupListResult.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 ManagementGroupsListResponse page. +func (p *ManagementGroupsListPager) PageResponse() ManagementGroupsListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_pollers.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_pollers.go new file mode 100644 index 000000000000..d3656a55e60e --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_pollers.go @@ -0,0 +1,102 @@ +//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 armmanagementgroups + +import ( + "context" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// ManagementGroupsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ManagementGroupsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ManagementGroupsCreateOrUpdatePoller) 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 *ManagementGroupsCreateOrUpdatePoller) 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 ManagementGroupsCreateOrUpdateResponse will be returned. +func (p *ManagementGroupsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ManagementGroupsCreateOrUpdateResponse, error) { + respType := ManagementGroupsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ManagementGroup) + if err != nil { + return ManagementGroupsCreateOrUpdateResponse{}, 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 *ManagementGroupsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ManagementGroupsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ManagementGroupsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ManagementGroupsDeletePoller) 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 *ManagementGroupsDeletePoller) 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 ManagementGroupsDeleteResponse will be returned. +func (p *ManagementGroupsDeletePoller) FinalResponse(ctx context.Context) (ManagementGroupsDeleteResponse, error) { + respType := ManagementGroupsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.AzureAsyncOperationResults) + if err != nil { + return ManagementGroupsDeleteResponse{}, 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 *ManagementGroupsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_response_types.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_response_types.go new file mode 100644 index 000000000000..ee1026b5fcda --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_response_types.go @@ -0,0 +1,321 @@ +//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 armmanagementgroups + +import ( + "context" + "net/http" + "time" + + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" +) + +// EntitiesListResponse contains the response from method Entities.List. +type EntitiesListResponse struct { + EntitiesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EntitiesListResult contains the result from method Entities.List. +type EntitiesListResult struct { + EntityListResult +} + +// HierarchySettingsCreateOrUpdateResponse contains the response from method HierarchySettings.CreateOrUpdate. +type HierarchySettingsCreateOrUpdateResponse struct { + HierarchySettingsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HierarchySettingsCreateOrUpdateResult contains the result from method HierarchySettings.CreateOrUpdate. +type HierarchySettingsCreateOrUpdateResult struct { + HierarchySettings +} + +// HierarchySettingsDeleteResponse contains the response from method HierarchySettings.Delete. +type HierarchySettingsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HierarchySettingsGetResponse contains the response from method HierarchySettings.Get. +type HierarchySettingsGetResponse struct { + HierarchySettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HierarchySettingsGetResult contains the result from method HierarchySettings.Get. +type HierarchySettingsGetResult struct { + HierarchySettings +} + +// HierarchySettingsListResponse contains the response from method HierarchySettings.List. +type HierarchySettingsListResponse struct { + HierarchySettingsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HierarchySettingsListResult contains the result from method HierarchySettings.List. +type HierarchySettingsListResult struct { + HierarchySettingsList +} + +// HierarchySettingsUpdateResponse contains the response from method HierarchySettings.Update. +type HierarchySettingsUpdateResponse struct { + HierarchySettingsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HierarchySettingsUpdateResult contains the result from method HierarchySettings.Update. +type HierarchySettingsUpdateResult struct { + HierarchySettings +} + +// ManagementGroupSubscriptionsCreateResponse contains the response from method ManagementGroupSubscriptions.Create. +type ManagementGroupSubscriptionsCreateResponse struct { + ManagementGroupSubscriptionsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupSubscriptionsCreateResult contains the result from method ManagementGroupSubscriptions.Create. +type ManagementGroupSubscriptionsCreateResult struct { + SubscriptionUnderManagementGroup +} + +// ManagementGroupSubscriptionsDeleteResponse contains the response from method ManagementGroupSubscriptions.Delete. +type ManagementGroupSubscriptionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupSubscriptionsGetSubscriptionResponse contains the response from method ManagementGroupSubscriptions.GetSubscription. +type ManagementGroupSubscriptionsGetSubscriptionResponse struct { + ManagementGroupSubscriptionsGetSubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupSubscriptionsGetSubscriptionResult contains the result from method ManagementGroupSubscriptions.GetSubscription. +type ManagementGroupSubscriptionsGetSubscriptionResult struct { + SubscriptionUnderManagementGroup +} + +// ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse contains the response from method ManagementGroupSubscriptions.GetSubscriptionsUnderManagementGroup. +type ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResponse struct { + ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResult contains the result from method ManagementGroupSubscriptions.GetSubscriptionsUnderManagementGroup. +type ManagementGroupSubscriptionsGetSubscriptionsUnderManagementGroupResult struct { + ListSubscriptionUnderManagementGroup +} + +// ManagementGroupsAPICheckNameAvailabilityResponse contains the response from method ManagementGroupsAPI.CheckNameAvailability. +type ManagementGroupsAPICheckNameAvailabilityResponse struct { + ManagementGroupsAPICheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsAPICheckNameAvailabilityResult contains the result from method ManagementGroupsAPI.CheckNameAvailability. +type ManagementGroupsAPICheckNameAvailabilityResult struct { + CheckNameAvailabilityResult +} + +// ManagementGroupsAPIStartTenantBackfillResponse contains the response from method ManagementGroupsAPI.StartTenantBackfill. +type ManagementGroupsAPIStartTenantBackfillResponse struct { + ManagementGroupsAPIStartTenantBackfillResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsAPIStartTenantBackfillResult contains the result from method ManagementGroupsAPI.StartTenantBackfill. +type ManagementGroupsAPIStartTenantBackfillResult struct { + TenantBackfillStatusResult +} + +// ManagementGroupsAPITenantBackfillStatusResponse contains the response from method ManagementGroupsAPI.TenantBackfillStatus. +type ManagementGroupsAPITenantBackfillStatusResponse struct { + ManagementGroupsAPITenantBackfillStatusResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsAPITenantBackfillStatusResult contains the result from method ManagementGroupsAPI.TenantBackfillStatus. +type ManagementGroupsAPITenantBackfillStatusResult struct { + TenantBackfillStatusResult +} + +// ManagementGroupsCreateOrUpdatePollerResponse contains the response from method ManagementGroups.CreateOrUpdate. +type ManagementGroupsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ManagementGroupsCreateOrUpdatePoller + + // 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. +func (l ManagementGroupsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ManagementGroupsCreateOrUpdateResponse, error) { + respType := ManagementGroupsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ManagementGroup) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ManagementGroupsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ManagementGroupsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ManagementGroupsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ManagementGroupsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ManagementGroupsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ManagementGroupsCreateOrUpdateResponse contains the response from method ManagementGroups.CreateOrUpdate. +type ManagementGroupsCreateOrUpdateResponse struct { + ManagementGroupsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsCreateOrUpdateResult contains the result from method ManagementGroups.CreateOrUpdate. +type ManagementGroupsCreateOrUpdateResult struct { + ManagementGroup +} + +// ManagementGroupsDeletePollerResponse contains the response from method ManagementGroups.Delete. +type ManagementGroupsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ManagementGroupsDeletePoller + + // 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. +func (l ManagementGroupsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ManagementGroupsDeleteResponse, error) { + respType := ManagementGroupsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.AzureAsyncOperationResults) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ManagementGroupsDeletePollerResponse from the provided client and resume token. +func (l *ManagementGroupsDeletePollerResponse) Resume(ctx context.Context, client *ManagementGroupsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ManagementGroupsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ManagementGroupsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ManagementGroupsDeleteResponse contains the response from method ManagementGroups.Delete. +type ManagementGroupsDeleteResponse struct { + ManagementGroupsDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsDeleteResult contains the result from method ManagementGroups.Delete. +type ManagementGroupsDeleteResult struct { + AzureAsyncOperationResults +} + +// ManagementGroupsGetDescendantsResponse contains the response from method ManagementGroups.GetDescendants. +type ManagementGroupsGetDescendantsResponse struct { + ManagementGroupsGetDescendantsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsGetDescendantsResult contains the result from method ManagementGroups.GetDescendants. +type ManagementGroupsGetDescendantsResult struct { + DescendantListResult +} + +// ManagementGroupsGetResponse contains the response from method ManagementGroups.Get. +type ManagementGroupsGetResponse struct { + ManagementGroupsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsGetResult contains the result from method ManagementGroups.Get. +type ManagementGroupsGetResult struct { + ManagementGroup +} + +// ManagementGroupsListResponse contains the response from method ManagementGroups.List. +type ManagementGroupsListResponse struct { + ManagementGroupsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsListResult contains the result from method ManagementGroups.List. +type ManagementGroupsListResult struct { + ManagementGroupListResult +} + +// ManagementGroupsUpdateResponse contains the response from method ManagementGroups.Update. +type ManagementGroupsUpdateResponse struct { + ManagementGroupsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsUpdateResult contains the result from method ManagementGroups.Update. +type ManagementGroupsUpdateResult struct { + ManagementGroup +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_time_rfc3339.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..c23b6f58e1cc --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/zz_generated_time_rfc3339.go @@ -0,0 +1,58 @@ +//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 armmanagementgroups + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +}