diff --git a/profiles/preview/preview/resources/mgmt/management/models.go b/profiles/preview/preview/resources/mgmt/management/models.go index 9fdcb6a980a8..f80d04cac30a 100644 --- a/profiles/preview/preview/resources/mgmt/management/models.go +++ b/profiles/preview/preview/resources/mgmt/management/models.go @@ -19,7 +19,7 @@ package managementgroups -import original "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/management" +import original "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-03-01-preview/management" const ( DefaultBaseURI = original.DefaultBaseURI @@ -28,13 +28,22 @@ const ( type BaseClient = original.BaseClient type EntitiesClient = original.EntitiesClient type Client = original.Client +type InheritedPermissions = original.InheritedPermissions + +const ( + Delete InheritedPermissions = original.Delete + Edit InheritedPermissions = original.Edit + Noaccess InheritedPermissions = original.Noaccess + View InheritedPermissions = original.View +) + type Permissions = original.Permissions const ( - Delete Permissions = original.Delete - Edit Permissions = original.Edit - Noaccess Permissions = original.Noaccess - View Permissions = original.View + PermissionsDelete Permissions = original.PermissionsDelete + PermissionsEdit Permissions = original.PermissionsEdit + PermissionsNoaccess Permissions = original.PermissionsNoaccess + PermissionsView Permissions = original.PermissionsView ) type Permissions1 = original.Permissions1 @@ -59,17 +68,28 @@ const ( Invalid Reason = original.Invalid ) +type Status = original.Status + +const ( + Cancelled Status = original.Cancelled + Completed Status = original.Completed + Failed Status = original.Failed + NotStarted Status = original.NotStarted + NotStartedButGroupsExist Status = original.NotStartedButGroupsExist + Started Status = original.Started +) + type Type = original.Type const ( - ProvidersMicrosoftManagementmanagementGroups Type = original.ProvidersMicrosoftManagementmanagementGroups + ProvidersMicrosoftManagementmanagementGroup Type = original.ProvidersMicrosoftManagementmanagementGroup ) type Type1 = original.Type1 const ( - Type1ProvidersMicrosoftManagementmanagementGroups Type1 = original.Type1ProvidersMicrosoftManagementmanagementGroups - Type1Subscriptions Type1 = original.Type1Subscriptions + ProvidersMicrosoftManagementmanagementGroups Type1 = original.ProvidersMicrosoftManagementmanagementGroups + Subscriptions Type1 = original.Subscriptions ) type Type2 = original.Type2 @@ -117,26 +137,30 @@ type ParentGroupInfo = original.ParentGroupInfo type PatchManagementGroupRequest = original.PatchManagementGroupRequest type Properties = original.Properties type SetObject = original.SetObject +type TenantBackfillStatusResult = original.TenantBackfillStatusResult type OperationsClient = original.OperationsClient type SubscriptionsClient = original.SubscriptionsClient -func New(operationResultID string, skiptoken string) BaseClient { - return original.New(operationResultID, skiptoken) +func New() BaseClient { + return original.New() } -func NewWithBaseURI(baseURI string, operationResultID string, skiptoken string) BaseClient { - return original.NewWithBaseURI(baseURI, operationResultID, skiptoken) +func NewWithBaseURI(baseURI string) BaseClient { + return original.NewWithBaseURI(baseURI) } -func NewEntitiesClient(operationResultID string, skiptoken string) EntitiesClient { - return original.NewEntitiesClient(operationResultID, skiptoken) +func NewEntitiesClient() EntitiesClient { + return original.NewEntitiesClient() } -func NewEntitiesClientWithBaseURI(baseURI string, operationResultID string, skiptoken string) EntitiesClient { - return original.NewEntitiesClientWithBaseURI(baseURI, operationResultID, skiptoken) +func NewEntitiesClientWithBaseURI(baseURI string) EntitiesClient { + return original.NewEntitiesClientWithBaseURI(baseURI) } -func NewClient(operationResultID string, skiptoken string) Client { - return original.NewClient(operationResultID, skiptoken) +func NewClient() Client { + return original.NewClient() } -func NewClientWithBaseURI(baseURI string, operationResultID string, skiptoken string) Client { - return original.NewClientWithBaseURI(baseURI, operationResultID, skiptoken) +func NewClientWithBaseURI(baseURI string) Client { + return original.NewClientWithBaseURI(baseURI) +} +func PossibleInheritedPermissionsValues() []InheritedPermissions { + return original.PossibleInheritedPermissionsValues() } func PossiblePermissionsValues() []Permissions { return original.PossiblePermissionsValues() @@ -150,6 +174,9 @@ func PossibleProvisioningStateValues() []ProvisioningState { func PossibleReasonValues() []Reason { return original.PossibleReasonValues() } +func PossibleStatusValues() []Status { + return original.PossibleStatusValues() +} func PossibleTypeValues() []Type { return original.PossibleTypeValues() } @@ -159,17 +186,17 @@ func PossibleType1Values() []Type1 { func PossibleType2Values() []Type2 { return original.PossibleType2Values() } -func NewOperationsClient(operationResultID string, skiptoken string) OperationsClient { - return original.NewOperationsClient(operationResultID, skiptoken) +func NewOperationsClient() OperationsClient { + return original.NewOperationsClient() } -func NewOperationsClientWithBaseURI(baseURI string, operationResultID string, skiptoken string) OperationsClient { - return original.NewOperationsClientWithBaseURI(baseURI, operationResultID, skiptoken) +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI) } -func NewSubscriptionsClient(operationResultID string, skiptoken string) SubscriptionsClient { - return original.NewSubscriptionsClient(operationResultID, skiptoken) +func NewSubscriptionsClient() SubscriptionsClient { + return original.NewSubscriptionsClient() } -func NewSubscriptionsClientWithBaseURI(baseURI string, operationResultID string, skiptoken string) SubscriptionsClient { - return original.NewSubscriptionsClientWithBaseURI(baseURI, operationResultID, skiptoken) +func NewSubscriptionsClientWithBaseURI(baseURI string) SubscriptionsClient { + return original.NewSubscriptionsClientWithBaseURI(baseURI) } func UserAgent() string { return original.UserAgent() + " profiles/preview" diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/client.go b/services/preview/resources/mgmt/2018-03-01-preview/management/client.go new file mode 100644 index 000000000000..38085ea838dc --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/client.go @@ -0,0 +1,231 @@ +// Package managementgroups implements the Azure ARM Managementgroups service API version 2018-03-01-preview. +// +// The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational +// hierarchy and centrally manage access control, policies, alerting and reporting for those resources. +package managementgroups + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Managementgroups + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Managementgroups. +type BaseClient struct { + autorest.Client + BaseURI string +} + +// New creates an instance of the BaseClient client. +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + } +} + +// CheckNameAvailability checks if the specified management group name is valid and unique +// Parameters: +// checkNameAvailabilityRequest - management group name availability check parameters. +func (client BaseClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest) (result CheckNameAvailabilityResult, err error) { + req, err := client.CheckNameAvailabilityPreparer(ctx, checkNameAvailabilityRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client BaseClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Management/checkNameAvailability"), + autorest.WithJSON(checkNameAvailabilityRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client BaseClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// StartTenantBackfill starts backfilling subscriptions for the Tenant. +func (client BaseClient) StartTenantBackfill(ctx context.Context) (result TenantBackfillStatusResult, err error) { + req, err := client.StartTenantBackfillPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "StartTenantBackfill", nil, "Failure preparing request") + return + } + + resp, err := client.StartTenantBackfillSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "StartTenantBackfill", resp, "Failure sending request") + return + } + + result, err = client.StartTenantBackfillResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "StartTenantBackfill", resp, "Failure responding to request") + } + + return +} + +// StartTenantBackfillPreparer prepares the StartTenantBackfill request. +func (client BaseClient) StartTenantBackfillPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Management/startTenantBackfill"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartTenantBackfillSender sends the StartTenantBackfill request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) StartTenantBackfillSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// StartTenantBackfillResponder handles the response to the StartTenantBackfill request. The method always +// closes the http.Response Body. +func (client BaseClient) StartTenantBackfillResponder(resp *http.Response) (result TenantBackfillStatusResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TenantBackfillStatus gets tenant backfill status +func (client BaseClient) TenantBackfillStatus(ctx context.Context) (result TenantBackfillStatusResult, err error) { + req, err := client.TenantBackfillStatusPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "TenantBackfillStatus", nil, "Failure preparing request") + return + } + + resp, err := client.TenantBackfillStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "TenantBackfillStatus", resp, "Failure sending request") + return + } + + result, err = client.TenantBackfillStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "TenantBackfillStatus", resp, "Failure responding to request") + } + + return +} + +// TenantBackfillStatusPreparer prepares the TenantBackfillStatus request. +func (client BaseClient) TenantBackfillStatusPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Management/tenantBackfillStatus"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TenantBackfillStatusSender sends the TenantBackfillStatus request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) TenantBackfillStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// TenantBackfillStatusResponder handles the response to the TenantBackfillStatus request. The method always +// closes the http.Response Body. +func (client BaseClient) TenantBackfillStatusResponder(resp *http.Response) (result TenantBackfillStatusResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/entities.go b/services/preview/resources/mgmt/2018-03-01-preview/management/entities.go new file mode 100644 index 000000000000..b3b576119866 --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/entities.go @@ -0,0 +1,186 @@ +package managementgroups + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// EntitiesClient is the the Azure Management Groups API enables consolidation of multiple subscriptions/resources into +// an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those +// resources. +type EntitiesClient struct { + BaseClient +} + +// NewEntitiesClient creates an instance of the EntitiesClient client. +func NewEntitiesClient() EntitiesClient { + return NewEntitiesClientWithBaseURI(DefaultBaseURI) +} + +// NewEntitiesClientWithBaseURI creates an instance of the EntitiesClient client. +func NewEntitiesClientWithBaseURI(baseURI string) EntitiesClient { + return EntitiesClient{NewWithBaseURI(baseURI)} +} + +// List list all entities (Management Groups, Subscriptions, etc.) for the authenticated user. +// Parameters: +// skiptoken - 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. +// skip - number of entities to skip over when retrieving results. Passing this in will override $skipToken. +// top - number of elements to return when retrieving results. Passing this in will override $skipToken. +// selectParameter - 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. +// search - 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. +// filter - 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. +// view - the view parameter allows clients to filter the type of data that is returned by the getEntities +// call. +// groupName - a filter which allows the get entities call to focus on a particular group (i.e. "$filter=name +// eq 'groupName'") +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client EntitiesClient) List(ctx context.Context, skiptoken string, skip *int32, top *int32, selectParameter string, search string, filter string, view string, groupName string, cacheControl string) (result EntityListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, skiptoken, skip, top, selectParameter, search, filter, view, groupName, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.elr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", resp, "Failure sending request") + return + } + + result.elr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client EntitiesClient) ListPreparer(ctx context.Context, skiptoken string, skip *int32, top *int32, selectParameter string, search string, filter string, view string, groupName string, cacheControl string) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if len(string(search)) > 0 { + queryParameters["$search"] = autorest.Encode("query", search) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(string(view)) > 0 { + queryParameters["$view"] = autorest.Encode("query", view) + } + if len(groupName) > 0 { + queryParameters["groupName"] = autorest.Encode("query", groupName) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Management/getEntities"), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client EntitiesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client EntitiesClient) ListResponder(resp *http.Response) (result EntityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client EntitiesClient) listNextResults(lastResults EntityListResult) (result EntityListResult, err error) { + req, err := lastResults.entityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client EntitiesClient) ListComplete(ctx context.Context, skiptoken string, skip *int32, top *int32, selectParameter string, search string, filter string, view string, groupName string, cacheControl string) (result EntityListResultIterator, err error) { + result.page, err = client.List(ctx, skiptoken, skip, top, selectParameter, search, filter, view, groupName, cacheControl) + return +} diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/managementgroups.go b/services/preview/resources/mgmt/2018-03-01-preview/management/managementgroups.go new file mode 100644 index 000000000000..f3811bb928ca --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/managementgroups.go @@ -0,0 +1,456 @@ +package managementgroups + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// Client is the the Azure Management Groups API enables consolidation of multiple subscriptions/resources into an +// organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources. +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient() Client { + return NewClientWithBaseURI(DefaultBaseURI) +} + +// NewClientWithBaseURI creates an instance of the Client client. +func NewClientWithBaseURI(baseURI string) Client { + return Client{NewWithBaseURI(baseURI)} +} + +// 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. +// Parameters: +// groupID - management Group ID. +// createManagementGroupRequest - management group creation parameters. +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client Client) CreateOrUpdate(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, cacheControl string) (result CreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, groupID, createManagementGroupRequest, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Client) CreateOrUpdatePreparer(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, cacheControl string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), + autorest.WithJSON(createManagementGroupRequest), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client Client) CreateOrUpdateResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete management group. If a management group contains child resources, the request will fail. +// Parameters: +// groupID - management Group ID. +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client Client) Delete(ctx context.Context, groupID string, cacheControl string) (result DeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, groupID, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(ctx context.Context, groupID string, cacheControl string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) { + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client Client) DeleteResponder(resp *http.Response) (result OperationResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the details of the management group. +// Parameters: +// groupID - management Group ID. +// expand - the $expand=children query string parameter allows clients to request inclusion of children in the +// response payload. +// recurse - 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. +// filter - a filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType +// ne Subscription') +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client Client) Get(ctx context.Context, groupID string, expand string, recurse *bool, filter string, cacheControl string) (result ManagementGroup, err error) { + req, err := client.GetPreparer(ctx, groupID, expand, recurse, filter, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(ctx context.Context, groupID string, expand string, recurse *bool, filter string, cacheControl string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(expand)) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if recurse != nil { + queryParameters["$recurse"] = autorest.Encode("query", *recurse) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client Client) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client Client) GetResponder(resp *http.Response) (result ManagementGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list management groups for the authenticated user. +// Parameters: +// cacheControl - indicates that the request shouldn't utilize any caches. +// skiptoken - 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. +func (client Client) List(ctx context.Context, cacheControl string, skiptoken string) (result ListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, cacheControl, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.lr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.Client", "List", resp, "Failure sending request") + return + } + + result.lr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client Client) ListPreparer(ctx context.Context, cacheControl string, skiptoken string) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Management/managementGroups"), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client Client) listNextResults(lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managementgroups.Client", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managementgroups.Client", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListComplete(ctx context.Context, cacheControl string, skiptoken string) (result ListResultIterator, err error) { + result.page, err = client.List(ctx, cacheControl, skiptoken) + return +} + +// Update update a management group. +// Parameters: +// groupID - management Group ID. +// patchGroupRequest - management group patch parameters. +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client Client) Update(ctx context.Context, groupID string, patchGroupRequest PatchManagementGroupRequest, cacheControl string) (result ManagementGroup, err error) { + req, err := client.UpdatePreparer(ctx, groupID, patchGroupRequest, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.Client", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, groupID string, patchGroupRequest PatchManagementGroupRequest, cacheControl string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), + autorest.WithJSON(patchGroupRequest), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client Client) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client Client) UpdateResponder(resp *http.Response) (result ManagementGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/models.go b/services/preview/resources/mgmt/2018-03-01-preview/management/models.go new file mode 100644 index 000000000000..7ad7af514407 --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/models.go @@ -0,0 +1,1286 @@ +package managementgroups + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// InheritedPermissions enumerates the values for inherited permissions. +type InheritedPermissions string + +const ( + // Delete ... + Delete InheritedPermissions = "delete" + // Edit ... + Edit InheritedPermissions = "edit" + // Noaccess ... + Noaccess InheritedPermissions = "noaccess" + // View ... + View InheritedPermissions = "view" +) + +// PossibleInheritedPermissionsValues returns an array of possible values for the InheritedPermissions const type. +func PossibleInheritedPermissionsValues() []InheritedPermissions { + return []InheritedPermissions{Delete, Edit, Noaccess, View} +} + +// Permissions enumerates the values for permissions. +type Permissions string + +const ( + // PermissionsDelete ... + PermissionsDelete Permissions = "delete" + // PermissionsEdit ... + PermissionsEdit Permissions = "edit" + // PermissionsNoaccess ... + PermissionsNoaccess Permissions = "noaccess" + // PermissionsView ... + PermissionsView Permissions = "view" +) + +// PossiblePermissionsValues returns an array of possible values for the Permissions const type. +func PossiblePermissionsValues() []Permissions { + return []Permissions{PermissionsDelete, PermissionsEdit, PermissionsNoaccess, PermissionsView} +} + +// Permissions1 enumerates the values for permissions 1. +type Permissions1 string + +const ( + // Permissions1Delete ... + Permissions1Delete Permissions1 = "delete" + // Permissions1Edit ... + Permissions1Edit Permissions1 = "edit" + // Permissions1Noaccess ... + Permissions1Noaccess Permissions1 = "noaccess" + // Permissions1View ... + Permissions1View Permissions1 = "view" +) + +// PossiblePermissions1Values returns an array of possible values for the Permissions1 const type. +func PossiblePermissions1Values() []Permissions1 { + return []Permissions1{Permissions1Delete, Permissions1Edit, Permissions1Noaccess, Permissions1View} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Updating} +} + +// Reason enumerates the values for reason. +type Reason string + +const ( + // AlreadyExists ... + AlreadyExists Reason = "AlreadyExists" + // Invalid ... + Invalid Reason = "Invalid" +) + +// PossibleReasonValues returns an array of possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{AlreadyExists, Invalid} +} + +// Status enumerates the values for status. +type Status string + +const ( + // Cancelled ... + Cancelled Status = "Cancelled" + // Completed ... + Completed Status = "Completed" + // Failed ... + Failed Status = "Failed" + // NotStarted ... + NotStarted Status = "NotStarted" + // NotStartedButGroupsExist ... + NotStartedButGroupsExist Status = "NotStartedButGroupsExist" + // Started ... + Started Status = "Started" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{Cancelled, Completed, Failed, NotStarted, NotStartedButGroupsExist, Started} +} + +// Type enumerates the values for type. +type Type string + +const ( + // ProvidersMicrosoftManagementmanagementGroup ... + ProvidersMicrosoftManagementmanagementGroup Type = "/providers/Microsoft.Management/managementGroup" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ProvidersMicrosoftManagementmanagementGroup} +} + +// Type1 enumerates the values for type 1. +type Type1 string + +const ( + // ProvidersMicrosoftManagementmanagementGroups ... + ProvidersMicrosoftManagementmanagementGroups Type1 = "/providers/Microsoft.Management/managementGroups" + // Subscriptions ... + Subscriptions Type1 = "/subscriptions" +) + +// PossibleType1Values returns an array of possible values for the Type1 const type. +func PossibleType1Values() []Type1 { + return []Type1{ProvidersMicrosoftManagementmanagementGroups, Subscriptions} +} + +// Type2 enumerates the values for type 2. +type Type2 string + +const ( + // Type2ProvidersMicrosoftManagementmanagementGroups ... + Type2ProvidersMicrosoftManagementmanagementGroups Type2 = "/providers/Microsoft.Management/managementGroups" + // Type2Subscriptions ... + Type2Subscriptions Type2 = "/subscriptions" +) + +// PossibleType2Values returns an array of possible values for the Type2 const type. +func PossibleType2Values() []Type2 { + return []Type2{Type2ProvidersMicrosoftManagementmanagementGroups, Type2Subscriptions} +} + +// CheckNameAvailabilityRequest management group name availability check parameters. +type CheckNameAvailabilityRequest struct { + // Name - the name to check for availability + Name *string `json:"name,omitempty"` + // Type - fully qualified resource type which includes provider namespace. Possible values include: 'ProvidersMicrosoftManagementmanagementGroup' + Type Type `json:"type,omitempty"` +} + +// CheckNameAvailabilityResult describes the result of the request to check management group name availability. +type CheckNameAvailabilityResult struct { + autorest.Response `json:"-"` + // NameAvailable - Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // 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. Possible values include: 'Invalid', 'AlreadyExists' + Reason Reason `json:"reason,omitempty"` + // Message - 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"` +} + +// ChildInfo the child information of a management group. +type ChildInfo struct { + // Type - The fully qualified resource type which includes provider namespace (e.g. /providers/Microsoft.Management/managementGroups). Possible values include: 'ProvidersMicrosoftManagementmanagementGroups', 'Subscriptions' + Type Type1 `json:"type,omitempty"` + // ID - 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"` + // Name - The name of the child entity. + Name *string `json:"name,omitempty"` + // DisplayName - The friendly name of the child resource. + DisplayName *string `json:"displayName,omitempty"` + // Roles - The roles definitions associated with the management group. + Roles *[]string `json:"roles,omitempty"` + // Children - The list of children. + Children *[]ChildInfo `json:"children,omitempty"` +} + +// CreateManagementGroupChildInfo the child information of a management group used during creation. +type CreateManagementGroupChildInfo struct { + // Type - The fully qualified resource type which includes provider namespace (e.g. /providers/Microsoft.Management/managementGroups). Possible values include: 'Type2ProvidersMicrosoftManagementmanagementGroups', 'Type2Subscriptions' + Type Type2 `json:"type,omitempty"` + // ID - 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"` + // Name - The name of the child entity. + Name *string `json:"name,omitempty"` + // DisplayName - The friendly name of the child resource. + DisplayName *string `json:"displayName,omitempty"` + // Roles - The roles definitions associated with the management group. + Roles *[]string `json:"roles,omitempty"` + // Children - The list of children. + Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"` +} + +// CreateManagementGroupDetails the details of a management group used during creation. +type CreateManagementGroupDetails struct { + // Version - The version number of the object. + Version *float64 `json:"version,omitempty"` + // UpdatedTime - The date and time when this object was last updated. + UpdatedTime *date.Time `json:"updatedTime,omitempty"` + // UpdatedBy - The identity of the principal or process that updated the object. + UpdatedBy *string `json:"updatedBy,omitempty"` + Parent *CreateParentGroupInfo `json:"parent,omitempty"` +} + +// CreateManagementGroupProperties the generic properties of a management group used during creation. +type CreateManagementGroupProperties struct { + // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` + // DisplayName - 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"` + // Roles - The roles definitions associated with the management group. + Roles *[]string `json:"roles,omitempty"` + Details *CreateManagementGroupDetails `json:"details,omitempty"` + // Children - The list of children. + Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"` +} + +// CreateManagementGroupRequest management group creation parameters. +type CreateManagementGroupRequest struct { + // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups + Type *string `json:"type,omitempty"` + // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + *CreateManagementGroupProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CreateManagementGroupRequest. +func (cmgr CreateManagementGroupRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cmgr.ID != nil { + objectMap["id"] = cmgr.ID + } + if cmgr.Type != nil { + objectMap["type"] = cmgr.Type + } + if cmgr.Name != nil { + objectMap["name"] = cmgr.Name + } + if cmgr.CreateManagementGroupProperties != nil { + objectMap["properties"] = cmgr.CreateManagementGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CreateManagementGroupRequest struct. +func (cmgr *CreateManagementGroupRequest) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cmgr.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cmgr.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cmgr.Name = &name + } + case "properties": + if v != nil { + var createManagementGroupProperties CreateManagementGroupProperties + err = json.Unmarshal(*v, &createManagementGroupProperties) + if err != nil { + return err + } + cmgr.CreateManagementGroupProperties = &createManagementGroupProperties + } + } + } + + return nil +} + +// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future CreateOrUpdateFuture) Result(client Client) (so SetObject, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return so, azure.NewAsyncOpIncompleteError("managementgroups.CreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + so, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + so, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// CreateParentGroupInfo (Optional) The ID of the parent management group used during creation. +type CreateParentGroupInfo struct { + // ID - 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"` + // Name - The name of the parent management group + Name *string `json:"name,omitempty"` + // DisplayName - The friendly name of the parent management group. + DisplayName *string `json:"displayName,omitempty"` +} + +// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DeleteFuture) Result(client Client) (or OperationResults, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return or, azure.NewAsyncOpIncompleteError("managementgroups.DeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + or, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", resp, "Failure sending request") + return + } + or, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// Details the details of a management group. +type Details struct { + // Version - The version number of the object. + Version *float64 `json:"version,omitempty"` + // UpdatedTime - The date and time when this object was last updated. + UpdatedTime *date.Time `json:"updatedTime,omitempty"` + // UpdatedBy - The identity of the principal or process that updated the object. + UpdatedBy *string `json:"updatedBy,omitempty"` + Parent *ParentGroupInfo `json:"parent,omitempty"` +} + +// EntityHierarchyItem the management group details for the hierarchy view. +type EntityHierarchyItem struct { + // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups + Type *string `json:"type,omitempty"` + // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + *EntityHierarchyItemProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for EntityHierarchyItem. +func (ehi EntityHierarchyItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ehi.ID != nil { + objectMap["id"] = ehi.ID + } + if ehi.Type != nil { + objectMap["type"] = ehi.Type + } + if ehi.Name != nil { + objectMap["name"] = ehi.Name + } + if ehi.EntityHierarchyItemProperties != nil { + objectMap["properties"] = ehi.EntityHierarchyItemProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EntityHierarchyItem struct. +func (ehi *EntityHierarchyItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ehi.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ehi.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ehi.Name = &name + } + case "properties": + if v != nil { + var entityHierarchyItemProperties EntityHierarchyItemProperties + err = json.Unmarshal(*v, &entityHierarchyItemProperties) + if err != nil { + return err + } + ehi.EntityHierarchyItemProperties = &entityHierarchyItemProperties + } + } + } + + return nil +} + +// EntityHierarchyItemProperties the generic properties of a management group. +type EntityHierarchyItemProperties struct { + // DisplayName - The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + // Permissions - Possible values include: 'Permissions1Noaccess', 'Permissions1View', 'Permissions1Edit', 'Permissions1Delete' + Permissions Permissions1 `json:"permissions,omitempty"` + // Children - The list of children. + Children *[]EntityHierarchyItem `json:"children,omitempty"` +} + +// EntityInfo the entity. +type EntityInfo struct { + // ID - The fully qualified ID for the entity. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups + Type *string `json:"type,omitempty"` + // Name - The name of the entity. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + *EntityInfoProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for EntityInfo. +func (ei EntityInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ei.ID != nil { + objectMap["id"] = ei.ID + } + if ei.Type != nil { + objectMap["type"] = ei.Type + } + if ei.Name != nil { + objectMap["name"] = ei.Name + } + if ei.EntityInfoProperties != nil { + objectMap["properties"] = ei.EntityInfoProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EntityInfo struct. +func (ei *EntityInfo) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ei.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ei.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ei.Name = &name + } + case "properties": + if v != nil { + var entityInfoProperties EntityInfoProperties + err = json.Unmarshal(*v, &entityInfoProperties) + if err != nil { + return err + } + ei.EntityInfoProperties = &entityInfoProperties + } + } + } + + return nil +} + +// EntityInfoProperties the generic properties of an entity. +type EntityInfoProperties struct { + // TenantID - The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` + // DisplayName - The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + Parent *EntityParentGroupInfo `json:"parent,omitempty"` + // Permissions - Possible values include: 'PermissionsNoaccess', 'PermissionsView', 'PermissionsEdit', 'PermissionsDelete' + Permissions Permissions `json:"permissions,omitempty"` + // InheritedPermissions - Possible values include: 'Noaccess', 'View', 'Edit', 'Delete' + InheritedPermissions InheritedPermissions `json:"inheritedPermissions,omitempty"` + NumberOfDescendants *int32 `json:"numberOfDescendants,omitempty"` + // ParentDisplayNameChain - The parent display name chain from the root group to the immediate parent + ParentDisplayNameChain *[]string `json:"parentDisplayNameChain,omitempty"` + // ParentNameChain - The parent name chain from the root group to the immediate parent + ParentNameChain *[]string `json:"parentNameChain,omitempty"` +} + +// EntityListResult describes the result of the request to view entities. +type EntityListResult struct { + autorest.Response `json:"-"` + // Value - The list of entities. + Value *[]EntityInfo `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// EntityListResultIterator provides access to a complete listing of EntityInfo values. +type EntityListResultIterator struct { + i int + page EntityListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EntityListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EntityListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EntityListResultIterator) Response() EntityListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EntityListResultIterator) Value() EntityInfo { + if !iter.page.NotDone() { + return EntityInfo{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (elr EntityListResult) IsEmpty() bool { + return elr.Value == nil || len(*elr.Value) == 0 +} + +// entityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (elr EntityListResult) entityListResultPreparer() (*http.Request, error) { + if elr.NextLink == nil || len(to.String(elr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(elr.NextLink))) +} + +// EntityListResultPage contains a page of EntityInfo values. +type EntityListResultPage struct { + fn func(EntityListResult) (EntityListResult, error) + elr EntityListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EntityListResultPage) Next() error { + next, err := page.fn(page.elr) + if err != nil { + return err + } + page.elr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EntityListResultPage) NotDone() bool { + return !page.elr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EntityListResultPage) Response() EntityListResult { + return page.elr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EntityListResultPage) Values() []EntityInfo { + if page.elr.IsEmpty() { + return nil + } + return *page.elr.Value +} + +// EntityParentGroupInfo (Optional) The ID of the parent management group. +type EntityParentGroupInfo struct { + // ID - 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 { + // Code - One of a server-defined set of error codes. + Code *string `json:"code,omitempty"` + // Message - A human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Details - A human-readable representation of the error's details. + Details *string `json:"details,omitempty"` +} + +// ErrorResponse the error object. +type ErrorResponse struct { + Error *ErrorDetails `json:"error,omitempty"` +} + +// Info the management group resource. +type Info struct { + // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups + Type *string `json:"type,omitempty"` + // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + *InfoProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Info. +func (i Info) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.ID != nil { + objectMap["id"] = i.ID + } + if i.Type != nil { + objectMap["type"] = i.Type + } + if i.Name != nil { + objectMap["name"] = i.Name + } + if i.InfoProperties != nil { + objectMap["properties"] = i.InfoProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Info struct. +func (i *Info) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + i.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + i.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + i.Name = &name + } + case "properties": + if v != nil { + var infoProperties InfoProperties + err = json.Unmarshal(*v, &infoProperties) + if err != nil { + return err + } + i.InfoProperties = &infoProperties + } + } + } + + return nil +} + +// InfoProperties the generic properties of a management group. +type InfoProperties struct { + // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` + // DisplayName - The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` +} + +// ListResult describes the result of the request to list management groups. +type ListResult struct { + autorest.Response `json:"-"` + // Value - The list of management groups. + Value *[]Info `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListResultIterator provides access to a complete listing of Info values. +type ListResultIterator struct { + i int + page ListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ListResultIterator) Response() ListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ListResultIterator) Value() Info { + if !iter.page.NotDone() { + return Info{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (lr ListResult) IsEmpty() bool { + return lr.Value == nil || len(*lr.Value) == 0 +} + +// listResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lr ListResult) listResultPreparer() (*http.Request, error) { + if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lr.NextLink))) +} + +// ListResultPage contains a page of Info values. +type ListResultPage struct { + fn func(ListResult) (ListResult, error) + lr ListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ListResultPage) Next() error { + next, err := page.fn(page.lr) + if err != nil { + return err + } + page.lr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListResultPage) NotDone() bool { + return !page.lr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListResultPage) Response() ListResult { + return page.lr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListResultPage) Values() []Info { + if page.lr.IsEmpty() { + return nil + } + return *page.lr.Value +} + +// ManagementGroup the management group details. +type ManagementGroup struct { + autorest.Response `json:"-"` + // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups + Type *string `json:"type,omitempty"` + // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + *Properties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagementGroup. +func (mg ManagementGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mg.ID != nil { + objectMap["id"] = mg.ID + } + if mg.Type != nil { + objectMap["type"] = mg.Type + } + if mg.Name != nil { + objectMap["name"] = mg.Name + } + if mg.Properties != nil { + objectMap["properties"] = mg.Properties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagementGroup struct. +func (mg *ManagementGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mg.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mg.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mg.Name = &name + } + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + mg.Properties = &properties + } + } + } + + return nil +} + +// Operation operation supported by the Microsoft.Management resource provider. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + Display *OperationDisplayProperties `json:"display,omitempty"` +} + +// OperationDisplayProperties the object that represents the operation. +type OperationDisplayProperties struct { + // Provider - The name of the provider. + Provider *string `json:"provider,omitempty"` + // Resource - The resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - The operation that can be performed. + Operation *string `json:"operation,omitempty"` + // Description - Operation description. + Description *string `json:"description,omitempty"` +} + +// OperationListResult describes the result of the request to list Microsoft.Management operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Microsoft.Management resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// OperationResults the results of an asynchronous operation. +type OperationResults struct { + autorest.Response `json:"-"` + // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ID *string `json:"id,omitempty"` + // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups + Type *string `json:"type,omitempty"` + // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 + Name *string `json:"name,omitempty"` + *OperationResultsProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationResults. +func (or OperationResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if or.ID != nil { + objectMap["id"] = or.ID + } + if or.Type != nil { + objectMap["type"] = or.Type + } + if or.Name != nil { + objectMap["name"] = or.Name + } + if or.OperationResultsProperties != nil { + objectMap["properties"] = or.OperationResultsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OperationResults struct. +func (or *OperationResults) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + or.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + or.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + or.Name = &name + } + case "properties": + if v != nil { + var operationResultsProperties OperationResultsProperties + err = json.Unmarshal(*v, &operationResultsProperties) + if err != nil { + return err + } + or.OperationResultsProperties = &operationResultsProperties + } + } + } + + return nil +} + +// OperationResultsProperties ... +type OperationResultsProperties struct { + // ProvisioningState - Possible values include: 'Updating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// ParentGroupInfo (Optional) The ID of the parent management group. +type ParentGroupInfo struct { + // ID - 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"` + // Name - The name of the parent management group + Name *string `json:"name,omitempty"` + // DisplayName - The friendly name of the parent management group. + DisplayName *string `json:"displayName,omitempty"` +} + +// PatchManagementGroupRequest management group patch parameters. +type PatchManagementGroupRequest struct { + // DisplayName - The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + // ParentID - (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + ParentID *string `json:"parentId,omitempty"` +} + +// Properties the generic properties of a management group. +type Properties struct { + // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` + // DisplayName - The friendly name of the management group. + DisplayName *string `json:"displayName,omitempty"` + // Roles - The role definitions associated with the management group. + Roles *[]string `json:"roles,omitempty"` + Details *Details `json:"details,omitempty"` + // Children - The list of children. + Children *[]ChildInfo `json:"children,omitempty"` +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// TenantBackfillStatusResult the tenant backfill status +type TenantBackfillStatusResult struct { + autorest.Response `json:"-"` + // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 + TenantID *string `json:"tenantId,omitempty"` + // Status - The status of the Tenant Backfill. Possible values include: 'NotStarted', 'NotStartedButGroupsExist', 'Started', 'Failed', 'Cancelled', 'Completed' + Status Status `json:"status,omitempty"` +} diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/operations.go b/services/preview/resources/mgmt/2018-03-01-preview/management/operations.go new file mode 100644 index 000000000000..26c8dd75895a --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/operations.go @@ -0,0 +1,128 @@ +package managementgroups + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the the Azure Management Groups API enables consolidation of multiple subscriptions/resources +// into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those +// resources. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient() OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI)} +} + +// List lists all of the available Management REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Management/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/subscriptions.go b/services/preview/resources/mgmt/2018-03-01-preview/management/subscriptions.go new file mode 100644 index 000000000000..50a883ff3d4c --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/subscriptions.go @@ -0,0 +1,188 @@ +package managementgroups + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// SubscriptionsClient is the the Azure Management Groups API enables consolidation of multiple subscriptions/resources +// into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those +// resources. +type SubscriptionsClient struct { + BaseClient +} + +// NewSubscriptionsClient creates an instance of the SubscriptionsClient client. +func NewSubscriptionsClient() SubscriptionsClient { + return NewSubscriptionsClientWithBaseURI(DefaultBaseURI) +} + +// NewSubscriptionsClientWithBaseURI creates an instance of the SubscriptionsClient client. +func NewSubscriptionsClientWithBaseURI(baseURI string) SubscriptionsClient { + return SubscriptionsClient{NewWithBaseURI(baseURI)} +} + +// Create associates existing subscription with the management group. +// Parameters: +// groupID - management Group ID. +// subscriptionID - subscription ID. +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client SubscriptionsClient) Create(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (result autorest.Response, err error) { + req, err := client.CreatePreparer(ctx, groupID, subscriptionID, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SubscriptionsClient) CreatePreparer(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete de-associates subscription from the management group. +// Parameters: +// groupID - management Group ID. +// subscriptionID - subscription ID. +// cacheControl - indicates that the request shouldn't utilize any caches. +func (client SubscriptionsClient) Delete(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, groupID, subscriptionID, cacheControl) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SubscriptionsClient) DeletePreparer(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(cacheControl) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) + } else { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/resources/mgmt/2018-03-01-preview/management/version.go b/services/preview/resources/mgmt/2018-03-01-preview/management/version.go new file mode 100644 index 000000000000..1816eb81e6cf --- /dev/null +++ b/services/preview/resources/mgmt/2018-03-01-preview/management/version.go @@ -0,0 +1,30 @@ +package managementgroups + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " managementgroups/2018-03-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}