1package managementgroups
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/date"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"github.com/satori/go.uuid"
28	"net/http"
29)
30
31// The package's fully qualified name.
32const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2017-08-31-preview/managementgroups"
33
34// ChildType enumerates the values for child type.
35type ChildType string
36
37const (
38	// Account ...
39	Account ChildType = "Account"
40	// Department ...
41	Department ChildType = "Department"
42	// Enrollment ...
43	Enrollment ChildType = "Enrollment"
44	// Subscription ...
45	Subscription ChildType = "Subscription"
46)
47
48// PossibleChildTypeValues returns an array of possible values for the ChildType const type.
49func PossibleChildTypeValues() []ChildType {
50	return []ChildType{Account, Department, Enrollment, Subscription}
51}
52
53// ChildType1 enumerates the values for child type 1.
54type ChildType1 string
55
56const (
57	// ChildType1Account ...
58	ChildType1Account ChildType1 = "Account"
59	// ChildType1Department ...
60	ChildType1Department ChildType1 = "Department"
61	// ChildType1Enrollment ...
62	ChildType1Enrollment ChildType1 = "Enrollment"
63	// ChildType1Subscription ...
64	ChildType1Subscription ChildType1 = "Subscription"
65)
66
67// PossibleChildType1Values returns an array of possible values for the ChildType1 const type.
68func PossibleChildType1Values() []ChildType1 {
69	return []ChildType1{ChildType1Account, ChildType1Department, ChildType1Enrollment, ChildType1Subscription}
70}
71
72// ManagementGroupType enumerates the values for management group type.
73type ManagementGroupType string
74
75const (
76	// ManagementGroupTypeAccount ...
77	ManagementGroupTypeAccount ManagementGroupType = "Account"
78	// ManagementGroupTypeDepartment ...
79	ManagementGroupTypeDepartment ManagementGroupType = "Department"
80	// ManagementGroupTypeEnrollment ...
81	ManagementGroupTypeEnrollment ManagementGroupType = "Enrollment"
82	// ManagementGroupTypeSubscription ...
83	ManagementGroupTypeSubscription ManagementGroupType = "Subscription"
84)
85
86// PossibleManagementGroupTypeValues returns an array of possible values for the ManagementGroupType const type.
87func PossibleManagementGroupTypeValues() []ManagementGroupType {
88	return []ManagementGroupType{ManagementGroupTypeAccount, ManagementGroupTypeDepartment, ManagementGroupTypeEnrollment, ManagementGroupTypeSubscription}
89}
90
91// ChildInfo the unique identifier (ID) of a management group.
92type ChildInfo struct {
93	// ChildType - Possible values include: 'Enrollment', 'Department', 'Account', 'Subscription'
94	ChildType ChildType `json:"childType,omitempty"`
95	// ChildID - The ID of the child resource (management group or subscription). E.g. /providers/Microsoft.Management/managementGroups/40000000-0000-0000-0000-000000000000
96	ChildID *string `json:"childId,omitempty"`
97	// DisplayName - The friendly name of the child resource.
98	DisplayName *string `json:"displayName,omitempty"`
99	// TenantID - (Optional) The AAD Tenant ID associated with the child resource.
100	TenantID *uuid.UUID `json:"tenantId,omitempty"`
101}
102
103// DetailsProperties the details properties of a management group.
104type DetailsProperties struct {
105	// Version - The version number of the object.
106	Version *float64 `json:"version,omitempty"`
107	// UpdatedTime - The date and time when this object was last updated.
108	UpdatedTime *date.Time `json:"updatedTime,omitempty"`
109	// UpdatedBy - The identity of the principal or process that updated the object.
110	UpdatedBy *string          `json:"updatedBy,omitempty"`
111	Parent    *ParentGroupInfo `json:"parent,omitempty"`
112	// ManagementGroupType - Possible values include: 'ManagementGroupTypeEnrollment', 'ManagementGroupTypeDepartment', 'ManagementGroupTypeAccount', 'ManagementGroupTypeSubscription'
113	ManagementGroupType ManagementGroupType `json:"managementGroupType,omitempty"`
114}
115
116// ErrorDetails the details of the error.
117type ErrorDetails struct {
118	// Code - One of a server-defined set of error codes.
119	Code *string `json:"code,omitempty"`
120	// Message - A human-readable representation of the error.
121	Message *string `json:"message,omitempty"`
122	// Target - (Optional) The target of the error.
123	Target *string `json:"target,omitempty"`
124}
125
126// ErrorResponse the error object.
127type ErrorResponse struct {
128	Error *ErrorDetails `json:"error,omitempty"`
129}
130
131// Info the management group.
132type Info struct {
133	// ID - READ-ONLY; The ID of the management group. E.g. /providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000
134	ID *string `json:"id,omitempty"`
135	// Type - READ-ONLY; The type of the resource. E.g. /providers/Microsoft.Management/managementGroups
136	Type *string `json:"type,omitempty"`
137	// Name - READ-ONLY; The name of the management group. E.g. 20000000-0000-0000-0000-000000000000
138	Name            *uuid.UUID `json:"name,omitempty"`
139	*InfoProperties `json:"properties,omitempty"`
140}
141
142// MarshalJSON is the custom marshaler for Info.
143func (i Info) MarshalJSON() ([]byte, error) {
144	objectMap := make(map[string]interface{})
145	if i.InfoProperties != nil {
146		objectMap["properties"] = i.InfoProperties
147	}
148	return json.Marshal(objectMap)
149}
150
151// UnmarshalJSON is the custom unmarshaler for Info struct.
152func (i *Info) UnmarshalJSON(body []byte) error {
153	var m map[string]*json.RawMessage
154	err := json.Unmarshal(body, &m)
155	if err != nil {
156		return err
157	}
158	for k, v := range m {
159		switch k {
160		case "id":
161			if v != nil {
162				var ID string
163				err = json.Unmarshal(*v, &ID)
164				if err != nil {
165					return err
166				}
167				i.ID = &ID
168			}
169		case "type":
170			if v != nil {
171				var typeVar string
172				err = json.Unmarshal(*v, &typeVar)
173				if err != nil {
174					return err
175				}
176				i.Type = &typeVar
177			}
178		case "name":
179			if v != nil {
180				var name uuid.UUID
181				err = json.Unmarshal(*v, &name)
182				if err != nil {
183					return err
184				}
185				i.Name = &name
186			}
187		case "properties":
188			if v != nil {
189				var infoProperties InfoProperties
190				err = json.Unmarshal(*v, &infoProperties)
191				if err != nil {
192					return err
193				}
194				i.InfoProperties = &infoProperties
195			}
196		}
197	}
198
199	return nil
200}
201
202// InfoProperties the generic properties of a management group.
203type InfoProperties struct {
204	// TenantID - The AAD Tenant ID associated with the management group. E.g. 10000000-0000-0000-0000-000000000000
205	TenantID *uuid.UUID `json:"tenantId,omitempty"`
206	// DisplayName - The friendly name of the management group.
207	DisplayName *string `json:"displayName,omitempty"`
208}
209
210// ListResult the result of listing management groups.
211type ListResult struct {
212	autorest.Response `json:"-"`
213	// Value - The list of management groups.
214	Value *[]Info `json:"value,omitempty"`
215	// NextLink - READ-ONLY; The URL to the next page of results.
216	NextLink *string `json:"nextLink,omitempty"`
217}
218
219// ListResultIterator provides access to a complete listing of Info values.
220type ListResultIterator struct {
221	i    int
222	page ListResultPage
223}
224
225// NextWithContext advances to the next value.  If there was an error making
226// the request the iterator does not advance and the error is returned.
227func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
228	if tracing.IsEnabled() {
229		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
230		defer func() {
231			sc := -1
232			if iter.Response().Response.Response != nil {
233				sc = iter.Response().Response.Response.StatusCode
234			}
235			tracing.EndSpan(ctx, sc, err)
236		}()
237	}
238	iter.i++
239	if iter.i < len(iter.page.Values()) {
240		return nil
241	}
242	err = iter.page.NextWithContext(ctx)
243	if err != nil {
244		iter.i--
245		return err
246	}
247	iter.i = 0
248	return nil
249}
250
251// Next advances to the next value.  If there was an error making
252// the request the iterator does not advance and the error is returned.
253// Deprecated: Use NextWithContext() instead.
254func (iter *ListResultIterator) Next() error {
255	return iter.NextWithContext(context.Background())
256}
257
258// NotDone returns true if the enumeration should be started or is not yet complete.
259func (iter ListResultIterator) NotDone() bool {
260	return iter.page.NotDone() && iter.i < len(iter.page.Values())
261}
262
263// Response returns the raw server response from the last page request.
264func (iter ListResultIterator) Response() ListResult {
265	return iter.page.Response()
266}
267
268// Value returns the current value or a zero-initialized value if the
269// iterator has advanced beyond the end of the collection.
270func (iter ListResultIterator) Value() Info {
271	if !iter.page.NotDone() {
272		return Info{}
273	}
274	return iter.page.Values()[iter.i]
275}
276
277// Creates a new instance of the ListResultIterator type.
278func NewListResultIterator(page ListResultPage) ListResultIterator {
279	return ListResultIterator{page: page}
280}
281
282// IsEmpty returns true if the ListResult contains no values.
283func (lr ListResult) IsEmpty() bool {
284	return lr.Value == nil || len(*lr.Value) == 0
285}
286
287// listResultPreparer prepares a request to retrieve the next set of results.
288// It returns nil if no more results exist.
289func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
290	if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 {
291		return nil, nil
292	}
293	return autorest.Prepare((&http.Request{}).WithContext(ctx),
294		autorest.AsJSON(),
295		autorest.AsGet(),
296		autorest.WithBaseURL(to.String(lr.NextLink)))
297}
298
299// ListResultPage contains a page of Info values.
300type ListResultPage struct {
301	fn func(context.Context, ListResult) (ListResult, error)
302	lr ListResult
303}
304
305// NextWithContext advances to the next page of values.  If there was an error making
306// the request the page does not advance and the error is returned.
307func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
308	if tracing.IsEnabled() {
309		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
310		defer func() {
311			sc := -1
312			if page.Response().Response.Response != nil {
313				sc = page.Response().Response.Response.StatusCode
314			}
315			tracing.EndSpan(ctx, sc, err)
316		}()
317	}
318	next, err := page.fn(ctx, page.lr)
319	if err != nil {
320		return err
321	}
322	page.lr = next
323	return nil
324}
325
326// Next advances to the next page of values.  If there was an error making
327// the request the page does not advance and the error is returned.
328// Deprecated: Use NextWithContext() instead.
329func (page *ListResultPage) Next() error {
330	return page.NextWithContext(context.Background())
331}
332
333// NotDone returns true if the page enumeration should be started or is not yet complete.
334func (page ListResultPage) NotDone() bool {
335	return !page.lr.IsEmpty()
336}
337
338// Response returns the raw server response from the last page request.
339func (page ListResultPage) Response() ListResult {
340	return page.lr
341}
342
343// Values returns the slice of values for the current page or nil if there are no values.
344func (page ListResultPage) Values() []Info {
345	if page.lr.IsEmpty() {
346		return nil
347	}
348	return *page.lr.Value
349}
350
351// Creates a new instance of the ListResultPage type.
352func NewListResultPage(getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
353	return ListResultPage{fn: getNextPage}
354}
355
356// ManagementGroup the management group details.
357type ManagementGroup struct {
358	// ID - READ-ONLY; The ID of the management group. E.g. /providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000
359	ID *string `json:"id,omitempty"`
360	// Type - READ-ONLY; The type of the resource. E.g. /providers/Microsoft.Management/managementGroups
361	Type *string `json:"type,omitempty"`
362	// Name - READ-ONLY; The name of the management group. E.g. 20000000-0000-0000-0000-000000000000
363	Name        *uuid.UUID `json:"name,omitempty"`
364	*Properties `json:"properties,omitempty"`
365}
366
367// MarshalJSON is the custom marshaler for ManagementGroup.
368func (mg ManagementGroup) MarshalJSON() ([]byte, error) {
369	objectMap := make(map[string]interface{})
370	if mg.Properties != nil {
371		objectMap["properties"] = mg.Properties
372	}
373	return json.Marshal(objectMap)
374}
375
376// UnmarshalJSON is the custom unmarshaler for ManagementGroup struct.
377func (mg *ManagementGroup) UnmarshalJSON(body []byte) error {
378	var m map[string]*json.RawMessage
379	err := json.Unmarshal(body, &m)
380	if err != nil {
381		return err
382	}
383	for k, v := range m {
384		switch k {
385		case "id":
386			if v != nil {
387				var ID string
388				err = json.Unmarshal(*v, &ID)
389				if err != nil {
390					return err
391				}
392				mg.ID = &ID
393			}
394		case "type":
395			if v != nil {
396				var typeVar string
397				err = json.Unmarshal(*v, &typeVar)
398				if err != nil {
399					return err
400				}
401				mg.Type = &typeVar
402			}
403		case "name":
404			if v != nil {
405				var name uuid.UUID
406				err = json.Unmarshal(*v, &name)
407				if err != nil {
408					return err
409				}
410				mg.Name = &name
411			}
412		case "properties":
413			if v != nil {
414				var properties Properties
415				err = json.Unmarshal(*v, &properties)
416				if err != nil {
417					return err
418				}
419				mg.Properties = &properties
420			}
421		}
422	}
423
424	return nil
425}
426
427// Operation a Management REST API operation.
428type Operation struct {
429	// Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}.
430	Name *string `json:"name,omitempty"`
431	// Display - The object that represents the operation.
432	Display *OperationDisplay `json:"display,omitempty"`
433}
434
435// OperationDisplay the object that represents the operation.
436type OperationDisplay struct {
437	// Provider - READ-ONLY; Service provider: Microsoft.Management.
438	Provider *string `json:"provider,omitempty"`
439	// Resource - READ-ONLY; Resource on which the operation is performed: Invoice, etc.
440	Resource *string `json:"resource,omitempty"`
441	// Operation - READ-ONLY; Operation type: Read, write, delete, etc.
442	Operation *string `json:"operation,omitempty"`
443}
444
445// OperationListResult result listing  operations. It contains a list of operations and a URL link to get
446// the next set of results.
447type OperationListResult struct {
448	autorest.Response `json:"-"`
449	// Value - READ-ONLY; List of management operations supported by the Microsoft.Management resource provider.
450	Value *[]Operation `json:"value,omitempty"`
451	// NextLink - READ-ONLY; URL to get the next set of operation list results if there are any.
452	NextLink *string `json:"nextLink,omitempty"`
453}
454
455// OperationListResultIterator provides access to a complete listing of Operation values.
456type OperationListResultIterator struct {
457	i    int
458	page OperationListResultPage
459}
460
461// NextWithContext advances to the next value.  If there was an error making
462// the request the iterator does not advance and the error is returned.
463func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
464	if tracing.IsEnabled() {
465		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
466		defer func() {
467			sc := -1
468			if iter.Response().Response.Response != nil {
469				sc = iter.Response().Response.Response.StatusCode
470			}
471			tracing.EndSpan(ctx, sc, err)
472		}()
473	}
474	iter.i++
475	if iter.i < len(iter.page.Values()) {
476		return nil
477	}
478	err = iter.page.NextWithContext(ctx)
479	if err != nil {
480		iter.i--
481		return err
482	}
483	iter.i = 0
484	return nil
485}
486
487// Next advances to the next value.  If there was an error making
488// the request the iterator does not advance and the error is returned.
489// Deprecated: Use NextWithContext() instead.
490func (iter *OperationListResultIterator) Next() error {
491	return iter.NextWithContext(context.Background())
492}
493
494// NotDone returns true if the enumeration should be started or is not yet complete.
495func (iter OperationListResultIterator) NotDone() bool {
496	return iter.page.NotDone() && iter.i < len(iter.page.Values())
497}
498
499// Response returns the raw server response from the last page request.
500func (iter OperationListResultIterator) Response() OperationListResult {
501	return iter.page.Response()
502}
503
504// Value returns the current value or a zero-initialized value if the
505// iterator has advanced beyond the end of the collection.
506func (iter OperationListResultIterator) Value() Operation {
507	if !iter.page.NotDone() {
508		return Operation{}
509	}
510	return iter.page.Values()[iter.i]
511}
512
513// Creates a new instance of the OperationListResultIterator type.
514func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
515	return OperationListResultIterator{page: page}
516}
517
518// IsEmpty returns true if the ListResult contains no values.
519func (olr OperationListResult) IsEmpty() bool {
520	return olr.Value == nil || len(*olr.Value) == 0
521}
522
523// operationListResultPreparer prepares a request to retrieve the next set of results.
524// It returns nil if no more results exist.
525func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
526	if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 {
527		return nil, nil
528	}
529	return autorest.Prepare((&http.Request{}).WithContext(ctx),
530		autorest.AsJSON(),
531		autorest.AsGet(),
532		autorest.WithBaseURL(to.String(olr.NextLink)))
533}
534
535// OperationListResultPage contains a page of Operation values.
536type OperationListResultPage struct {
537	fn  func(context.Context, OperationListResult) (OperationListResult, error)
538	olr OperationListResult
539}
540
541// NextWithContext advances to the next page of values.  If there was an error making
542// the request the page does not advance and the error is returned.
543func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
544	if tracing.IsEnabled() {
545		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
546		defer func() {
547			sc := -1
548			if page.Response().Response.Response != nil {
549				sc = page.Response().Response.Response.StatusCode
550			}
551			tracing.EndSpan(ctx, sc, err)
552		}()
553	}
554	next, err := page.fn(ctx, page.olr)
555	if err != nil {
556		return err
557	}
558	page.olr = next
559	return nil
560}
561
562// Next advances to the next page of values.  If there was an error making
563// the request the page does not advance and the error is returned.
564// Deprecated: Use NextWithContext() instead.
565func (page *OperationListResultPage) Next() error {
566	return page.NextWithContext(context.Background())
567}
568
569// NotDone returns true if the page enumeration should be started or is not yet complete.
570func (page OperationListResultPage) NotDone() bool {
571	return !page.olr.IsEmpty()
572}
573
574// Response returns the raw server response from the last page request.
575func (page OperationListResultPage) Response() OperationListResult {
576	return page.olr
577}
578
579// Values returns the slice of values for the current page or nil if there are no values.
580func (page OperationListResultPage) Values() []Operation {
581	if page.olr.IsEmpty() {
582		return nil
583	}
584	return *page.olr.Value
585}
586
587// Creates a new instance of the OperationListResultPage type.
588func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
589	return OperationListResultPage{fn: getNextPage}
590}
591
592// ParentGroupInfo (Optional) The ID of the parent management group.
593type ParentGroupInfo struct {
594	// ParentID - The ID of the parent management group. E.g. /providers/Microsoft.Management/managementGroups/30000000-0000-0000-0000-000000000000
595	ParentID *string `json:"parentId,omitempty"`
596	// DisplayName - The friendly name of the management group.
597	DisplayName *string `json:"displayName,omitempty"`
598}
599
600// Properties the generic properties of a management group.
601type Properties struct {
602	// TenantID - The AAD Tenant ID associated with the management group. E.g. 10000000-0000-0000-0000-000000000000
603	TenantID *uuid.UUID `json:"tenantId,omitempty"`
604	// DisplayName - The friendly name of the management group.
605	DisplayName *string            `json:"displayName,omitempty"`
606	Details     *DetailsProperties `json:"details,omitempty"`
607}
608
609// PropertiesWithChildren the generic properties of a management group.
610type PropertiesWithChildren struct {
611	// TenantID - The AAD Tenant ID associated with the management group. E.g. 10000000-0000-0000-0000-000000000000
612	TenantID *uuid.UUID `json:"tenantId,omitempty"`
613	// DisplayName - The friendly name of the management group.
614	DisplayName *string            `json:"displayName,omitempty"`
615	Details     *DetailsProperties `json:"details,omitempty"`
616	// Children - The list of children.
617	Children *[]ChildInfo `json:"children,omitempty"`
618}
619
620// PropertiesWithHierarchy the generic properties of a management group.
621type PropertiesWithHierarchy struct {
622	// TenantID - The AAD Tenant ID associated with the management group. E.g. 10000000-0000-0000-0000-000000000000
623	TenantID *uuid.UUID `json:"tenantId,omitempty"`
624	// DisplayName - The friendly name of the management group.
625	DisplayName *string            `json:"displayName,omitempty"`
626	Details     *DetailsProperties `json:"details,omitempty"`
627	// Children - The list of children.
628	Children *[]RecursiveChildInfo `json:"children,omitempty"`
629}
630
631// RecursiveChildInfo the unique identifier (ID) of a management group.
632type RecursiveChildInfo struct {
633	// ChildType - Possible values include: 'ChildType1Enrollment', 'ChildType1Department', 'ChildType1Account', 'ChildType1Subscription'
634	ChildType ChildType1 `json:"childType,omitempty"`
635	// ChildID - The ID of the child resource (management group or subscription). E.g. /providers/Microsoft.Management/managementGroups/40000000-0000-0000-0000-000000000000
636	ChildID *string `json:"childId,omitempty"`
637	// DisplayName - The friendly name of the child resource.
638	DisplayName *string `json:"displayName,omitempty"`
639	// TenantID - (Optional) The AAD Tenant ID associated with the child resource.
640	TenantID *uuid.UUID `json:"tenantId,omitempty"`
641	// Children - The list of children.
642	Children *[]RecursiveChildInfo `json:"children,omitempty"`
643}
644
645// WithChildren the management group details.
646type WithChildren struct {
647	// ID - READ-ONLY; The ID of the management group. E.g. /providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000
648	ID *string `json:"id,omitempty"`
649	// Type - READ-ONLY; The type of the resource. E.g. /providers/Microsoft.Management/managementGroups
650	Type *string `json:"type,omitempty"`
651	// Name - READ-ONLY; The name of the management group. E.g. 20000000-0000-0000-0000-000000000000
652	Name                    *uuid.UUID `json:"name,omitempty"`
653	*PropertiesWithChildren `json:"properties,omitempty"`
654}
655
656// MarshalJSON is the custom marshaler for WithChildren.
657func (wc WithChildren) MarshalJSON() ([]byte, error) {
658	objectMap := make(map[string]interface{})
659	if wc.PropertiesWithChildren != nil {
660		objectMap["properties"] = wc.PropertiesWithChildren
661	}
662	return json.Marshal(objectMap)
663}
664
665// UnmarshalJSON is the custom unmarshaler for WithChildren struct.
666func (wc *WithChildren) UnmarshalJSON(body []byte) error {
667	var m map[string]*json.RawMessage
668	err := json.Unmarshal(body, &m)
669	if err != nil {
670		return err
671	}
672	for k, v := range m {
673		switch k {
674		case "id":
675			if v != nil {
676				var ID string
677				err = json.Unmarshal(*v, &ID)
678				if err != nil {
679					return err
680				}
681				wc.ID = &ID
682			}
683		case "type":
684			if v != nil {
685				var typeVar string
686				err = json.Unmarshal(*v, &typeVar)
687				if err != nil {
688					return err
689				}
690				wc.Type = &typeVar
691			}
692		case "name":
693			if v != nil {
694				var name uuid.UUID
695				err = json.Unmarshal(*v, &name)
696				if err != nil {
697					return err
698				}
699				wc.Name = &name
700			}
701		case "properties":
702			if v != nil {
703				var propertiesWithChildren PropertiesWithChildren
704				err = json.Unmarshal(*v, &propertiesWithChildren)
705				if err != nil {
706					return err
707				}
708				wc.PropertiesWithChildren = &propertiesWithChildren
709			}
710		}
711	}
712
713	return nil
714}
715
716// WithHierarchy the management group details.
717type WithHierarchy struct {
718	autorest.Response `json:"-"`
719	// ID - READ-ONLY; The ID of the management group. E.g. /providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000
720	ID *string `json:"id,omitempty"`
721	// Type - READ-ONLY; The type of the resource. E.g. /providers/Microsoft.Management/managementGroups
722	Type *string `json:"type,omitempty"`
723	// Name - READ-ONLY; The name of the management group. E.g. 20000000-0000-0000-0000-000000000000
724	Name                     *uuid.UUID `json:"name,omitempty"`
725	*PropertiesWithHierarchy `json:"properties,omitempty"`
726}
727
728// MarshalJSON is the custom marshaler for WithHierarchy.
729func (wh WithHierarchy) MarshalJSON() ([]byte, error) {
730	objectMap := make(map[string]interface{})
731	if wh.PropertiesWithHierarchy != nil {
732		objectMap["properties"] = wh.PropertiesWithHierarchy
733	}
734	return json.Marshal(objectMap)
735}
736
737// UnmarshalJSON is the custom unmarshaler for WithHierarchy struct.
738func (wh *WithHierarchy) UnmarshalJSON(body []byte) error {
739	var m map[string]*json.RawMessage
740	err := json.Unmarshal(body, &m)
741	if err != nil {
742		return err
743	}
744	for k, v := range m {
745		switch k {
746		case "id":
747			if v != nil {
748				var ID string
749				err = json.Unmarshal(*v, &ID)
750				if err != nil {
751					return err
752				}
753				wh.ID = &ID
754			}
755		case "type":
756			if v != nil {
757				var typeVar string
758				err = json.Unmarshal(*v, &typeVar)
759				if err != nil {
760					return err
761				}
762				wh.Type = &typeVar
763			}
764		case "name":
765			if v != nil {
766				var name uuid.UUID
767				err = json.Unmarshal(*v, &name)
768				if err != nil {
769					return err
770				}
771				wh.Name = &name
772			}
773		case "properties":
774			if v != nil {
775				var propertiesWithHierarchy PropertiesWithHierarchy
776				err = json.Unmarshal(*v, &propertiesWithHierarchy)
777				if err != nil {
778					return err
779				}
780				wh.PropertiesWithHierarchy = &propertiesWithHierarchy
781			}
782		}
783	}
784
785	return nil
786}
787