...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-11-01/managementgroups/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-11-01/managementgroups

     1  package 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  
     9  import (
    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.
    21  const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-11-01/managementgroups"
    22  
    23  // CheckNameAvailabilityRequest management group name availability check parameters.
    24  type 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: 'MicrosoftManagementmanagementGroups'
    28  	Type Type `json:"type,omitempty"`
    29  }
    30  
    31  // CheckNameAvailabilityResult describes the result of the request to check management group name
    32  // availability.
    33  type 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.
    44  func (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.
    50  type ChildInfo struct {
    51  	// Type - The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). Possible values include: 'Type1MicrosoftManagementmanagementGroups', '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.
    66  type CreateManagementGroupChildInfo struct {
    67  	// Type - READ-ONLY; The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). Possible values include: 'Type2MicrosoftManagementmanagementGroups', '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.
    82  func (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.
    88  type 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.
    99  func (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.
   108  type 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.
   121  func (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.
   133  type 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, 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.
   144  func (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.
   156  func (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.
   208  type 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.
   216  func (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.
   227  func (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.
   250  type 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.
   260  func (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.
   269  type 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.
   277  func (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.
   288  func (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  // DescendantInfo the descendant.
   311  type DescendantInfo struct {
   312  	// ID - READ-ONLY; The fully qualified ID for the descendant.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 or /subscriptions/0000000-0000-0000-0000-000000000000
   313  	ID *string `json:"id,omitempty"`
   314  	// Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups or /subscriptions
   315  	Type *string `json:"type,omitempty"`
   316  	// Name - READ-ONLY; The name of the descendant. For example, 00000000-0000-0000-0000-000000000000
   317  	Name                      *string `json:"name,omitempty"`
   318  	*DescendantInfoProperties `json:"properties,omitempty"`
   319  }
   320  
   321  // MarshalJSON is the custom marshaler for DescendantInfo.
   322  func (di DescendantInfo) MarshalJSON() ([]byte, error) {
   323  	objectMap := make(map[string]interface{})
   324  	if di.DescendantInfoProperties != nil {
   325  		objectMap["properties"] = di.DescendantInfoProperties
   326  	}
   327  	return json.Marshal(objectMap)
   328  }
   329  
   330  // UnmarshalJSON is the custom unmarshaler for DescendantInfo struct.
   331  func (di *DescendantInfo) 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  				di.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  				di.Type = &typeVar
   356  			}
   357  		case "name":
   358  			if v != nil {
   359  				var name string
   360  				err = json.Unmarshal(*v, &name)
   361  				if err != nil {
   362  					return err
   363  				}
   364  				di.Name = &name
   365  			}
   366  		case "properties":
   367  			if v != nil {
   368  				var descendantInfoProperties DescendantInfoProperties
   369  				err = json.Unmarshal(*v, &descendantInfoProperties)
   370  				if err != nil {
   371  					return err
   372  				}
   373  				di.DescendantInfoProperties = &descendantInfoProperties
   374  			}
   375  		}
   376  	}
   377  
   378  	return nil
   379  }
   380  
   381  // DescendantInfoProperties the generic properties of an descendant.
   382  type DescendantInfoProperties struct {
   383  	// DisplayName - The friendly name of the management group.
   384  	DisplayName *string                    `json:"displayName,omitempty"`
   385  	Parent      *DescendantParentGroupInfo `json:"parent,omitempty"`
   386  }
   387  
   388  // DescendantListResult describes the result of the request to view descendants.
   389  type DescendantListResult struct {
   390  	autorest.Response `json:"-"`
   391  	// Value - The list of descendants.
   392  	Value *[]DescendantInfo `json:"value,omitempty"`
   393  	// NextLink - READ-ONLY; The URL to use for getting the next set of results.
   394  	NextLink *string `json:"nextLink,omitempty"`
   395  }
   396  
   397  // MarshalJSON is the custom marshaler for DescendantListResult.
   398  func (dlr DescendantListResult) MarshalJSON() ([]byte, error) {
   399  	objectMap := make(map[string]interface{})
   400  	if dlr.Value != nil {
   401  		objectMap["value"] = dlr.Value
   402  	}
   403  	return json.Marshal(objectMap)
   404  }
   405  
   406  // DescendantListResultIterator provides access to a complete listing of DescendantInfo values.
   407  type DescendantListResultIterator struct {
   408  	i    int
   409  	page DescendantListResultPage
   410  }
   411  
   412  // NextWithContext advances to the next value.  If there was an error making
   413  // the request the iterator does not advance and the error is returned.
   414  func (iter *DescendantListResultIterator) NextWithContext(ctx context.Context) (err error) {
   415  	if tracing.IsEnabled() {
   416  		ctx = tracing.StartSpan(ctx, fqdn+"/DescendantListResultIterator.NextWithContext")
   417  		defer func() {
   418  			sc := -1
   419  			if iter.Response().Response.Response != nil {
   420  				sc = iter.Response().Response.Response.StatusCode
   421  			}
   422  			tracing.EndSpan(ctx, sc, err)
   423  		}()
   424  	}
   425  	iter.i++
   426  	if iter.i < len(iter.page.Values()) {
   427  		return nil
   428  	}
   429  	err = iter.page.NextWithContext(ctx)
   430  	if err != nil {
   431  		iter.i--
   432  		return err
   433  	}
   434  	iter.i = 0
   435  	return nil
   436  }
   437  
   438  // Next advances to the next value.  If there was an error making
   439  // the request the iterator does not advance and the error is returned.
   440  // Deprecated: Use NextWithContext() instead.
   441  func (iter *DescendantListResultIterator) Next() error {
   442  	return iter.NextWithContext(context.Background())
   443  }
   444  
   445  // NotDone returns true if the enumeration should be started or is not yet complete.
   446  func (iter DescendantListResultIterator) NotDone() bool {
   447  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   448  }
   449  
   450  // Response returns the raw server response from the last page request.
   451  func (iter DescendantListResultIterator) Response() DescendantListResult {
   452  	return iter.page.Response()
   453  }
   454  
   455  // Value returns the current value or a zero-initialized value if the
   456  // iterator has advanced beyond the end of the collection.
   457  func (iter DescendantListResultIterator) Value() DescendantInfo {
   458  	if !iter.page.NotDone() {
   459  		return DescendantInfo{}
   460  	}
   461  	return iter.page.Values()[iter.i]
   462  }
   463  
   464  // Creates a new instance of the DescendantListResultIterator type.
   465  func NewDescendantListResultIterator(page DescendantListResultPage) DescendantListResultIterator {
   466  	return DescendantListResultIterator{page: page}
   467  }
   468  
   469  // IsEmpty returns true if the ListResult contains no values.
   470  func (dlr DescendantListResult) IsEmpty() bool {
   471  	return dlr.Value == nil || len(*dlr.Value) == 0
   472  }
   473  
   474  // hasNextLink returns true if the NextLink is not empty.
   475  func (dlr DescendantListResult) hasNextLink() bool {
   476  	return dlr.NextLink != nil && len(*dlr.NextLink) != 0
   477  }
   478  
   479  // descendantListResultPreparer prepares a request to retrieve the next set of results.
   480  // It returns nil if no more results exist.
   481  func (dlr DescendantListResult) descendantListResultPreparer(ctx context.Context) (*http.Request, error) {
   482  	if !dlr.hasNextLink() {
   483  		return nil, nil
   484  	}
   485  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   486  		autorest.AsJSON(),
   487  		autorest.AsGet(),
   488  		autorest.WithBaseURL(to.String(dlr.NextLink)))
   489  }
   490  
   491  // DescendantListResultPage contains a page of DescendantInfo values.
   492  type DescendantListResultPage struct {
   493  	fn  func(context.Context, DescendantListResult) (DescendantListResult, error)
   494  	dlr DescendantListResult
   495  }
   496  
   497  // NextWithContext advances to the next page of values.  If there was an error making
   498  // the request the page does not advance and the error is returned.
   499  func (page *DescendantListResultPage) NextWithContext(ctx context.Context) (err error) {
   500  	if tracing.IsEnabled() {
   501  		ctx = tracing.StartSpan(ctx, fqdn+"/DescendantListResultPage.NextWithContext")
   502  		defer func() {
   503  			sc := -1
   504  			if page.Response().Response.Response != nil {
   505  				sc = page.Response().Response.Response.StatusCode
   506  			}
   507  			tracing.EndSpan(ctx, sc, err)
   508  		}()
   509  	}
   510  	for {
   511  		next, err := page.fn(ctx, page.dlr)
   512  		if err != nil {
   513  			return err
   514  		}
   515  		page.dlr = next
   516  		if !next.hasNextLink() || !next.IsEmpty() {
   517  			break
   518  		}
   519  	}
   520  	return nil
   521  }
   522  
   523  // Next advances to the next page of values.  If there was an error making
   524  // the request the page does not advance and the error is returned.
   525  // Deprecated: Use NextWithContext() instead.
   526  func (page *DescendantListResultPage) Next() error {
   527  	return page.NextWithContext(context.Background())
   528  }
   529  
   530  // NotDone returns true if the page enumeration should be started or is not yet complete.
   531  func (page DescendantListResultPage) NotDone() bool {
   532  	return !page.dlr.IsEmpty()
   533  }
   534  
   535  // Response returns the raw server response from the last page request.
   536  func (page DescendantListResultPage) Response() DescendantListResult {
   537  	return page.dlr
   538  }
   539  
   540  // Values returns the slice of values for the current page or nil if there are no values.
   541  func (page DescendantListResultPage) Values() []DescendantInfo {
   542  	if page.dlr.IsEmpty() {
   543  		return nil
   544  	}
   545  	return *page.dlr.Value
   546  }
   547  
   548  // Creates a new instance of the DescendantListResultPage type.
   549  func NewDescendantListResultPage(cur DescendantListResult, getNextPage func(context.Context, DescendantListResult) (DescendantListResult, error)) DescendantListResultPage {
   550  	return DescendantListResultPage{
   551  		fn:  getNextPage,
   552  		dlr: cur,
   553  	}
   554  }
   555  
   556  // DescendantParentGroupInfo the ID of the parent management group.
   557  type DescendantParentGroupInfo struct {
   558  	// ID - The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
   559  	ID *string `json:"id,omitempty"`
   560  }
   561  
   562  // Details the details of a management group.
   563  type Details struct {
   564  	// Version - The version number of the object.
   565  	Version *float64 `json:"version,omitempty"`
   566  	// UpdatedTime - The date and time when this object was last updated.
   567  	UpdatedTime *date.Time `json:"updatedTime,omitempty"`
   568  	// UpdatedBy - The identity of the principal or process that updated the object.
   569  	UpdatedBy *string          `json:"updatedBy,omitempty"`
   570  	Parent    *ParentGroupInfo `json:"parent,omitempty"`
   571  }
   572  
   573  // EntityHierarchyItem the management group details for the hierarchy view.
   574  type EntityHierarchyItem struct {
   575  	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
   576  	ID *string `json:"id,omitempty"`
   577  	// Type - READ-ONLY; The type of the resource.  For example, Microsoft.Management/managementGroups
   578  	Type *string `json:"type,omitempty"`
   579  	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
   580  	Name                           *string `json:"name,omitempty"`
   581  	*EntityHierarchyItemProperties `json:"properties,omitempty"`
   582  }
   583  
   584  // MarshalJSON is the custom marshaler for EntityHierarchyItem.
   585  func (ehi EntityHierarchyItem) MarshalJSON() ([]byte, error) {
   586  	objectMap := make(map[string]interface{})
   587  	if ehi.EntityHierarchyItemProperties != nil {
   588  		objectMap["properties"] = ehi.EntityHierarchyItemProperties
   589  	}
   590  	return json.Marshal(objectMap)
   591  }
   592  
   593  // UnmarshalJSON is the custom unmarshaler for EntityHierarchyItem struct.
   594  func (ehi *EntityHierarchyItem) UnmarshalJSON(body []byte) error {
   595  	var m map[string]*json.RawMessage
   596  	err := json.Unmarshal(body, &m)
   597  	if err != nil {
   598  		return err
   599  	}
   600  	for k, v := range m {
   601  		switch k {
   602  		case "id":
   603  			if v != nil {
   604  				var ID string
   605  				err = json.Unmarshal(*v, &ID)
   606  				if err != nil {
   607  					return err
   608  				}
   609  				ehi.ID = &ID
   610  			}
   611  		case "type":
   612  			if v != nil {
   613  				var typeVar string
   614  				err = json.Unmarshal(*v, &typeVar)
   615  				if err != nil {
   616  					return err
   617  				}
   618  				ehi.Type = &typeVar
   619  			}
   620  		case "name":
   621  			if v != nil {
   622  				var name string
   623  				err = json.Unmarshal(*v, &name)
   624  				if err != nil {
   625  					return err
   626  				}
   627  				ehi.Name = &name
   628  			}
   629  		case "properties":
   630  			if v != nil {
   631  				var entityHierarchyItemProperties EntityHierarchyItemProperties
   632  				err = json.Unmarshal(*v, &entityHierarchyItemProperties)
   633  				if err != nil {
   634  					return err
   635  				}
   636  				ehi.EntityHierarchyItemProperties = &entityHierarchyItemProperties
   637  			}
   638  		}
   639  	}
   640  
   641  	return nil
   642  }
   643  
   644  // EntityHierarchyItemProperties the generic properties of a management group.
   645  type EntityHierarchyItemProperties struct {
   646  	// DisplayName - The friendly name of the management group.
   647  	DisplayName *string `json:"displayName,omitempty"`
   648  	// Permissions - Possible values include: 'Permissions1Noaccess', 'Permissions1View', 'Permissions1Edit', 'Permissions1Delete'
   649  	Permissions Permissions1 `json:"permissions,omitempty"`
   650  	// Children - The list of children.
   651  	Children *[]EntityHierarchyItem `json:"children,omitempty"`
   652  }
   653  
   654  // EntityInfo the entity.
   655  type EntityInfo struct {
   656  	// ID - READ-ONLY; The fully qualified ID for the entity.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
   657  	ID *string `json:"id,omitempty"`
   658  	// Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
   659  	Type *string `json:"type,omitempty"`
   660  	// Name - READ-ONLY; The name of the entity. For example, 00000000-0000-0000-0000-000000000000
   661  	Name                  *string `json:"name,omitempty"`
   662  	*EntityInfoProperties `json:"properties,omitempty"`
   663  }
   664  
   665  // MarshalJSON is the custom marshaler for EntityInfo.
   666  func (ei EntityInfo) MarshalJSON() ([]byte, error) {
   667  	objectMap := make(map[string]interface{})
   668  	if ei.EntityInfoProperties != nil {
   669  		objectMap["properties"] = ei.EntityInfoProperties
   670  	}
   671  	return json.Marshal(objectMap)
   672  }
   673  
   674  // UnmarshalJSON is the custom unmarshaler for EntityInfo struct.
   675  func (ei *EntityInfo) UnmarshalJSON(body []byte) error {
   676  	var m map[string]*json.RawMessage
   677  	err := json.Unmarshal(body, &m)
   678  	if err != nil {
   679  		return err
   680  	}
   681  	for k, v := range m {
   682  		switch k {
   683  		case "id":
   684  			if v != nil {
   685  				var ID string
   686  				err = json.Unmarshal(*v, &ID)
   687  				if err != nil {
   688  					return err
   689  				}
   690  				ei.ID = &ID
   691  			}
   692  		case "type":
   693  			if v != nil {
   694  				var typeVar string
   695  				err = json.Unmarshal(*v, &typeVar)
   696  				if err != nil {
   697  					return err
   698  				}
   699  				ei.Type = &typeVar
   700  			}
   701  		case "name":
   702  			if v != nil {
   703  				var name string
   704  				err = json.Unmarshal(*v, &name)
   705  				if err != nil {
   706  					return err
   707  				}
   708  				ei.Name = &name
   709  			}
   710  		case "properties":
   711  			if v != nil {
   712  				var entityInfoProperties EntityInfoProperties
   713  				err = json.Unmarshal(*v, &entityInfoProperties)
   714  				if err != nil {
   715  					return err
   716  				}
   717  				ei.EntityInfoProperties = &entityInfoProperties
   718  			}
   719  		}
   720  	}
   721  
   722  	return nil
   723  }
   724  
   725  // EntityInfoProperties the generic properties of an entity.
   726  type EntityInfoProperties struct {
   727  	// TenantID - The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000
   728  	TenantID *string `json:"tenantId,omitempty"`
   729  	// DisplayName - The friendly name of the management group.
   730  	DisplayName *string                `json:"displayName,omitempty"`
   731  	Parent      *EntityParentGroupInfo `json:"parent,omitempty"`
   732  	// Permissions - Possible values include: 'PermissionsNoaccess', 'PermissionsView', 'PermissionsEdit', 'PermissionsDelete'
   733  	Permissions Permissions `json:"permissions,omitempty"`
   734  	// InheritedPermissions - Possible values include: 'Noaccess', 'View', 'Edit', 'Delete'
   735  	InheritedPermissions InheritedPermissions `json:"inheritedPermissions,omitempty"`
   736  	NumberOfDescendants  *int32               `json:"numberOfDescendants,omitempty"`
   737  	// NumberOfChildren - Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group.
   738  	NumberOfChildren *int32 `json:"numberOfChildren,omitempty"`
   739  	// NumberOfChildGroups - Number of children is the number of Groups that are exactly one level underneath the current Group.
   740  	NumberOfChildGroups *int32 `json:"numberOfChildGroups,omitempty"`
   741  	// ParentDisplayNameChain - The parent display name chain from the root group to the immediate parent
   742  	ParentDisplayNameChain *[]string `json:"parentDisplayNameChain,omitempty"`
   743  	// ParentNameChain - The parent name chain from the root group to the immediate parent
   744  	ParentNameChain *[]string `json:"parentNameChain,omitempty"`
   745  }
   746  
   747  // EntityListResult describes the result of the request to view entities.
   748  type EntityListResult struct {
   749  	autorest.Response `json:"-"`
   750  	// Value - The list of entities.
   751  	Value *[]EntityInfo `json:"value,omitempty"`
   752  	// Count - READ-ONLY; Total count of records that match the filter
   753  	Count *int32 `json:"count,omitempty"`
   754  	// NextLink - READ-ONLY; The URL to use for getting the next set of results.
   755  	NextLink *string `json:"nextLink,omitempty"`
   756  }
   757  
   758  // MarshalJSON is the custom marshaler for EntityListResult.
   759  func (elr EntityListResult) MarshalJSON() ([]byte, error) {
   760  	objectMap := make(map[string]interface{})
   761  	if elr.Value != nil {
   762  		objectMap["value"] = elr.Value
   763  	}
   764  	return json.Marshal(objectMap)
   765  }
   766  
   767  // EntityListResultIterator provides access to a complete listing of EntityInfo values.
   768  type EntityListResultIterator struct {
   769  	i    int
   770  	page EntityListResultPage
   771  }
   772  
   773  // NextWithContext advances to the next value.  If there was an error making
   774  // the request the iterator does not advance and the error is returned.
   775  func (iter *EntityListResultIterator) NextWithContext(ctx context.Context) (err error) {
   776  	if tracing.IsEnabled() {
   777  		ctx = tracing.StartSpan(ctx, fqdn+"/EntityListResultIterator.NextWithContext")
   778  		defer func() {
   779  			sc := -1
   780  			if iter.Response().Response.Response != nil {
   781  				sc = iter.Response().Response.Response.StatusCode
   782  			}
   783  			tracing.EndSpan(ctx, sc, err)
   784  		}()
   785  	}
   786  	iter.i++
   787  	if iter.i < len(iter.page.Values()) {
   788  		return nil
   789  	}
   790  	err = iter.page.NextWithContext(ctx)
   791  	if err != nil {
   792  		iter.i--
   793  		return err
   794  	}
   795  	iter.i = 0
   796  	return nil
   797  }
   798  
   799  // Next advances to the next value.  If there was an error making
   800  // the request the iterator does not advance and the error is returned.
   801  // Deprecated: Use NextWithContext() instead.
   802  func (iter *EntityListResultIterator) Next() error {
   803  	return iter.NextWithContext(context.Background())
   804  }
   805  
   806  // NotDone returns true if the enumeration should be started or is not yet complete.
   807  func (iter EntityListResultIterator) NotDone() bool {
   808  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   809  }
   810  
   811  // Response returns the raw server response from the last page request.
   812  func (iter EntityListResultIterator) Response() EntityListResult {
   813  	return iter.page.Response()
   814  }
   815  
   816  // Value returns the current value or a zero-initialized value if the
   817  // iterator has advanced beyond the end of the collection.
   818  func (iter EntityListResultIterator) Value() EntityInfo {
   819  	if !iter.page.NotDone() {
   820  		return EntityInfo{}
   821  	}
   822  	return iter.page.Values()[iter.i]
   823  }
   824  
   825  // Creates a new instance of the EntityListResultIterator type.
   826  func NewEntityListResultIterator(page EntityListResultPage) EntityListResultIterator {
   827  	return EntityListResultIterator{page: page}
   828  }
   829  
   830  // IsEmpty returns true if the ListResult contains no values.
   831  func (elr EntityListResult) IsEmpty() bool {
   832  	return elr.Value == nil || len(*elr.Value) == 0
   833  }
   834  
   835  // hasNextLink returns true if the NextLink is not empty.
   836  func (elr EntityListResult) hasNextLink() bool {
   837  	return elr.NextLink != nil && len(*elr.NextLink) != 0
   838  }
   839  
   840  // entityListResultPreparer prepares a request to retrieve the next set of results.
   841  // It returns nil if no more results exist.
   842  func (elr EntityListResult) entityListResultPreparer(ctx context.Context) (*http.Request, error) {
   843  	if !elr.hasNextLink() {
   844  		return nil, nil
   845  	}
   846  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   847  		autorest.AsJSON(),
   848  		autorest.AsGet(),
   849  		autorest.WithBaseURL(to.String(elr.NextLink)))
   850  }
   851  
   852  // EntityListResultPage contains a page of EntityInfo values.
   853  type EntityListResultPage struct {
   854  	fn  func(context.Context, EntityListResult) (EntityListResult, error)
   855  	elr EntityListResult
   856  }
   857  
   858  // NextWithContext advances to the next page of values.  If there was an error making
   859  // the request the page does not advance and the error is returned.
   860  func (page *EntityListResultPage) NextWithContext(ctx context.Context) (err error) {
   861  	if tracing.IsEnabled() {
   862  		ctx = tracing.StartSpan(ctx, fqdn+"/EntityListResultPage.NextWithContext")
   863  		defer func() {
   864  			sc := -1
   865  			if page.Response().Response.Response != nil {
   866  				sc = page.Response().Response.Response.StatusCode
   867  			}
   868  			tracing.EndSpan(ctx, sc, err)
   869  		}()
   870  	}
   871  	for {
   872  		next, err := page.fn(ctx, page.elr)
   873  		if err != nil {
   874  			return err
   875  		}
   876  		page.elr = next
   877  		if !next.hasNextLink() || !next.IsEmpty() {
   878  			break
   879  		}
   880  	}
   881  	return nil
   882  }
   883  
   884  // Next advances to the next page of values.  If there was an error making
   885  // the request the page does not advance and the error is returned.
   886  // Deprecated: Use NextWithContext() instead.
   887  func (page *EntityListResultPage) Next() error {
   888  	return page.NextWithContext(context.Background())
   889  }
   890  
   891  // NotDone returns true if the page enumeration should be started or is not yet complete.
   892  func (page EntityListResultPage) NotDone() bool {
   893  	return !page.elr.IsEmpty()
   894  }
   895  
   896  // Response returns the raw server response from the last page request.
   897  func (page EntityListResultPage) Response() EntityListResult {
   898  	return page.elr
   899  }
   900  
   901  // Values returns the slice of values for the current page or nil if there are no values.
   902  func (page EntityListResultPage) Values() []EntityInfo {
   903  	if page.elr.IsEmpty() {
   904  		return nil
   905  	}
   906  	return *page.elr.Value
   907  }
   908  
   909  // Creates a new instance of the EntityListResultPage type.
   910  func NewEntityListResultPage(cur EntityListResult, getNextPage func(context.Context, EntityListResult) (EntityListResult, error)) EntityListResultPage {
   911  	return EntityListResultPage{
   912  		fn:  getNextPage,
   913  		elr: cur,
   914  	}
   915  }
   916  
   917  // EntityParentGroupInfo (Optional) The ID of the parent management group.
   918  type EntityParentGroupInfo struct {
   919  	// ID - The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
   920  	ID *string `json:"id,omitempty"`
   921  }
   922  
   923  // ErrorDetails the details of the error.
   924  type ErrorDetails struct {
   925  	// Code - One of a server-defined set of error codes.
   926  	Code *string `json:"code,omitempty"`
   927  	// Message - A human-readable representation of the error.
   928  	Message *string `json:"message,omitempty"`
   929  	// Details - A human-readable representation of the error's details.
   930  	Details *string `json:"details,omitempty"`
   931  }
   932  
   933  // ErrorResponse the error object.
   934  type ErrorResponse struct {
   935  	Error *ErrorDetails `json:"error,omitempty"`
   936  }
   937  
   938  // Info the management group resource.
   939  type Info struct {
   940  	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
   941  	ID *string `json:"id,omitempty"`
   942  	// Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups
   943  	Type *string `json:"type,omitempty"`
   944  	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
   945  	Name            *string `json:"name,omitempty"`
   946  	*InfoProperties `json:"properties,omitempty"`
   947  }
   948  
   949  // MarshalJSON is the custom marshaler for Info.
   950  func (i Info) MarshalJSON() ([]byte, error) {
   951  	objectMap := make(map[string]interface{})
   952  	if i.InfoProperties != nil {
   953  		objectMap["properties"] = i.InfoProperties
   954  	}
   955  	return json.Marshal(objectMap)
   956  }
   957  
   958  // UnmarshalJSON is the custom unmarshaler for Info struct.
   959  func (i *Info) UnmarshalJSON(body []byte) error {
   960  	var m map[string]*json.RawMessage
   961  	err := json.Unmarshal(body, &m)
   962  	if err != nil {
   963  		return err
   964  	}
   965  	for k, v := range m {
   966  		switch k {
   967  		case "id":
   968  			if v != nil {
   969  				var ID string
   970  				err = json.Unmarshal(*v, &ID)
   971  				if err != nil {
   972  					return err
   973  				}
   974  				i.ID = &ID
   975  			}
   976  		case "type":
   977  			if v != nil {
   978  				var typeVar string
   979  				err = json.Unmarshal(*v, &typeVar)
   980  				if err != nil {
   981  					return err
   982  				}
   983  				i.Type = &typeVar
   984  			}
   985  		case "name":
   986  			if v != nil {
   987  				var name string
   988  				err = json.Unmarshal(*v, &name)
   989  				if err != nil {
   990  					return err
   991  				}
   992  				i.Name = &name
   993  			}
   994  		case "properties":
   995  			if v != nil {
   996  				var infoProperties InfoProperties
   997  				err = json.Unmarshal(*v, &infoProperties)
   998  				if err != nil {
   999  					return err
  1000  				}
  1001  				i.InfoProperties = &infoProperties
  1002  			}
  1003  		}
  1004  	}
  1005  
  1006  	return nil
  1007  }
  1008  
  1009  // InfoProperties the generic properties of a management group.
  1010  type InfoProperties struct {
  1011  	// TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
  1012  	TenantID *string `json:"tenantId,omitempty"`
  1013  	// DisplayName - The friendly name of the management group.
  1014  	DisplayName *string `json:"displayName,omitempty"`
  1015  }
  1016  
  1017  // ListResult describes the result of the request to list management groups.
  1018  type ListResult struct {
  1019  	autorest.Response `json:"-"`
  1020  	// Value - The list of management groups.
  1021  	Value *[]Info `json:"value,omitempty"`
  1022  	// NextLink - READ-ONLY; The URL to use for getting the next set of results.
  1023  	NextLink *string `json:"nextLink,omitempty"`
  1024  }
  1025  
  1026  // MarshalJSON is the custom marshaler for ListResult.
  1027  func (lr ListResult) MarshalJSON() ([]byte, error) {
  1028  	objectMap := make(map[string]interface{})
  1029  	if lr.Value != nil {
  1030  		objectMap["value"] = lr.Value
  1031  	}
  1032  	return json.Marshal(objectMap)
  1033  }
  1034  
  1035  // ListResultIterator provides access to a complete listing of Info values.
  1036  type ListResultIterator struct {
  1037  	i    int
  1038  	page ListResultPage
  1039  }
  1040  
  1041  // NextWithContext advances to the next value.  If there was an error making
  1042  // the request the iterator does not advance and the error is returned.
  1043  func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
  1044  	if tracing.IsEnabled() {
  1045  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
  1046  		defer func() {
  1047  			sc := -1
  1048  			if iter.Response().Response.Response != nil {
  1049  				sc = iter.Response().Response.Response.StatusCode
  1050  			}
  1051  			tracing.EndSpan(ctx, sc, err)
  1052  		}()
  1053  	}
  1054  	iter.i++
  1055  	if iter.i < len(iter.page.Values()) {
  1056  		return nil
  1057  	}
  1058  	err = iter.page.NextWithContext(ctx)
  1059  	if err != nil {
  1060  		iter.i--
  1061  		return err
  1062  	}
  1063  	iter.i = 0
  1064  	return nil
  1065  }
  1066  
  1067  // Next advances to the next value.  If there was an error making
  1068  // the request the iterator does not advance and the error is returned.
  1069  // Deprecated: Use NextWithContext() instead.
  1070  func (iter *ListResultIterator) Next() error {
  1071  	return iter.NextWithContext(context.Background())
  1072  }
  1073  
  1074  // NotDone returns true if the enumeration should be started or is not yet complete.
  1075  func (iter ListResultIterator) NotDone() bool {
  1076  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
  1077  }
  1078  
  1079  // Response returns the raw server response from the last page request.
  1080  func (iter ListResultIterator) Response() ListResult {
  1081  	return iter.page.Response()
  1082  }
  1083  
  1084  // Value returns the current value or a zero-initialized value if the
  1085  // iterator has advanced beyond the end of the collection.
  1086  func (iter ListResultIterator) Value() Info {
  1087  	if !iter.page.NotDone() {
  1088  		return Info{}
  1089  	}
  1090  	return iter.page.Values()[iter.i]
  1091  }
  1092  
  1093  // Creates a new instance of the ListResultIterator type.
  1094  func NewListResultIterator(page ListResultPage) ListResultIterator {
  1095  	return ListResultIterator{page: page}
  1096  }
  1097  
  1098  // IsEmpty returns true if the ListResult contains no values.
  1099  func (lr ListResult) IsEmpty() bool {
  1100  	return lr.Value == nil || len(*lr.Value) == 0
  1101  }
  1102  
  1103  // hasNextLink returns true if the NextLink is not empty.
  1104  func (lr ListResult) hasNextLink() bool {
  1105  	return lr.NextLink != nil && len(*lr.NextLink) != 0
  1106  }
  1107  
  1108  // listResultPreparer prepares a request to retrieve the next set of results.
  1109  // It returns nil if no more results exist.
  1110  func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
  1111  	if !lr.hasNextLink() {
  1112  		return nil, nil
  1113  	}
  1114  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
  1115  		autorest.AsJSON(),
  1116  		autorest.AsGet(),
  1117  		autorest.WithBaseURL(to.String(lr.NextLink)))
  1118  }
  1119  
  1120  // ListResultPage contains a page of Info values.
  1121  type ListResultPage struct {
  1122  	fn func(context.Context, ListResult) (ListResult, error)
  1123  	lr ListResult
  1124  }
  1125  
  1126  // NextWithContext advances to the next page of values.  If there was an error making
  1127  // the request the page does not advance and the error is returned.
  1128  func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
  1129  	if tracing.IsEnabled() {
  1130  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
  1131  		defer func() {
  1132  			sc := -1
  1133  			if page.Response().Response.Response != nil {
  1134  				sc = page.Response().Response.Response.StatusCode
  1135  			}
  1136  			tracing.EndSpan(ctx, sc, err)
  1137  		}()
  1138  	}
  1139  	for {
  1140  		next, err := page.fn(ctx, page.lr)
  1141  		if err != nil {
  1142  			return err
  1143  		}
  1144  		page.lr = next
  1145  		if !next.hasNextLink() || !next.IsEmpty() {
  1146  			break
  1147  		}
  1148  	}
  1149  	return nil
  1150  }
  1151  
  1152  // Next advances to the next page of values.  If there was an error making
  1153  // the request the page does not advance and the error is returned.
  1154  // Deprecated: Use NextWithContext() instead.
  1155  func (page *ListResultPage) Next() error {
  1156  	return page.NextWithContext(context.Background())
  1157  }
  1158  
  1159  // NotDone returns true if the page enumeration should be started or is not yet complete.
  1160  func (page ListResultPage) NotDone() bool {
  1161  	return !page.lr.IsEmpty()
  1162  }
  1163  
  1164  // Response returns the raw server response from the last page request.
  1165  func (page ListResultPage) Response() ListResult {
  1166  	return page.lr
  1167  }
  1168  
  1169  // Values returns the slice of values for the current page or nil if there are no values.
  1170  func (page ListResultPage) Values() []Info {
  1171  	if page.lr.IsEmpty() {
  1172  		return nil
  1173  	}
  1174  	return *page.lr.Value
  1175  }
  1176  
  1177  // Creates a new instance of the ListResultPage type.
  1178  func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
  1179  	return ListResultPage{
  1180  		fn: getNextPage,
  1181  		lr: cur,
  1182  	}
  1183  }
  1184  
  1185  // ManagementGroup the management group details.
  1186  type ManagementGroup struct {
  1187  	autorest.Response `json:"-"`
  1188  	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
  1189  	ID *string `json:"id,omitempty"`
  1190  	// Type - READ-ONLY; The type of the resource.  For example, Microsoft.Management/managementGroups
  1191  	Type *string `json:"type,omitempty"`
  1192  	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
  1193  	Name        *string `json:"name,omitempty"`
  1194  	*Properties `json:"properties,omitempty"`
  1195  }
  1196  
  1197  // MarshalJSON is the custom marshaler for ManagementGroup.
  1198  func (mg ManagementGroup) MarshalJSON() ([]byte, error) {
  1199  	objectMap := make(map[string]interface{})
  1200  	if mg.Properties != nil {
  1201  		objectMap["properties"] = mg.Properties
  1202  	}
  1203  	return json.Marshal(objectMap)
  1204  }
  1205  
  1206  // UnmarshalJSON is the custom unmarshaler for ManagementGroup struct.
  1207  func (mg *ManagementGroup) UnmarshalJSON(body []byte) error {
  1208  	var m map[string]*json.RawMessage
  1209  	err := json.Unmarshal(body, &m)
  1210  	if err != nil {
  1211  		return err
  1212  	}
  1213  	for k, v := range m {
  1214  		switch k {
  1215  		case "id":
  1216  			if v != nil {
  1217  				var ID string
  1218  				err = json.Unmarshal(*v, &ID)
  1219  				if err != nil {
  1220  					return err
  1221  				}
  1222  				mg.ID = &ID
  1223  			}
  1224  		case "type":
  1225  			if v != nil {
  1226  				var typeVar string
  1227  				err = json.Unmarshal(*v, &typeVar)
  1228  				if err != nil {
  1229  					return err
  1230  				}
  1231  				mg.Type = &typeVar
  1232  			}
  1233  		case "name":
  1234  			if v != nil {
  1235  				var name string
  1236  				err = json.Unmarshal(*v, &name)
  1237  				if err != nil {
  1238  					return err
  1239  				}
  1240  				mg.Name = &name
  1241  			}
  1242  		case "properties":
  1243  			if v != nil {
  1244  				var properties Properties
  1245  				err = json.Unmarshal(*v, &properties)
  1246  				if err != nil {
  1247  					return err
  1248  				}
  1249  				mg.Properties = &properties
  1250  			}
  1251  		}
  1252  	}
  1253  
  1254  	return nil
  1255  }
  1256  
  1257  // Operation operation supported by the Microsoft.Management resource provider.
  1258  type Operation struct {
  1259  	// Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}.
  1260  	Name    *string                     `json:"name,omitempty"`
  1261  	Display *OperationDisplayProperties `json:"display,omitempty"`
  1262  }
  1263  
  1264  // MarshalJSON is the custom marshaler for Operation.
  1265  func (o Operation) MarshalJSON() ([]byte, error) {
  1266  	objectMap := make(map[string]interface{})
  1267  	if o.Display != nil {
  1268  		objectMap["display"] = o.Display
  1269  	}
  1270  	return json.Marshal(objectMap)
  1271  }
  1272  
  1273  // OperationDisplayProperties the object that represents the operation.
  1274  type OperationDisplayProperties struct {
  1275  	// Provider - READ-ONLY; The name of the provider.
  1276  	Provider *string `json:"provider,omitempty"`
  1277  	// Resource - READ-ONLY; The resource on which the operation is performed.
  1278  	Resource *string `json:"resource,omitempty"`
  1279  	// Operation - READ-ONLY; The operation that can be performed.
  1280  	Operation *string `json:"operation,omitempty"`
  1281  	// Description - READ-ONLY; Operation description.
  1282  	Description *string `json:"description,omitempty"`
  1283  }
  1284  
  1285  // MarshalJSON is the custom marshaler for OperationDisplayProperties.
  1286  func (odp OperationDisplayProperties) MarshalJSON() ([]byte, error) {
  1287  	objectMap := make(map[string]interface{})
  1288  	return json.Marshal(objectMap)
  1289  }
  1290  
  1291  // OperationListResult describes the result of the request to list Microsoft.Management operations.
  1292  type OperationListResult struct {
  1293  	autorest.Response `json:"-"`
  1294  	// Value - READ-ONLY; List of operations supported by the Microsoft.Management resource provider.
  1295  	Value *[]Operation `json:"value,omitempty"`
  1296  	// NextLink - READ-ONLY; URL to get the next set of operation list results if there are any.
  1297  	NextLink *string `json:"nextLink,omitempty"`
  1298  }
  1299  
  1300  // MarshalJSON is the custom marshaler for OperationListResult.
  1301  func (olr OperationListResult) MarshalJSON() ([]byte, error) {
  1302  	objectMap := make(map[string]interface{})
  1303  	return json.Marshal(objectMap)
  1304  }
  1305  
  1306  // OperationListResultIterator provides access to a complete listing of Operation values.
  1307  type OperationListResultIterator struct {
  1308  	i    int
  1309  	page OperationListResultPage
  1310  }
  1311  
  1312  // NextWithContext advances to the next value.  If there was an error making
  1313  // the request the iterator does not advance and the error is returned.
  1314  func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
  1315  	if tracing.IsEnabled() {
  1316  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
  1317  		defer func() {
  1318  			sc := -1
  1319  			if iter.Response().Response.Response != nil {
  1320  				sc = iter.Response().Response.Response.StatusCode
  1321  			}
  1322  			tracing.EndSpan(ctx, sc, err)
  1323  		}()
  1324  	}
  1325  	iter.i++
  1326  	if iter.i < len(iter.page.Values()) {
  1327  		return nil
  1328  	}
  1329  	err = iter.page.NextWithContext(ctx)
  1330  	if err != nil {
  1331  		iter.i--
  1332  		return err
  1333  	}
  1334  	iter.i = 0
  1335  	return nil
  1336  }
  1337  
  1338  // Next advances to the next value.  If there was an error making
  1339  // the request the iterator does not advance and the error is returned.
  1340  // Deprecated: Use NextWithContext() instead.
  1341  func (iter *OperationListResultIterator) Next() error {
  1342  	return iter.NextWithContext(context.Background())
  1343  }
  1344  
  1345  // NotDone returns true if the enumeration should be started or is not yet complete.
  1346  func (iter OperationListResultIterator) NotDone() bool {
  1347  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
  1348  }
  1349  
  1350  // Response returns the raw server response from the last page request.
  1351  func (iter OperationListResultIterator) Response() OperationListResult {
  1352  	return iter.page.Response()
  1353  }
  1354  
  1355  // Value returns the current value or a zero-initialized value if the
  1356  // iterator has advanced beyond the end of the collection.
  1357  func (iter OperationListResultIterator) Value() Operation {
  1358  	if !iter.page.NotDone() {
  1359  		return Operation{}
  1360  	}
  1361  	return iter.page.Values()[iter.i]
  1362  }
  1363  
  1364  // Creates a new instance of the OperationListResultIterator type.
  1365  func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
  1366  	return OperationListResultIterator{page: page}
  1367  }
  1368  
  1369  // IsEmpty returns true if the ListResult contains no values.
  1370  func (olr OperationListResult) IsEmpty() bool {
  1371  	return olr.Value == nil || len(*olr.Value) == 0
  1372  }
  1373  
  1374  // hasNextLink returns true if the NextLink is not empty.
  1375  func (olr OperationListResult) hasNextLink() bool {
  1376  	return olr.NextLink != nil && len(*olr.NextLink) != 0
  1377  }
  1378  
  1379  // operationListResultPreparer prepares a request to retrieve the next set of results.
  1380  // It returns nil if no more results exist.
  1381  func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
  1382  	if !olr.hasNextLink() {
  1383  		return nil, nil
  1384  	}
  1385  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
  1386  		autorest.AsJSON(),
  1387  		autorest.AsGet(),
  1388  		autorest.WithBaseURL(to.String(olr.NextLink)))
  1389  }
  1390  
  1391  // OperationListResultPage contains a page of Operation values.
  1392  type OperationListResultPage struct {
  1393  	fn  func(context.Context, OperationListResult) (OperationListResult, error)
  1394  	olr OperationListResult
  1395  }
  1396  
  1397  // NextWithContext advances to the next page of values.  If there was an error making
  1398  // the request the page does not advance and the error is returned.
  1399  func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
  1400  	if tracing.IsEnabled() {
  1401  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
  1402  		defer func() {
  1403  			sc := -1
  1404  			if page.Response().Response.Response != nil {
  1405  				sc = page.Response().Response.Response.StatusCode
  1406  			}
  1407  			tracing.EndSpan(ctx, sc, err)
  1408  		}()
  1409  	}
  1410  	for {
  1411  		next, err := page.fn(ctx, page.olr)
  1412  		if err != nil {
  1413  			return err
  1414  		}
  1415  		page.olr = next
  1416  		if !next.hasNextLink() || !next.IsEmpty() {
  1417  			break
  1418  		}
  1419  	}
  1420  	return nil
  1421  }
  1422  
  1423  // Next advances to the next page of values.  If there was an error making
  1424  // the request the page does not advance and the error is returned.
  1425  // Deprecated: Use NextWithContext() instead.
  1426  func (page *OperationListResultPage) Next() error {
  1427  	return page.NextWithContext(context.Background())
  1428  }
  1429  
  1430  // NotDone returns true if the page enumeration should be started or is not yet complete.
  1431  func (page OperationListResultPage) NotDone() bool {
  1432  	return !page.olr.IsEmpty()
  1433  }
  1434  
  1435  // Response returns the raw server response from the last page request.
  1436  func (page OperationListResultPage) Response() OperationListResult {
  1437  	return page.olr
  1438  }
  1439  
  1440  // Values returns the slice of values for the current page or nil if there are no values.
  1441  func (page OperationListResultPage) Values() []Operation {
  1442  	if page.olr.IsEmpty() {
  1443  		return nil
  1444  	}
  1445  	return *page.olr.Value
  1446  }
  1447  
  1448  // Creates a new instance of the OperationListResultPage type.
  1449  func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
  1450  	return OperationListResultPage{
  1451  		fn:  getNextPage,
  1452  		olr: cur,
  1453  	}
  1454  }
  1455  
  1456  // OperationResults the results of an asynchronous operation.
  1457  type OperationResults struct {
  1458  	autorest.Response `json:"-"`
  1459  	// ID - READ-ONLY; The fully qualified ID for the management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
  1460  	ID *string `json:"id,omitempty"`
  1461  	// Type - READ-ONLY; The type of the resource.  For example, Microsoft.Management/managementGroups
  1462  	Type *string `json:"type,omitempty"`
  1463  	// Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000
  1464  	Name *string `json:"name,omitempty"`
  1465  	// Status - READ-ONLY; The current status of the operation
  1466  	Status *string `json:"status,omitempty"`
  1467  }
  1468  
  1469  // MarshalJSON is the custom marshaler for OperationResults.
  1470  func (or OperationResults) MarshalJSON() ([]byte, error) {
  1471  	objectMap := make(map[string]interface{})
  1472  	return json.Marshal(objectMap)
  1473  }
  1474  
  1475  // ParentGroupInfo (Optional) The ID of the parent management group.
  1476  type ParentGroupInfo struct {
  1477  	// ID - The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
  1478  	ID *string `json:"id,omitempty"`
  1479  	// Name - The name of the parent management group
  1480  	Name *string `json:"name,omitempty"`
  1481  	// DisplayName - The friendly name of the parent management group.
  1482  	DisplayName *string `json:"displayName,omitempty"`
  1483  }
  1484  
  1485  // PatchManagementGroupRequest management group patch parameters.
  1486  type PatchManagementGroupRequest struct {
  1487  	// DisplayName - The friendly name of the management group.
  1488  	DisplayName *string `json:"displayName,omitempty"`
  1489  	// ParentID - (Optional) The fully qualified ID for the parent management group.  For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
  1490  	ParentID *string `json:"parentId,omitempty"`
  1491  }
  1492  
  1493  // PathElement a path element of a management group ancestors.
  1494  type PathElement struct {
  1495  	// Name - The name of the group.
  1496  	Name *string `json:"name,omitempty"`
  1497  	// DisplayName - The friendly name of the group.
  1498  	DisplayName *string `json:"displayName,omitempty"`
  1499  }
  1500  
  1501  // Properties the generic properties of a management group.
  1502  type Properties struct {
  1503  	// TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
  1504  	TenantID *string `json:"tenantId,omitempty"`
  1505  	// DisplayName - The friendly name of the management group.
  1506  	DisplayName *string `json:"displayName,omitempty"`
  1507  	// Roles - The role definitions associated with the management group.
  1508  	Roles   *[]string `json:"roles,omitempty"`
  1509  	Details *Details  `json:"details,omitempty"`
  1510  	// Children - The list of children.
  1511  	Children *[]ChildInfo `json:"children,omitempty"`
  1512  	// Path - The hierarchial path from the root group to the current group.
  1513  	Path *[]PathElement `json:"path,omitempty"`
  1514  }
  1515  
  1516  // SetObject ...
  1517  type SetObject struct {
  1518  	autorest.Response `json:"-"`
  1519  	Value             interface{} `json:"value,omitempty"`
  1520  }
  1521  
  1522  // TenantBackfillStatusResult the tenant backfill status
  1523  type TenantBackfillStatusResult struct {
  1524  	autorest.Response `json:"-"`
  1525  	// TenantID - READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000
  1526  	TenantID *string `json:"tenantId,omitempty"`
  1527  	// Status - READ-ONLY; The status of the Tenant Backfill. Possible values include: 'NotStarted', 'NotStartedButGroupsExist', 'Started', 'Failed', 'Cancelled', 'Completed'
  1528  	Status Status `json:"status,omitempty"`
  1529  }
  1530  
  1531  // MarshalJSON is the custom marshaler for TenantBackfillStatusResult.
  1532  func (tbsr TenantBackfillStatusResult) MarshalJSON() ([]byte, error) {
  1533  	objectMap := make(map[string]interface{})
  1534  	return json.Marshal(objectMap)
  1535  }
  1536  

View as plain text