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 "encoding/json" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/date" 24 "github.com/Azure/go-autorest/autorest/to" 25 "net/http" 26) 27 28// ChildType enumerates the values for child type. 29type ChildType string 30 31const ( 32 // ChildTypeManagementGroup ... 33 ChildTypeManagementGroup ChildType = "ManagementGroup" 34 // ChildTypeSubscription ... 35 ChildTypeSubscription ChildType = "Subscription" 36) 37 38// PossibleChildTypeValues returns an array of possible values for the ChildType const type. 39func PossibleChildTypeValues() []ChildType { 40 return []ChildType{ChildTypeManagementGroup, ChildTypeSubscription} 41} 42 43// ChildInfo the child information of a management group. 44type ChildInfo struct { 45 // ChildType - Possible values include: 'ChildTypeManagementGroup', 'ChildTypeSubscription' 46 ChildType ChildType `json:"childType,omitempty"` 47 // ChildID - The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 48 ChildID *string `json:"childId,omitempty"` 49 // DisplayName - The friendly name of the child resource. 50 DisplayName *string `json:"displayName,omitempty"` 51 // Children - The list of children. 52 Children *[]ChildInfo `json:"children,omitempty"` 53} 54 55// CreateManagementGroupRequest management group creation parameters. 56type CreateManagementGroupRequest struct { 57 // DisplayName - The friendly name of the management group. 58 DisplayName *string `json:"displayName,omitempty"` 59 // ParentID - (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 60 ParentID *string `json:"parentId,omitempty"` 61} 62 63// Details the details of a management group. 64type Details struct { 65 // Version - The version number of the object. 66 Version *float64 `json:"version,omitempty"` 67 // UpdatedTime - The date and time when this object was last updated. 68 UpdatedTime *date.Time `json:"updatedTime,omitempty"` 69 // UpdatedBy - The identity of the principal or process that updated the object. 70 UpdatedBy *string `json:"updatedBy,omitempty"` 71 Parent *ParentGroupInfo `json:"parent,omitempty"` 72} 73 74// ErrorDetails the details of the error. 75type ErrorDetails struct { 76 // Code - One of a server-defined set of error codes. 77 Code *string `json:"code,omitempty"` 78 // Message - A human-readable representation of the error. 79 Message *string `json:"message,omitempty"` 80} 81 82// ErrorResponse the error object. 83type ErrorResponse struct { 84 Error *ErrorDetails `json:"error,omitempty"` 85} 86 87// Info the management group resource. 88type Info struct { 89 // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 90 ID *string `json:"id,omitempty"` 91 // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups 92 Type *string `json:"type,omitempty"` 93 // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 94 Name *string `json:"name,omitempty"` 95 *InfoProperties `json:"properties,omitempty"` 96} 97 98// MarshalJSON is the custom marshaler for Info. 99func (i Info) MarshalJSON() ([]byte, error) { 100 objectMap := make(map[string]interface{}) 101 if i.ID != nil { 102 objectMap["id"] = i.ID 103 } 104 if i.Type != nil { 105 objectMap["type"] = i.Type 106 } 107 if i.Name != nil { 108 objectMap["name"] = i.Name 109 } 110 if i.InfoProperties != nil { 111 objectMap["properties"] = i.InfoProperties 112 } 113 return json.Marshal(objectMap) 114} 115 116// UnmarshalJSON is the custom unmarshaler for Info struct. 117func (i *Info) UnmarshalJSON(body []byte) error { 118 var m map[string]*json.RawMessage 119 err := json.Unmarshal(body, &m) 120 if err != nil { 121 return err 122 } 123 for k, v := range m { 124 switch k { 125 case "id": 126 if v != nil { 127 var ID string 128 err = json.Unmarshal(*v, &ID) 129 if err != nil { 130 return err 131 } 132 i.ID = &ID 133 } 134 case "type": 135 if v != nil { 136 var typeVar string 137 err = json.Unmarshal(*v, &typeVar) 138 if err != nil { 139 return err 140 } 141 i.Type = &typeVar 142 } 143 case "name": 144 if v != nil { 145 var name string 146 err = json.Unmarshal(*v, &name) 147 if err != nil { 148 return err 149 } 150 i.Name = &name 151 } 152 case "properties": 153 if v != nil { 154 var infoProperties InfoProperties 155 err = json.Unmarshal(*v, &infoProperties) 156 if err != nil { 157 return err 158 } 159 i.InfoProperties = &infoProperties 160 } 161 } 162 } 163 164 return nil 165} 166 167// InfoProperties the generic properties of a management group. 168type InfoProperties struct { 169 // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 170 TenantID *string `json:"tenantId,omitempty"` 171 // DisplayName - The friendly name of the management group. 172 DisplayName *string `json:"displayName,omitempty"` 173} 174 175// ListResult describes the result of the request to list management groups. 176type ListResult struct { 177 autorest.Response `json:"-"` 178 // Value - The list of management groups. 179 Value *[]Info `json:"value,omitempty"` 180 // NextLink - The URL to use for getting the next set of results. 181 NextLink *string `json:"nextLink,omitempty"` 182} 183 184// ListResultIterator provides access to a complete listing of Info values. 185type ListResultIterator struct { 186 i int 187 page ListResultPage 188} 189 190// Next advances to the next value. If there was an error making 191// the request the iterator does not advance and the error is returned. 192func (iter *ListResultIterator) Next() error { 193 iter.i++ 194 if iter.i < len(iter.page.Values()) { 195 return nil 196 } 197 err := iter.page.Next() 198 if err != nil { 199 iter.i-- 200 return err 201 } 202 iter.i = 0 203 return nil 204} 205 206// NotDone returns true if the enumeration should be started or is not yet complete. 207func (iter ListResultIterator) NotDone() bool { 208 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 209} 210 211// Response returns the raw server response from the last page request. 212func (iter ListResultIterator) Response() ListResult { 213 return iter.page.Response() 214} 215 216// Value returns the current value or a zero-initialized value if the 217// iterator has advanced beyond the end of the collection. 218func (iter ListResultIterator) Value() Info { 219 if !iter.page.NotDone() { 220 return Info{} 221 } 222 return iter.page.Values()[iter.i] 223} 224 225// IsEmpty returns true if the ListResult contains no values. 226func (lr ListResult) IsEmpty() bool { 227 return lr.Value == nil || len(*lr.Value) == 0 228} 229 230// listResultPreparer prepares a request to retrieve the next set of results. 231// It returns nil if no more results exist. 232func (lr ListResult) listResultPreparer() (*http.Request, error) { 233 if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { 234 return nil, nil 235 } 236 return autorest.Prepare(&http.Request{}, 237 autorest.AsJSON(), 238 autorest.AsGet(), 239 autorest.WithBaseURL(to.String(lr.NextLink))) 240} 241 242// ListResultPage contains a page of Info values. 243type ListResultPage struct { 244 fn func(ListResult) (ListResult, error) 245 lr ListResult 246} 247 248// Next advances to the next page of values. If there was an error making 249// the request the page does not advance and the error is returned. 250func (page *ListResultPage) Next() error { 251 next, err := page.fn(page.lr) 252 if err != nil { 253 return err 254 } 255 page.lr = next 256 return nil 257} 258 259// NotDone returns true if the page enumeration should be started or is not yet complete. 260func (page ListResultPage) NotDone() bool { 261 return !page.lr.IsEmpty() 262} 263 264// Response returns the raw server response from the last page request. 265func (page ListResultPage) Response() ListResult { 266 return page.lr 267} 268 269// Values returns the slice of values for the current page or nil if there are no values. 270func (page ListResultPage) Values() []Info { 271 if page.lr.IsEmpty() { 272 return nil 273 } 274 return *page.lr.Value 275} 276 277// ManagementGroup the management group details. 278type ManagementGroup struct { 279 autorest.Response `json:"-"` 280 // ID - The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 281 ID *string `json:"id,omitempty"` 282 // Type - The type of the resource. For example, /providers/Microsoft.Management/managementGroups 283 Type *string `json:"type,omitempty"` 284 // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 285 Name *string `json:"name,omitempty"` 286 *Properties `json:"properties,omitempty"` 287} 288 289// MarshalJSON is the custom marshaler for ManagementGroup. 290func (mg ManagementGroup) MarshalJSON() ([]byte, error) { 291 objectMap := make(map[string]interface{}) 292 if mg.ID != nil { 293 objectMap["id"] = mg.ID 294 } 295 if mg.Type != nil { 296 objectMap["type"] = mg.Type 297 } 298 if mg.Name != nil { 299 objectMap["name"] = mg.Name 300 } 301 if mg.Properties != nil { 302 objectMap["properties"] = mg.Properties 303 } 304 return json.Marshal(objectMap) 305} 306 307// UnmarshalJSON is the custom unmarshaler for ManagementGroup struct. 308func (mg *ManagementGroup) UnmarshalJSON(body []byte) error { 309 var m map[string]*json.RawMessage 310 err := json.Unmarshal(body, &m) 311 if err != nil { 312 return err 313 } 314 for k, v := range m { 315 switch k { 316 case "id": 317 if v != nil { 318 var ID string 319 err = json.Unmarshal(*v, &ID) 320 if err != nil { 321 return err 322 } 323 mg.ID = &ID 324 } 325 case "type": 326 if v != nil { 327 var typeVar string 328 err = json.Unmarshal(*v, &typeVar) 329 if err != nil { 330 return err 331 } 332 mg.Type = &typeVar 333 } 334 case "name": 335 if v != nil { 336 var name string 337 err = json.Unmarshal(*v, &name) 338 if err != nil { 339 return err 340 } 341 mg.Name = &name 342 } 343 case "properties": 344 if v != nil { 345 var properties Properties 346 err = json.Unmarshal(*v, &properties) 347 if err != nil { 348 return err 349 } 350 mg.Properties = &properties 351 } 352 } 353 } 354 355 return nil 356} 357 358// Operation operation supported by the Microsoft.Management resource provider. 359type Operation struct { 360 // Name - Operation name: {provider}/{resource}/{operation}. 361 Name *string `json:"name,omitempty"` 362 // Display - The object that represents the operation. 363 Display *OperationDisplay `json:"display,omitempty"` 364} 365 366// OperationDisplay the object that represents the operation. 367type OperationDisplay struct { 368 // Provider - The name of the provider. 369 Provider *string `json:"provider,omitempty"` 370 // Resource - The resource on which the operation is performed. 371 Resource *string `json:"resource,omitempty"` 372 // Operation - The operation that can be performed. 373 Operation *string `json:"operation,omitempty"` 374 // Description - Operation description. 375 Description *string `json:"description,omitempty"` 376} 377 378// OperationListResult describes the result of the request to list Microsoft.Management operations. 379type OperationListResult struct { 380 autorest.Response `json:"-"` 381 // Value - List of operations supported by the Microsoft.Management resource provider. 382 Value *[]Operation `json:"value,omitempty"` 383 // NextLink - URL to get the next set of operation list results if there are any. 384 NextLink *string `json:"nextLink,omitempty"` 385} 386 387// OperationListResultIterator provides access to a complete listing of Operation values. 388type OperationListResultIterator struct { 389 i int 390 page OperationListResultPage 391} 392 393// Next advances to the next value. If there was an error making 394// the request the iterator does not advance and the error is returned. 395func (iter *OperationListResultIterator) Next() error { 396 iter.i++ 397 if iter.i < len(iter.page.Values()) { 398 return nil 399 } 400 err := iter.page.Next() 401 if err != nil { 402 iter.i-- 403 return err 404 } 405 iter.i = 0 406 return nil 407} 408 409// NotDone returns true if the enumeration should be started or is not yet complete. 410func (iter OperationListResultIterator) NotDone() bool { 411 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 412} 413 414// Response returns the raw server response from the last page request. 415func (iter OperationListResultIterator) Response() OperationListResult { 416 return iter.page.Response() 417} 418 419// Value returns the current value or a zero-initialized value if the 420// iterator has advanced beyond the end of the collection. 421func (iter OperationListResultIterator) Value() Operation { 422 if !iter.page.NotDone() { 423 return Operation{} 424 } 425 return iter.page.Values()[iter.i] 426} 427 428// IsEmpty returns true if the ListResult contains no values. 429func (olr OperationListResult) IsEmpty() bool { 430 return olr.Value == nil || len(*olr.Value) == 0 431} 432 433// operationListResultPreparer prepares a request to retrieve the next set of results. 434// It returns nil if no more results exist. 435func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { 436 if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { 437 return nil, nil 438 } 439 return autorest.Prepare(&http.Request{}, 440 autorest.AsJSON(), 441 autorest.AsGet(), 442 autorest.WithBaseURL(to.String(olr.NextLink))) 443} 444 445// OperationListResultPage contains a page of Operation values. 446type OperationListResultPage struct { 447 fn func(OperationListResult) (OperationListResult, error) 448 olr OperationListResult 449} 450 451// Next advances to the next page of values. If there was an error making 452// the request the page does not advance and the error is returned. 453func (page *OperationListResultPage) Next() error { 454 next, err := page.fn(page.olr) 455 if err != nil { 456 return err 457 } 458 page.olr = next 459 return nil 460} 461 462// NotDone returns true if the page enumeration should be started or is not yet complete. 463func (page OperationListResultPage) NotDone() bool { 464 return !page.olr.IsEmpty() 465} 466 467// Response returns the raw server response from the last page request. 468func (page OperationListResultPage) Response() OperationListResult { 469 return page.olr 470} 471 472// Values returns the slice of values for the current page or nil if there are no values. 473func (page OperationListResultPage) Values() []Operation { 474 if page.olr.IsEmpty() { 475 return nil 476 } 477 return *page.olr.Value 478} 479 480// ParentGroupInfo (Optional) The ID of the parent management group. 481type ParentGroupInfo struct { 482 // ParentID - The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 483 ParentID *string `json:"parentId,omitempty"` 484 // DisplayName - The friendly name of the parent management group. 485 DisplayName *string `json:"displayName,omitempty"` 486} 487 488// Properties the generic properties of a management group. 489type Properties struct { 490 // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 491 TenantID *string `json:"tenantId,omitempty"` 492 // DisplayName - The friendly name of the management group. 493 DisplayName *string `json:"displayName,omitempty"` 494 Details *Details `json:"details,omitempty"` 495 // Children - The list of children. 496 Children *[]ChildInfo `json:"children,omitempty"` 497} 498