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