1package managementgroups
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"encoding/json"
12	"github.com/Azure/go-autorest/autorest"
13	"github.com/Azure/go-autorest/autorest/azure"
14	"github.com/Azure/go-autorest/autorest/date"
15	"github.com/Azure/go-autorest/autorest/to"
16	"github.com/Azure/go-autorest/tracing"
17	"net/http"
18)
19
20// The package's fully qualified name.
21const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-01-01-preview/managementgroups"
22
23// CheckNameAvailabilityRequest management group name availability check parameters.
24type CheckNameAvailabilityRequest struct {
25	// Name - the name to check for availability
26	Name *string `json:"name,omitempty"`
27	// Type - fully qualified resource type which includes provider namespace. Possible values include: 'ProvidersMicrosoftManagementmanagementGroups'
28	Type Type `json:"type,omitempty"`
29}
30
31// CheckNameAvailabilityResult describes the result of the request to check management group name
32// availability.
33type CheckNameAvailabilityResult struct {
34	autorest.Response `json:"-"`
35	// NameAvailable - READ-ONLY; Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both.
36	NameAvailable *bool `json:"nameAvailable,omitempty"`
37	// Reason - READ-ONLY; Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. Possible values include: 'Invalid', 'AlreadyExists'
38	Reason Reason `json:"reason,omitempty"`
39	// Message - READ-ONLY; Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason == AlreadyExists, explain that is already in use, and direct them to select a different name.
40	Message *string `json:"message,omitempty"`
41}
42
43// MarshalJSON is the custom marshaler for CheckNameAvailabilityResult.
44func (cnar CheckNameAvailabilityResult) MarshalJSON() ([]byte, error) {
45	objectMap := make(map[string]interface{})
46	return json.Marshal(objectMap)
47}
48
49// ChildInfo the child information of a management group.
50type ChildInfo struct {
51	// Type - The fully qualified resource type which includes provider namespace (e.g. /providers/Microsoft.Management/managementGroups). Possible values include: 'Type1ProvidersMicrosoftManagementmanagementGroups', 'Type1Subscriptions'
52	Type Type1 `json:"type,omitempty"`
53	// ID - The fully qualified ID for the child resource (management group or subscription).  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
54	ID *string `json:"id,omitempty"`
55	// Name - The name of the child entity.
56	Name *string `json:"name,omitempty"`
57	// DisplayName - The friendly name of the child resource.
58	DisplayName *string `json:"displayName,omitempty"`
59	// Roles - The roles definitions associated with the management group.
60	Roles *[]string `json:"roles,omitempty"`
61	// Children - The list of children.
62	Children *[]ChildInfo `json:"children,omitempty"`
63}
64
65// CreateManagementGroupChildInfo the child information of a management group used during creation.
66type CreateManagementGroupChildInfo struct {
67	// Type - READ-ONLY; The fully qualified resource type which includes provider namespace (e.g. /providers/Microsoft.Management/managementGroups). Possible values include: 'Type2ProvidersMicrosoftManagementmanagementGroups', 'Type2Subscriptions'
68	Type Type2 `json:"type,omitempty"`
69	// ID - READ-ONLY; The fully qualified ID for the child resource (management group or subscription).  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
70	ID *string `json:"id,omitempty"`
71	// Name - READ-ONLY; The name of the child entity.
72	Name *string `json:"name,omitempty"`
73	// DisplayName - READ-ONLY; The friendly name of the child resource.
74	DisplayName *string `json:"displayName,omitempty"`
75	// Roles - READ-ONLY; The roles definitions associated with the management group.
76	Roles *[]string `json:"roles,omitempty"`
77	// Children - READ-ONLY; The list of children.
78	Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"`
79}
80
81// MarshalJSON is the custom marshaler for CreateManagementGroupChildInfo.
82func (cmgci CreateManagementGroupChildInfo) MarshalJSON() ([]byte, error) {
83	objectMap := make(map[string]interface{})
84	return json.Marshal(objectMap)
85}
86
87// CreateManagementGroupDetails the details of a management group used during creation.
88type CreateManagementGroupDetails struct {
89	// Version - READ-ONLY; The version number of the object.
90	Version *float64 `json:"version,omitempty"`
91	// UpdatedTime - READ-ONLY; The date and time when this object was last updated.
92	UpdatedTime *date.Time `json:"updatedTime,omitempty"`
93	// UpdatedBy - READ-ONLY; The identity of the principal or process that updated the object.
94	UpdatedBy *string                `json:"updatedBy,omitempty"`
95	Parent    *CreateParentGroupInfo `json:"parent,omitempty"`
96}
97
98// MarshalJSON is the custom marshaler for CreateManagementGroupDetails.
99func (cmgd CreateManagementGroupDetails) MarshalJSON() ([]byte, error) {
100	objectMap := make(map[string]interface{})
101	if cmgd.Parent != nil {
102		objectMap["parent"] = cmgd.Parent
103	}
104	return json.Marshal(objectMap)
105}
106
107// CreateManagementGroupProperties the generic properties of a management group used during creation.
108type CreateManagementGroupProperties struct {
109	// TenantID - READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
110	TenantID *string `json:"tenantId,omitempty"`
111	// DisplayName - The friendly name of the management group. If no value is passed then this  field will be set to the groupId.
112	DisplayName *string `json:"displayName,omitempty"`
113	// Roles - READ-ONLY; The roles definitions associated with the management group.
114	Roles   *[]string                     `json:"roles,omitempty"`
115	Details *CreateManagementGroupDetails `json:"details,omitempty"`
116	// Children - READ-ONLY; The list of children.
117	Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"`
118}
119
120// MarshalJSON is the custom marshaler for CreateManagementGroupProperties.
121func (cmgp CreateManagementGroupProperties) MarshalJSON() ([]byte, error) {
122	objectMap := make(map[string]interface{})
123	if cmgp.DisplayName != nil {
124		objectMap["displayName"] = cmgp.DisplayName
125	}
126	if cmgp.Details != nil {
127		objectMap["details"] = cmgp.Details
128	}
129	return json.Marshal(objectMap)
130}
131
132// CreateManagementGroupRequest management group creation parameters.
133type CreateManagementGroupRequest struct {
134	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
135	ID *string `json:"id,omitempty"`
136	// Type - READ-ONLY; The type of the resource.  For example, /providers/Microsoft.Management/managementGroups
137	Type *string `json:"type,omitempty"`
138	// Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000
139	Name                             *string `json:"name,omitempty"`
140	*CreateManagementGroupProperties `json:"properties,omitempty"`
141}
142
143// MarshalJSON is the custom marshaler for CreateManagementGroupRequest.
144func (cmgr CreateManagementGroupRequest) MarshalJSON() ([]byte, error) {
145	objectMap := make(map[string]interface{})
146	if cmgr.Name != nil {
147		objectMap["name"] = cmgr.Name
148	}
149	if cmgr.CreateManagementGroupProperties != nil {
150		objectMap["properties"] = cmgr.CreateManagementGroupProperties
151	}
152	return json.Marshal(objectMap)
153}
154
155// UnmarshalJSON is the custom unmarshaler for CreateManagementGroupRequest struct.
156func (cmgr *CreateManagementGroupRequest) UnmarshalJSON(body []byte) error {
157	var m map[string]*json.RawMessage
158	err := json.Unmarshal(body, &m)
159	if err != nil {
160		return err
161	}
162	for k, v := range m {
163		switch k {
164		case "id":
165			if v != nil {
166				var ID string
167				err = json.Unmarshal(*v, &ID)
168				if err != nil {
169					return err
170				}
171				cmgr.ID = &ID
172			}
173		case "type":
174			if v != nil {
175				var typeVar string
176				err = json.Unmarshal(*v, &typeVar)
177				if err != nil {
178					return err
179				}
180				cmgr.Type = &typeVar
181			}
182		case "name":
183			if v != nil {
184				var name string
185				err = json.Unmarshal(*v, &name)
186				if err != nil {
187					return err
188				}
189				cmgr.Name = &name
190			}
191		case "properties":
192			if v != nil {
193				var createManagementGroupProperties CreateManagementGroupProperties
194				err = json.Unmarshal(*v, &createManagementGroupProperties)
195				if err != nil {
196					return err
197				}
198				cmgr.CreateManagementGroupProperties = &createManagementGroupProperties
199			}
200		}
201	}
202
203	return nil
204}
205
206// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
207// operation.
208type CreateOrUpdateFuture struct {
209	azure.FutureAPI
210	// Result returns the result of the asynchronous operation.
211	// If the operation has not completed it will return an error.
212	Result func(Client) (SetObject, error)
213}
214
215// UnmarshalJSON is the custom unmarshaller for CreateFuture.
216func (future *CreateOrUpdateFuture) UnmarshalJSON(body []byte) error {
217	var azFuture azure.Future
218	if err := json.Unmarshal(body, &azFuture); err != nil {
219		return err
220	}
221	future.FutureAPI = &azFuture
222	future.Result = future.result
223	return nil
224}
225
226// result is the default implementation for CreateOrUpdateFuture.Result.
227func (future *CreateOrUpdateFuture) result(client Client) (so SetObject, err error) {
228	var done bool
229	done, err = future.DoneWithContext(context.Background(), client)
230	if err != nil {
231		err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
232		return
233	}
234	if !done {
235		so.Response.Response = future.Response()
236		err = azure.NewAsyncOpIncompleteError("managementgroups.CreateOrUpdateFuture")
237		return
238	}
239	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
240	if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent {
241		so, err = client.CreateOrUpdateResponder(so.Response.Response)
242		if err != nil {
243			err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", so.Response.Response, "Failure responding to request")
244		}
245	}
246	return
247}
248
249// CreateParentGroupInfo (Optional) The ID of the parent management group used during creation.
250type CreateParentGroupInfo struct {
251	// ID - The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
252	ID *string `json:"id,omitempty"`
253	// Name - READ-ONLY; The name of the parent management group
254	Name *string `json:"name,omitempty"`
255	// DisplayName - READ-ONLY; The friendly name of the parent management group.
256	DisplayName *string `json:"displayName,omitempty"`
257}
258
259// MarshalJSON is the custom marshaler for CreateParentGroupInfo.
260func (cpgi CreateParentGroupInfo) MarshalJSON() ([]byte, error) {
261	objectMap := make(map[string]interface{})
262	if cpgi.ID != nil {
263		objectMap["id"] = cpgi.ID
264	}
265	return json.Marshal(objectMap)
266}
267
268// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
269type DeleteFuture struct {
270	azure.FutureAPI
271	// Result returns the result of the asynchronous operation.
272	// If the operation has not completed it will return an error.
273	Result func(Client) (OperationResults, error)
274}
275
276// UnmarshalJSON is the custom unmarshaller for CreateFuture.
277func (future *DeleteFuture) UnmarshalJSON(body []byte) error {
278	var azFuture azure.Future
279	if err := json.Unmarshal(body, &azFuture); err != nil {
280		return err
281	}
282	future.FutureAPI = &azFuture
283	future.Result = future.result
284	return nil
285}
286
287// result is the default implementation for DeleteFuture.Result.
288func (future *DeleteFuture) result(client Client) (or OperationResults, err error) {
289	var done bool
290	done, err = future.DoneWithContext(context.Background(), client)
291	if err != nil {
292		err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", future.Response(), "Polling failure")
293		return
294	}
295	if !done {
296		or.Response.Response = future.Response()
297		err = azure.NewAsyncOpIncompleteError("managementgroups.DeleteFuture")
298		return
299	}
300	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
301	if or.Response.Response, err = future.GetResult(sender); err == nil && or.Response.Response.StatusCode != http.StatusNoContent {
302		or, err = client.DeleteResponder(or.Response.Response)
303		if err != nil {
304			err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", or.Response.Response, "Failure responding to request")
305		}
306	}
307	return
308}
309
310// Details the details of a management group.
311type Details struct {
312	// Version - The version number of the object.
313	Version *float64 `json:"version,omitempty"`
314	// UpdatedTime - The date and time when this object was last updated.
315	UpdatedTime *date.Time `json:"updatedTime,omitempty"`
316	// UpdatedBy - The identity of the principal or process that updated the object.
317	UpdatedBy *string          `json:"updatedBy,omitempty"`
318	Parent    *ParentGroupInfo `json:"parent,omitempty"`
319}
320
321// EntityHierarchyItem the management group details for the hierarchy view.
322type EntityHierarchyItem struct {
323	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
324	ID *string `json:"id,omitempty"`
325	// Type - READ-ONLY; The type of the resource.  For example, /providers/Microsoft.Management/managementGroups
326	Type *string `json:"type,omitempty"`
327	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
328	Name                           *string `json:"name,omitempty"`
329	*EntityHierarchyItemProperties `json:"properties,omitempty"`
330}
331
332// MarshalJSON is the custom marshaler for EntityHierarchyItem.
333func (ehi EntityHierarchyItem) MarshalJSON() ([]byte, error) {
334	objectMap := make(map[string]interface{})
335	if ehi.EntityHierarchyItemProperties != nil {
336		objectMap["properties"] = ehi.EntityHierarchyItemProperties
337	}
338	return json.Marshal(objectMap)
339}
340
341// UnmarshalJSON is the custom unmarshaler for EntityHierarchyItem struct.
342func (ehi *EntityHierarchyItem) UnmarshalJSON(body []byte) error {
343	var m map[string]*json.RawMessage
344	err := json.Unmarshal(body, &m)
345	if err != nil {
346		return err
347	}
348	for k, v := range m {
349		switch k {
350		case "id":
351			if v != nil {
352				var ID string
353				err = json.Unmarshal(*v, &ID)
354				if err != nil {
355					return err
356				}
357				ehi.ID = &ID
358			}
359		case "type":
360			if v != nil {
361				var typeVar string
362				err = json.Unmarshal(*v, &typeVar)
363				if err != nil {
364					return err
365				}
366				ehi.Type = &typeVar
367			}
368		case "name":
369			if v != nil {
370				var name string
371				err = json.Unmarshal(*v, &name)
372				if err != nil {
373					return err
374				}
375				ehi.Name = &name
376			}
377		case "properties":
378			if v != nil {
379				var entityHierarchyItemProperties EntityHierarchyItemProperties
380				err = json.Unmarshal(*v, &entityHierarchyItemProperties)
381				if err != nil {
382					return err
383				}
384				ehi.EntityHierarchyItemProperties = &entityHierarchyItemProperties
385			}
386		}
387	}
388
389	return nil
390}
391
392// EntityHierarchyItemProperties the generic properties of a management group.
393type EntityHierarchyItemProperties struct {
394	// DisplayName - The friendly name of the management group.
395	DisplayName *string `json:"displayName,omitempty"`
396	// Permissions - Possible values include: 'Permissions1Noaccess', 'Permissions1View', 'Permissions1Edit', 'Permissions1Delete'
397	Permissions Permissions1 `json:"permissions,omitempty"`
398	// Children - The list of children.
399	Children *[]EntityHierarchyItem `json:"children,omitempty"`
400}
401
402// EntityInfo the entity.
403type EntityInfo struct {
404	// ID - READ-ONLY; The fully qualified ID for the entity.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
405	ID *string `json:"id,omitempty"`
406	// Type - READ-ONLY; The type of the resource. For example, /providers/Microsoft.Management/managementGroups
407	Type *string `json:"type,omitempty"`
408	// Name - READ-ONLY; The name of the entity. For example, 00000000-0000-0000-0000-000000000000
409	Name                  *string `json:"name,omitempty"`
410	*EntityInfoProperties `json:"properties,omitempty"`
411}
412
413// MarshalJSON is the custom marshaler for EntityInfo.
414func (ei EntityInfo) MarshalJSON() ([]byte, error) {
415	objectMap := make(map[string]interface{})
416	if ei.EntityInfoProperties != nil {
417		objectMap["properties"] = ei.EntityInfoProperties
418	}
419	return json.Marshal(objectMap)
420}
421
422// UnmarshalJSON is the custom unmarshaler for EntityInfo struct.
423func (ei *EntityInfo) UnmarshalJSON(body []byte) error {
424	var m map[string]*json.RawMessage
425	err := json.Unmarshal(body, &m)
426	if err != nil {
427		return err
428	}
429	for k, v := range m {
430		switch k {
431		case "id":
432			if v != nil {
433				var ID string
434				err = json.Unmarshal(*v, &ID)
435				if err != nil {
436					return err
437				}
438				ei.ID = &ID
439			}
440		case "type":
441			if v != nil {
442				var typeVar string
443				err = json.Unmarshal(*v, &typeVar)
444				if err != nil {
445					return err
446				}
447				ei.Type = &typeVar
448			}
449		case "name":
450			if v != nil {
451				var name string
452				err = json.Unmarshal(*v, &name)
453				if err != nil {
454					return err
455				}
456				ei.Name = &name
457			}
458		case "properties":
459			if v != nil {
460				var entityInfoProperties EntityInfoProperties
461				err = json.Unmarshal(*v, &entityInfoProperties)
462				if err != nil {
463					return err
464				}
465				ei.EntityInfoProperties = &entityInfoProperties
466			}
467		}
468	}
469
470	return nil
471}
472
473// EntityInfoProperties the generic properties of an entity.
474type EntityInfoProperties struct {
475	// TenantID - The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000
476	TenantID *string `json:"tenantId,omitempty"`
477	// DisplayName - The friendly name of the management group.
478	DisplayName *string                `json:"displayName,omitempty"`
479	Parent      *EntityParentGroupInfo `json:"parent,omitempty"`
480	// Permissions - Possible values include: 'Noaccess', 'View', 'Edit', 'Delete'
481	Permissions Permissions `json:"permissions,omitempty"`
482}
483
484// EntityListResult describes the result of the request to view entities.
485type EntityListResult struct {
486	autorest.Response `json:"-"`
487	// Value - The list of entities.
488	Value *[]EntityInfo `json:"value,omitempty"`
489	// NextLink - READ-ONLY; The URL to use for getting the next set of results.
490	NextLink *string `json:"nextLink,omitempty"`
491}
492
493// MarshalJSON is the custom marshaler for EntityListResult.
494func (elr EntityListResult) MarshalJSON() ([]byte, error) {
495	objectMap := make(map[string]interface{})
496	if elr.Value != nil {
497		objectMap["value"] = elr.Value
498	}
499	return json.Marshal(objectMap)
500}
501
502// EntityListResultIterator provides access to a complete listing of EntityInfo values.
503type EntityListResultIterator struct {
504	i    int
505	page EntityListResultPage
506}
507
508// NextWithContext advances to the next value.  If there was an error making
509// the request the iterator does not advance and the error is returned.
510func (iter *EntityListResultIterator) NextWithContext(ctx context.Context) (err error) {
511	if tracing.IsEnabled() {
512		ctx = tracing.StartSpan(ctx, fqdn+"/EntityListResultIterator.NextWithContext")
513		defer func() {
514			sc := -1
515			if iter.Response().Response.Response != nil {
516				sc = iter.Response().Response.Response.StatusCode
517			}
518			tracing.EndSpan(ctx, sc, err)
519		}()
520	}
521	iter.i++
522	if iter.i < len(iter.page.Values()) {
523		return nil
524	}
525	err = iter.page.NextWithContext(ctx)
526	if err != nil {
527		iter.i--
528		return err
529	}
530	iter.i = 0
531	return nil
532}
533
534// Next advances to the next value.  If there was an error making
535// the request the iterator does not advance and the error is returned.
536// Deprecated: Use NextWithContext() instead.
537func (iter *EntityListResultIterator) Next() error {
538	return iter.NextWithContext(context.Background())
539}
540
541// NotDone returns true if the enumeration should be started or is not yet complete.
542func (iter EntityListResultIterator) NotDone() bool {
543	return iter.page.NotDone() && iter.i < len(iter.page.Values())
544}
545
546// Response returns the raw server response from the last page request.
547func (iter EntityListResultIterator) Response() EntityListResult {
548	return iter.page.Response()
549}
550
551// Value returns the current value or a zero-initialized value if the
552// iterator has advanced beyond the end of the collection.
553func (iter EntityListResultIterator) Value() EntityInfo {
554	if !iter.page.NotDone() {
555		return EntityInfo{}
556	}
557	return iter.page.Values()[iter.i]
558}
559
560// Creates a new instance of the EntityListResultIterator type.
561func NewEntityListResultIterator(page EntityListResultPage) EntityListResultIterator {
562	return EntityListResultIterator{page: page}
563}
564
565// IsEmpty returns true if the ListResult contains no values.
566func (elr EntityListResult) IsEmpty() bool {
567	return elr.Value == nil || len(*elr.Value) == 0
568}
569
570// hasNextLink returns true if the NextLink is not empty.
571func (elr EntityListResult) hasNextLink() bool {
572	return elr.NextLink != nil && len(*elr.NextLink) != 0
573}
574
575// entityListResultPreparer prepares a request to retrieve the next set of results.
576// It returns nil if no more results exist.
577func (elr EntityListResult) entityListResultPreparer(ctx context.Context) (*http.Request, error) {
578	if !elr.hasNextLink() {
579		return nil, nil
580	}
581	return autorest.Prepare((&http.Request{}).WithContext(ctx),
582		autorest.AsJSON(),
583		autorest.AsGet(),
584		autorest.WithBaseURL(to.String(elr.NextLink)))
585}
586
587// EntityListResultPage contains a page of EntityInfo values.
588type EntityListResultPage struct {
589	fn  func(context.Context, EntityListResult) (EntityListResult, error)
590	elr EntityListResult
591}
592
593// NextWithContext advances to the next page of values.  If there was an error making
594// the request the page does not advance and the error is returned.
595func (page *EntityListResultPage) NextWithContext(ctx context.Context) (err error) {
596	if tracing.IsEnabled() {
597		ctx = tracing.StartSpan(ctx, fqdn+"/EntityListResultPage.NextWithContext")
598		defer func() {
599			sc := -1
600			if page.Response().Response.Response != nil {
601				sc = page.Response().Response.Response.StatusCode
602			}
603			tracing.EndSpan(ctx, sc, err)
604		}()
605	}
606	for {
607		next, err := page.fn(ctx, page.elr)
608		if err != nil {
609			return err
610		}
611		page.elr = next
612		if !next.hasNextLink() || !next.IsEmpty() {
613			break
614		}
615	}
616	return nil
617}
618
619// Next advances to the next page of values.  If there was an error making
620// the request the page does not advance and the error is returned.
621// Deprecated: Use NextWithContext() instead.
622func (page *EntityListResultPage) Next() error {
623	return page.NextWithContext(context.Background())
624}
625
626// NotDone returns true if the page enumeration should be started or is not yet complete.
627func (page EntityListResultPage) NotDone() bool {
628	return !page.elr.IsEmpty()
629}
630
631// Response returns the raw server response from the last page request.
632func (page EntityListResultPage) Response() EntityListResult {
633	return page.elr
634}
635
636// Values returns the slice of values for the current page or nil if there are no values.
637func (page EntityListResultPage) Values() []EntityInfo {
638	if page.elr.IsEmpty() {
639		return nil
640	}
641	return *page.elr.Value
642}
643
644// Creates a new instance of the EntityListResultPage type.
645func NewEntityListResultPage(cur EntityListResult, getNextPage func(context.Context, EntityListResult) (EntityListResult, error)) EntityListResultPage {
646	return EntityListResultPage{
647		fn:  getNextPage,
648		elr: cur,
649	}
650}
651
652// EntityParentGroupInfo (Optional) The ID of the parent management group.
653type EntityParentGroupInfo struct {
654	// ID - The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
655	ID *string `json:"id,omitempty"`
656}
657
658// ErrorDetails the details of the error.
659type ErrorDetails struct {
660	// Code - One of a server-defined set of error codes.
661	Code *string `json:"code,omitempty"`
662	// Message - A human-readable representation of the error.
663	Message *string `json:"message,omitempty"`
664	// Details - A human-readable representation of the error's details.
665	Details *string `json:"details,omitempty"`
666}
667
668// ErrorResponse the error object.
669type ErrorResponse struct {
670	Error *ErrorDetails `json:"error,omitempty"`
671}
672
673// Info the management group resource.
674type Info struct {
675	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
676	ID *string `json:"id,omitempty"`
677	// Type - READ-ONLY; The type of the resource. For example, /providers/Microsoft.Management/managementGroups
678	Type *string `json:"type,omitempty"`
679	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
680	Name            *string `json:"name,omitempty"`
681	*InfoProperties `json:"properties,omitempty"`
682}
683
684// MarshalJSON is the custom marshaler for Info.
685func (i Info) MarshalJSON() ([]byte, error) {
686	objectMap := make(map[string]interface{})
687	if i.InfoProperties != nil {
688		objectMap["properties"] = i.InfoProperties
689	}
690	return json.Marshal(objectMap)
691}
692
693// UnmarshalJSON is the custom unmarshaler for Info struct.
694func (i *Info) UnmarshalJSON(body []byte) error {
695	var m map[string]*json.RawMessage
696	err := json.Unmarshal(body, &m)
697	if err != nil {
698		return err
699	}
700	for k, v := range m {
701		switch k {
702		case "id":
703			if v != nil {
704				var ID string
705				err = json.Unmarshal(*v, &ID)
706				if err != nil {
707					return err
708				}
709				i.ID = &ID
710			}
711		case "type":
712			if v != nil {
713				var typeVar string
714				err = json.Unmarshal(*v, &typeVar)
715				if err != nil {
716					return err
717				}
718				i.Type = &typeVar
719			}
720		case "name":
721			if v != nil {
722				var name string
723				err = json.Unmarshal(*v, &name)
724				if err != nil {
725					return err
726				}
727				i.Name = &name
728			}
729		case "properties":
730			if v != nil {
731				var infoProperties InfoProperties
732				err = json.Unmarshal(*v, &infoProperties)
733				if err != nil {
734					return err
735				}
736				i.InfoProperties = &infoProperties
737			}
738		}
739	}
740
741	return nil
742}
743
744// InfoProperties the generic properties of a management group.
745type InfoProperties struct {
746	// TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
747	TenantID *string `json:"tenantId,omitempty"`
748	// DisplayName - The friendly name of the management group.
749	DisplayName *string `json:"displayName,omitempty"`
750}
751
752// ListResult describes the result of the request to list management groups.
753type ListResult struct {
754	autorest.Response `json:"-"`
755	// Value - The list of management groups.
756	Value *[]Info `json:"value,omitempty"`
757	// NextLink - READ-ONLY; The URL to use for getting the next set of results.
758	NextLink *string `json:"nextLink,omitempty"`
759}
760
761// MarshalJSON is the custom marshaler for ListResult.
762func (lr ListResult) MarshalJSON() ([]byte, error) {
763	objectMap := make(map[string]interface{})
764	if lr.Value != nil {
765		objectMap["value"] = lr.Value
766	}
767	return json.Marshal(objectMap)
768}
769
770// ListResultIterator provides access to a complete listing of Info values.
771type ListResultIterator struct {
772	i    int
773	page ListResultPage
774}
775
776// NextWithContext advances to the next value.  If there was an error making
777// the request the iterator does not advance and the error is returned.
778func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
779	if tracing.IsEnabled() {
780		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
781		defer func() {
782			sc := -1
783			if iter.Response().Response.Response != nil {
784				sc = iter.Response().Response.Response.StatusCode
785			}
786			tracing.EndSpan(ctx, sc, err)
787		}()
788	}
789	iter.i++
790	if iter.i < len(iter.page.Values()) {
791		return nil
792	}
793	err = iter.page.NextWithContext(ctx)
794	if err != nil {
795		iter.i--
796		return err
797	}
798	iter.i = 0
799	return nil
800}
801
802// Next advances to the next value.  If there was an error making
803// the request the iterator does not advance and the error is returned.
804// Deprecated: Use NextWithContext() instead.
805func (iter *ListResultIterator) Next() error {
806	return iter.NextWithContext(context.Background())
807}
808
809// NotDone returns true if the enumeration should be started or is not yet complete.
810func (iter ListResultIterator) NotDone() bool {
811	return iter.page.NotDone() && iter.i < len(iter.page.Values())
812}
813
814// Response returns the raw server response from the last page request.
815func (iter ListResultIterator) Response() ListResult {
816	return iter.page.Response()
817}
818
819// Value returns the current value or a zero-initialized value if the
820// iterator has advanced beyond the end of the collection.
821func (iter ListResultIterator) Value() Info {
822	if !iter.page.NotDone() {
823		return Info{}
824	}
825	return iter.page.Values()[iter.i]
826}
827
828// Creates a new instance of the ListResultIterator type.
829func NewListResultIterator(page ListResultPage) ListResultIterator {
830	return ListResultIterator{page: page}
831}
832
833// IsEmpty returns true if the ListResult contains no values.
834func (lr ListResult) IsEmpty() bool {
835	return lr.Value == nil || len(*lr.Value) == 0
836}
837
838// hasNextLink returns true if the NextLink is not empty.
839func (lr ListResult) hasNextLink() bool {
840	return lr.NextLink != nil && len(*lr.NextLink) != 0
841}
842
843// listResultPreparer prepares a request to retrieve the next set of results.
844// It returns nil if no more results exist.
845func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
846	if !lr.hasNextLink() {
847		return nil, nil
848	}
849	return autorest.Prepare((&http.Request{}).WithContext(ctx),
850		autorest.AsJSON(),
851		autorest.AsGet(),
852		autorest.WithBaseURL(to.String(lr.NextLink)))
853}
854
855// ListResultPage contains a page of Info values.
856type ListResultPage struct {
857	fn func(context.Context, ListResult) (ListResult, error)
858	lr ListResult
859}
860
861// NextWithContext advances to the next page of values.  If there was an error making
862// the request the page does not advance and the error is returned.
863func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
864	if tracing.IsEnabled() {
865		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
866		defer func() {
867			sc := -1
868			if page.Response().Response.Response != nil {
869				sc = page.Response().Response.Response.StatusCode
870			}
871			tracing.EndSpan(ctx, sc, err)
872		}()
873	}
874	for {
875		next, err := page.fn(ctx, page.lr)
876		if err != nil {
877			return err
878		}
879		page.lr = next
880		if !next.hasNextLink() || !next.IsEmpty() {
881			break
882		}
883	}
884	return nil
885}
886
887// Next advances to the next page of values.  If there was an error making
888// the request the page does not advance and the error is returned.
889// Deprecated: Use NextWithContext() instead.
890func (page *ListResultPage) Next() error {
891	return page.NextWithContext(context.Background())
892}
893
894// NotDone returns true if the page enumeration should be started or is not yet complete.
895func (page ListResultPage) NotDone() bool {
896	return !page.lr.IsEmpty()
897}
898
899// Response returns the raw server response from the last page request.
900func (page ListResultPage) Response() ListResult {
901	return page.lr
902}
903
904// Values returns the slice of values for the current page or nil if there are no values.
905func (page ListResultPage) Values() []Info {
906	if page.lr.IsEmpty() {
907		return nil
908	}
909	return *page.lr.Value
910}
911
912// Creates a new instance of the ListResultPage type.
913func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
914	return ListResultPage{
915		fn: getNextPage,
916		lr: cur,
917	}
918}
919
920// ManagementGroup the management group details.
921type ManagementGroup struct {
922	autorest.Response `json:"-"`
923	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
924	ID *string `json:"id,omitempty"`
925	// Type - READ-ONLY; The type of the resource.  For example, /providers/Microsoft.Management/managementGroups
926	Type *string `json:"type,omitempty"`
927	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
928	Name        *string `json:"name,omitempty"`
929	*Properties `json:"properties,omitempty"`
930}
931
932// MarshalJSON is the custom marshaler for ManagementGroup.
933func (mg ManagementGroup) MarshalJSON() ([]byte, error) {
934	objectMap := make(map[string]interface{})
935	if mg.Properties != nil {
936		objectMap["properties"] = mg.Properties
937	}
938	return json.Marshal(objectMap)
939}
940
941// UnmarshalJSON is the custom unmarshaler for ManagementGroup struct.
942func (mg *ManagementGroup) UnmarshalJSON(body []byte) error {
943	var m map[string]*json.RawMessage
944	err := json.Unmarshal(body, &m)
945	if err != nil {
946		return err
947	}
948	for k, v := range m {
949		switch k {
950		case "id":
951			if v != nil {
952				var ID string
953				err = json.Unmarshal(*v, &ID)
954				if err != nil {
955					return err
956				}
957				mg.ID = &ID
958			}
959		case "type":
960			if v != nil {
961				var typeVar string
962				err = json.Unmarshal(*v, &typeVar)
963				if err != nil {
964					return err
965				}
966				mg.Type = &typeVar
967			}
968		case "name":
969			if v != nil {
970				var name string
971				err = json.Unmarshal(*v, &name)
972				if err != nil {
973					return err
974				}
975				mg.Name = &name
976			}
977		case "properties":
978			if v != nil {
979				var properties Properties
980				err = json.Unmarshal(*v, &properties)
981				if err != nil {
982					return err
983				}
984				mg.Properties = &properties
985			}
986		}
987	}
988
989	return nil
990}
991
992// Operation operation supported by the Microsoft.Management resource provider.
993type Operation struct {
994	// Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}.
995	Name    *string                     `json:"name,omitempty"`
996	Display *OperationDisplayProperties `json:"display,omitempty"`
997}
998
999// MarshalJSON is the custom marshaler for Operation.
1000func (o Operation) MarshalJSON() ([]byte, error) {
1001	objectMap := make(map[string]interface{})
1002	if o.Display != nil {
1003		objectMap["display"] = o.Display
1004	}
1005	return json.Marshal(objectMap)
1006}
1007
1008// OperationDisplayProperties the object that represents the operation.
1009type OperationDisplayProperties struct {
1010	// Provider - READ-ONLY; The name of the provider.
1011	Provider *string `json:"provider,omitempty"`
1012	// Resource - READ-ONLY; The resource on which the operation is performed.
1013	Resource *string `json:"resource,omitempty"`
1014	// Operation - READ-ONLY; The operation that can be performed.
1015	Operation *string `json:"operation,omitempty"`
1016	// Description - READ-ONLY; Operation description.
1017	Description *string `json:"description,omitempty"`
1018}
1019
1020// MarshalJSON is the custom marshaler for OperationDisplayProperties.
1021func (odp OperationDisplayProperties) MarshalJSON() ([]byte, error) {
1022	objectMap := make(map[string]interface{})
1023	return json.Marshal(objectMap)
1024}
1025
1026// OperationListResult describes the result of the request to list Microsoft.Management operations.
1027type OperationListResult struct {
1028	autorest.Response `json:"-"`
1029	// Value - READ-ONLY; List of operations supported by the Microsoft.Management resource provider.
1030	Value *[]Operation `json:"value,omitempty"`
1031	// NextLink - READ-ONLY; URL to get the next set of operation list results if there are any.
1032	NextLink *string `json:"nextLink,omitempty"`
1033}
1034
1035// MarshalJSON is the custom marshaler for OperationListResult.
1036func (olr OperationListResult) MarshalJSON() ([]byte, error) {
1037	objectMap := make(map[string]interface{})
1038	return json.Marshal(objectMap)
1039}
1040
1041// OperationListResultIterator provides access to a complete listing of Operation values.
1042type OperationListResultIterator struct {
1043	i    int
1044	page OperationListResultPage
1045}
1046
1047// NextWithContext advances to the next value.  If there was an error making
1048// the request the iterator does not advance and the error is returned.
1049func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
1050	if tracing.IsEnabled() {
1051		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
1052		defer func() {
1053			sc := -1
1054			if iter.Response().Response.Response != nil {
1055				sc = iter.Response().Response.Response.StatusCode
1056			}
1057			tracing.EndSpan(ctx, sc, err)
1058		}()
1059	}
1060	iter.i++
1061	if iter.i < len(iter.page.Values()) {
1062		return nil
1063	}
1064	err = iter.page.NextWithContext(ctx)
1065	if err != nil {
1066		iter.i--
1067		return err
1068	}
1069	iter.i = 0
1070	return nil
1071}
1072
1073// Next advances to the next value.  If there was an error making
1074// the request the iterator does not advance and the error is returned.
1075// Deprecated: Use NextWithContext() instead.
1076func (iter *OperationListResultIterator) Next() error {
1077	return iter.NextWithContext(context.Background())
1078}
1079
1080// NotDone returns true if the enumeration should be started or is not yet complete.
1081func (iter OperationListResultIterator) NotDone() bool {
1082	return iter.page.NotDone() && iter.i < len(iter.page.Values())
1083}
1084
1085// Response returns the raw server response from the last page request.
1086func (iter OperationListResultIterator) Response() OperationListResult {
1087	return iter.page.Response()
1088}
1089
1090// Value returns the current value or a zero-initialized value if the
1091// iterator has advanced beyond the end of the collection.
1092func (iter OperationListResultIterator) Value() Operation {
1093	if !iter.page.NotDone() {
1094		return Operation{}
1095	}
1096	return iter.page.Values()[iter.i]
1097}
1098
1099// Creates a new instance of the OperationListResultIterator type.
1100func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
1101	return OperationListResultIterator{page: page}
1102}
1103
1104// IsEmpty returns true if the ListResult contains no values.
1105func (olr OperationListResult) IsEmpty() bool {
1106	return olr.Value == nil || len(*olr.Value) == 0
1107}
1108
1109// hasNextLink returns true if the NextLink is not empty.
1110func (olr OperationListResult) hasNextLink() bool {
1111	return olr.NextLink != nil && len(*olr.NextLink) != 0
1112}
1113
1114// operationListResultPreparer prepares a request to retrieve the next set of results.
1115// It returns nil if no more results exist.
1116func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
1117	if !olr.hasNextLink() {
1118		return nil, nil
1119	}
1120	return autorest.Prepare((&http.Request{}).WithContext(ctx),
1121		autorest.AsJSON(),
1122		autorest.AsGet(),
1123		autorest.WithBaseURL(to.String(olr.NextLink)))
1124}
1125
1126// OperationListResultPage contains a page of Operation values.
1127type OperationListResultPage struct {
1128	fn  func(context.Context, OperationListResult) (OperationListResult, error)
1129	olr OperationListResult
1130}
1131
1132// NextWithContext advances to the next page of values.  If there was an error making
1133// the request the page does not advance and the error is returned.
1134func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
1135	if tracing.IsEnabled() {
1136		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
1137		defer func() {
1138			sc := -1
1139			if page.Response().Response.Response != nil {
1140				sc = page.Response().Response.Response.StatusCode
1141			}
1142			tracing.EndSpan(ctx, sc, err)
1143		}()
1144	}
1145	for {
1146		next, err := page.fn(ctx, page.olr)
1147		if err != nil {
1148			return err
1149		}
1150		page.olr = next
1151		if !next.hasNextLink() || !next.IsEmpty() {
1152			break
1153		}
1154	}
1155	return nil
1156}
1157
1158// Next advances to the next page of values.  If there was an error making
1159// the request the page does not advance and the error is returned.
1160// Deprecated: Use NextWithContext() instead.
1161func (page *OperationListResultPage) Next() error {
1162	return page.NextWithContext(context.Background())
1163}
1164
1165// NotDone returns true if the page enumeration should be started or is not yet complete.
1166func (page OperationListResultPage) NotDone() bool {
1167	return !page.olr.IsEmpty()
1168}
1169
1170// Response returns the raw server response from the last page request.
1171func (page OperationListResultPage) Response() OperationListResult {
1172	return page.olr
1173}
1174
1175// Values returns the slice of values for the current page or nil if there are no values.
1176func (page OperationListResultPage) Values() []Operation {
1177	if page.olr.IsEmpty() {
1178		return nil
1179	}
1180	return *page.olr.Value
1181}
1182
1183// Creates a new instance of the OperationListResultPage type.
1184func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
1185	return OperationListResultPage{
1186		fn:  getNextPage,
1187		olr: cur,
1188	}
1189}
1190
1191// OperationResults the results of an asynchronous operation.
1192type OperationResults struct {
1193	autorest.Response `json:"-"`
1194	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
1195	ID *string `json:"id,omitempty"`
1196	// Type - READ-ONLY; The type of the resource.  For example, /providers/Microsoft.Management/managementGroups
1197	Type *string `json:"type,omitempty"`
1198	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
1199	Name                        *string `json:"name,omitempty"`
1200	*OperationResultsProperties `json:"properties,omitempty"`
1201}
1202
1203// MarshalJSON is the custom marshaler for OperationResults.
1204func (or OperationResults) MarshalJSON() ([]byte, error) {
1205	objectMap := make(map[string]interface{})
1206	if or.OperationResultsProperties != nil {
1207		objectMap["properties"] = or.OperationResultsProperties
1208	}
1209	return json.Marshal(objectMap)
1210}
1211
1212// UnmarshalJSON is the custom unmarshaler for OperationResults struct.
1213func (or *OperationResults) UnmarshalJSON(body []byte) error {
1214	var m map[string]*json.RawMessage
1215	err := json.Unmarshal(body, &m)
1216	if err != nil {
1217		return err
1218	}
1219	for k, v := range m {
1220		switch k {
1221		case "id":
1222			if v != nil {
1223				var ID string
1224				err = json.Unmarshal(*v, &ID)
1225				if err != nil {
1226					return err
1227				}
1228				or.ID = &ID
1229			}
1230		case "type":
1231			if v != nil {
1232				var typeVar string
1233				err = json.Unmarshal(*v, &typeVar)
1234				if err != nil {
1235					return err
1236				}
1237				or.Type = &typeVar
1238			}
1239		case "name":
1240			if v != nil {
1241				var name string
1242				err = json.Unmarshal(*v, &name)
1243				if err != nil {
1244					return err
1245				}
1246				or.Name = &name
1247			}
1248		case "properties":
1249			if v != nil {
1250				var operationResultsProperties OperationResultsProperties
1251				err = json.Unmarshal(*v, &operationResultsProperties)
1252				if err != nil {
1253					return err
1254				}
1255				or.OperationResultsProperties = &operationResultsProperties
1256			}
1257		}
1258	}
1259
1260	return nil
1261}
1262
1263// OperationResultsProperties ...
1264type OperationResultsProperties struct {
1265	// ProvisioningState - Possible values include: 'Updating'
1266	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
1267}
1268
1269// ParentGroupInfo (Optional) The ID of the parent management group.
1270type ParentGroupInfo struct {
1271	// ID - The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
1272	ID *string `json:"id,omitempty"`
1273	// Name - The name of the parent management group
1274	Name *string `json:"name,omitempty"`
1275	// DisplayName - The friendly name of the parent management group.
1276	DisplayName *string `json:"displayName,omitempty"`
1277}
1278
1279// PatchManagementGroupRequest management group patch parameters.
1280type PatchManagementGroupRequest struct {
1281	// DisplayName - The friendly name of the management group.
1282	DisplayName *string `json:"displayName,omitempty"`
1283	// ParentID - (Optional) The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
1284	ParentID *string `json:"parentId,omitempty"`
1285}
1286
1287// Properties the generic properties of a management group.
1288type Properties struct {
1289	// TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
1290	TenantID *string `json:"tenantId,omitempty"`
1291	// DisplayName - The friendly name of the management group.
1292	DisplayName *string `json:"displayName,omitempty"`
1293	// Roles - The role definitions associated with the management group.
1294	Roles   *[]string `json:"roles,omitempty"`
1295	Details *Details  `json:"details,omitempty"`
1296	// Children - The list of children.
1297	Children *[]ChildInfo `json:"children,omitempty"`
1298}
1299
1300// SetObject ...
1301type SetObject struct {
1302	autorest.Response `json:"-"`
1303	Value             interface{} `json:"value,omitempty"`
1304}
1305