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