...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2021-01-01/subscriptions/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2021-01-01/subscriptions

     1  package subscriptions
     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/to"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // The package's fully qualified name.
    19  const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2021-01-01/subscriptions"
    20  
    21  // CheckResourceNameResult resource Name valid if not a reserved word, does not contain a reserved word and
    22  // does not start with a reserved word
    23  type CheckResourceNameResult struct {
    24  	autorest.Response `json:"-"`
    25  	// Name - Name of Resource
    26  	Name *string `json:"name,omitempty"`
    27  	// Type - Type of Resource
    28  	Type *string `json:"type,omitempty"`
    29  	// Status - Is the resource name Allowed or Reserved. Possible values include: 'ResourceNameStatusAllowed', 'ResourceNameStatusReserved'
    30  	Status ResourceNameStatus `json:"status,omitempty"`
    31  }
    32  
    33  // CloudError an error response for a resource management request.
    34  type CloudError struct {
    35  	Error *ErrorResponse `json:"error,omitempty"`
    36  }
    37  
    38  // ErrorAdditionalInfo the resource management error additional info.
    39  type ErrorAdditionalInfo struct {
    40  	// Type - READ-ONLY; The additional info type.
    41  	Type *string `json:"type,omitempty"`
    42  	// Info - READ-ONLY; The additional info.
    43  	Info interface{} `json:"info,omitempty"`
    44  }
    45  
    46  // MarshalJSON is the custom marshaler for ErrorAdditionalInfo.
    47  func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
    48  	objectMap := make(map[string]interface{})
    49  	return json.Marshal(objectMap)
    50  }
    51  
    52  // ErrorResponse common error response for all Azure Resource Manager APIs to return error details for
    53  // failed operations. (This also follows the OData error response format.)
    54  type ErrorResponse struct {
    55  	// Code - READ-ONLY; The error code.
    56  	Code *string `json:"code,omitempty"`
    57  	// Message - READ-ONLY; The error message.
    58  	Message *string `json:"message,omitempty"`
    59  	// Target - READ-ONLY; The error target.
    60  	Target *string `json:"target,omitempty"`
    61  	// Details - READ-ONLY; The error details.
    62  	Details *[]ErrorResponse `json:"details,omitempty"`
    63  	// AdditionalInfo - READ-ONLY; The error additional info.
    64  	AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
    65  }
    66  
    67  // MarshalJSON is the custom marshaler for ErrorResponse.
    68  func (er ErrorResponse) MarshalJSON() ([]byte, error) {
    69  	objectMap := make(map[string]interface{})
    70  	return json.Marshal(objectMap)
    71  }
    72  
    73  // ListResult subscription list operation response.
    74  type ListResult struct {
    75  	autorest.Response `json:"-"`
    76  	// Value - An array of subscriptions.
    77  	Value *[]Subscription `json:"value,omitempty"`
    78  	// NextLink - The URL to get the next set of results.
    79  	NextLink *string `json:"nextLink,omitempty"`
    80  }
    81  
    82  // ListResultIterator provides access to a complete listing of Subscription values.
    83  type ListResultIterator struct {
    84  	i    int
    85  	page ListResultPage
    86  }
    87  
    88  // NextWithContext advances to the next value.  If there was an error making
    89  // the request the iterator does not advance and the error is returned.
    90  func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
    91  	if tracing.IsEnabled() {
    92  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
    93  		defer func() {
    94  			sc := -1
    95  			if iter.Response().Response.Response != nil {
    96  				sc = iter.Response().Response.Response.StatusCode
    97  			}
    98  			tracing.EndSpan(ctx, sc, err)
    99  		}()
   100  	}
   101  	iter.i++
   102  	if iter.i < len(iter.page.Values()) {
   103  		return nil
   104  	}
   105  	err = iter.page.NextWithContext(ctx)
   106  	if err != nil {
   107  		iter.i--
   108  		return err
   109  	}
   110  	iter.i = 0
   111  	return nil
   112  }
   113  
   114  // Next advances to the next value.  If there was an error making
   115  // the request the iterator does not advance and the error is returned.
   116  // Deprecated: Use NextWithContext() instead.
   117  func (iter *ListResultIterator) Next() error {
   118  	return iter.NextWithContext(context.Background())
   119  }
   120  
   121  // NotDone returns true if the enumeration should be started or is not yet complete.
   122  func (iter ListResultIterator) NotDone() bool {
   123  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   124  }
   125  
   126  // Response returns the raw server response from the last page request.
   127  func (iter ListResultIterator) Response() ListResult {
   128  	return iter.page.Response()
   129  }
   130  
   131  // Value returns the current value or a zero-initialized value if the
   132  // iterator has advanced beyond the end of the collection.
   133  func (iter ListResultIterator) Value() Subscription {
   134  	if !iter.page.NotDone() {
   135  		return Subscription{}
   136  	}
   137  	return iter.page.Values()[iter.i]
   138  }
   139  
   140  // Creates a new instance of the ListResultIterator type.
   141  func NewListResultIterator(page ListResultPage) ListResultIterator {
   142  	return ListResultIterator{page: page}
   143  }
   144  
   145  // IsEmpty returns true if the ListResult contains no values.
   146  func (lr ListResult) IsEmpty() bool {
   147  	return lr.Value == nil || len(*lr.Value) == 0
   148  }
   149  
   150  // hasNextLink returns true if the NextLink is not empty.
   151  func (lr ListResult) hasNextLink() bool {
   152  	return lr.NextLink != nil && len(*lr.NextLink) != 0
   153  }
   154  
   155  // listResultPreparer prepares a request to retrieve the next set of results.
   156  // It returns nil if no more results exist.
   157  func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
   158  	if !lr.hasNextLink() {
   159  		return nil, nil
   160  	}
   161  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   162  		autorest.AsJSON(),
   163  		autorest.AsGet(),
   164  		autorest.WithBaseURL(to.String(lr.NextLink)))
   165  }
   166  
   167  // ListResultPage contains a page of Subscription values.
   168  type ListResultPage struct {
   169  	fn func(context.Context, ListResult) (ListResult, error)
   170  	lr ListResult
   171  }
   172  
   173  // NextWithContext advances to the next page of values.  If there was an error making
   174  // the request the page does not advance and the error is returned.
   175  func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
   176  	if tracing.IsEnabled() {
   177  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
   178  		defer func() {
   179  			sc := -1
   180  			if page.Response().Response.Response != nil {
   181  				sc = page.Response().Response.Response.StatusCode
   182  			}
   183  			tracing.EndSpan(ctx, sc, err)
   184  		}()
   185  	}
   186  	for {
   187  		next, err := page.fn(ctx, page.lr)
   188  		if err != nil {
   189  			return err
   190  		}
   191  		page.lr = next
   192  		if !next.hasNextLink() || !next.IsEmpty() {
   193  			break
   194  		}
   195  	}
   196  	return nil
   197  }
   198  
   199  // Next advances to the next page of values.  If there was an error making
   200  // the request the page does not advance and the error is returned.
   201  // Deprecated: Use NextWithContext() instead.
   202  func (page *ListResultPage) Next() error {
   203  	return page.NextWithContext(context.Background())
   204  }
   205  
   206  // NotDone returns true if the page enumeration should be started or is not yet complete.
   207  func (page ListResultPage) NotDone() bool {
   208  	return !page.lr.IsEmpty()
   209  }
   210  
   211  // Response returns the raw server response from the last page request.
   212  func (page ListResultPage) Response() ListResult {
   213  	return page.lr
   214  }
   215  
   216  // Values returns the slice of values for the current page or nil if there are no values.
   217  func (page ListResultPage) Values() []Subscription {
   218  	if page.lr.IsEmpty() {
   219  		return nil
   220  	}
   221  	return *page.lr.Value
   222  }
   223  
   224  // Creates a new instance of the ListResultPage type.
   225  func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
   226  	return ListResultPage{
   227  		fn: getNextPage,
   228  		lr: cur,
   229  	}
   230  }
   231  
   232  // Location location information.
   233  type Location struct {
   234  	// ID - READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus.
   235  	ID *string `json:"id,omitempty"`
   236  	// SubscriptionID - READ-ONLY; The subscription ID.
   237  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   238  	// Name - READ-ONLY; The location name.
   239  	Name *string `json:"name,omitempty"`
   240  	// Type - READ-ONLY; The location type. Possible values include: 'LocationTypeRegion', 'LocationTypeEdgeZone'
   241  	Type LocationType `json:"type,omitempty"`
   242  	// DisplayName - READ-ONLY; The display name of the location.
   243  	DisplayName *string `json:"displayName,omitempty"`
   244  	// RegionalDisplayName - READ-ONLY; The display name of the location and its region.
   245  	RegionalDisplayName *string `json:"regionalDisplayName,omitempty"`
   246  	// Metadata - Metadata of the location, such as lat/long, paired region, and others.
   247  	Metadata *LocationMetadata `json:"metadata,omitempty"`
   248  }
   249  
   250  // MarshalJSON is the custom marshaler for Location.
   251  func (l Location) MarshalJSON() ([]byte, error) {
   252  	objectMap := make(map[string]interface{})
   253  	if l.Metadata != nil {
   254  		objectMap["metadata"] = l.Metadata
   255  	}
   256  	return json.Marshal(objectMap)
   257  }
   258  
   259  // LocationListResult location list operation response.
   260  type LocationListResult struct {
   261  	autorest.Response `json:"-"`
   262  	// Value - An array of locations.
   263  	Value *[]Location `json:"value,omitempty"`
   264  }
   265  
   266  // LocationMetadata location metadata information
   267  type LocationMetadata struct {
   268  	// RegionType - READ-ONLY; The type of the region. Possible values include: 'RegionTypePhysical', 'RegionTypeLogical'
   269  	RegionType RegionType `json:"regionType,omitempty"`
   270  	// RegionCategory - READ-ONLY; The category of the region. Possible values include: 'RegionCategoryRecommended', 'RegionCategoryExtended', 'RegionCategoryOther'
   271  	RegionCategory RegionCategory `json:"regionCategory,omitempty"`
   272  	// GeographyGroup - READ-ONLY; The geography group of the location.
   273  	GeographyGroup *string `json:"geographyGroup,omitempty"`
   274  	// Longitude - READ-ONLY; The longitude of the location.
   275  	Longitude *string `json:"longitude,omitempty"`
   276  	// Latitude - READ-ONLY; The latitude of the location.
   277  	Latitude *string `json:"latitude,omitempty"`
   278  	// PhysicalLocation - READ-ONLY; The physical location of the Azure location.
   279  	PhysicalLocation *string `json:"physicalLocation,omitempty"`
   280  	// PairedRegion - The regions paired to this region.
   281  	PairedRegion *[]PairedRegion `json:"pairedRegion,omitempty"`
   282  	// HomeLocation - READ-ONLY; The home location of an edge zone.
   283  	HomeLocation *string `json:"homeLocation,omitempty"`
   284  }
   285  
   286  // MarshalJSON is the custom marshaler for LocationMetadata.
   287  func (lm LocationMetadata) MarshalJSON() ([]byte, error) {
   288  	objectMap := make(map[string]interface{})
   289  	if lm.PairedRegion != nil {
   290  		objectMap["pairedRegion"] = lm.PairedRegion
   291  	}
   292  	return json.Marshal(objectMap)
   293  }
   294  
   295  // ManagedByTenant information about a tenant managing the subscription.
   296  type ManagedByTenant struct {
   297  	// TenantID - READ-ONLY; The tenant ID of the managing tenant. This is a GUID.
   298  	TenantID *string `json:"tenantId,omitempty"`
   299  }
   300  
   301  // MarshalJSON is the custom marshaler for ManagedByTenant.
   302  func (mbt ManagedByTenant) MarshalJSON() ([]byte, error) {
   303  	objectMap := make(map[string]interface{})
   304  	return json.Marshal(objectMap)
   305  }
   306  
   307  // Operation microsoft.Resources operation
   308  type Operation struct {
   309  	// Name - Operation name: {provider}/{resource}/{operation}
   310  	Name *string `json:"name,omitempty"`
   311  	// Display - The object that represents the operation.
   312  	Display *OperationDisplay `json:"display,omitempty"`
   313  }
   314  
   315  // OperationDisplay the object that represents the operation.
   316  type OperationDisplay struct {
   317  	// Provider - Service provider: Microsoft.Resources
   318  	Provider *string `json:"provider,omitempty"`
   319  	// Resource - Resource on which the operation is performed: Profile, endpoint, etc.
   320  	Resource *string `json:"resource,omitempty"`
   321  	// Operation - Operation type: Read, write, delete, etc.
   322  	Operation *string `json:"operation,omitempty"`
   323  	// Description - Description of the operation.
   324  	Description *string `json:"description,omitempty"`
   325  }
   326  
   327  // OperationListResult result of the request to list Microsoft.Resources operations. It contains a list of
   328  // operations and a URL link to get the next set of results.
   329  type OperationListResult struct {
   330  	autorest.Response `json:"-"`
   331  	// Value - List of Microsoft.Resources operations.
   332  	Value *[]Operation `json:"value,omitempty"`
   333  	// NextLink - URL to get the next set of operation list results if there are any.
   334  	NextLink *string `json:"nextLink,omitempty"`
   335  }
   336  
   337  // OperationListResultIterator provides access to a complete listing of Operation values.
   338  type OperationListResultIterator struct {
   339  	i    int
   340  	page OperationListResultPage
   341  }
   342  
   343  // NextWithContext advances to the next value.  If there was an error making
   344  // the request the iterator does not advance and the error is returned.
   345  func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
   346  	if tracing.IsEnabled() {
   347  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
   348  		defer func() {
   349  			sc := -1
   350  			if iter.Response().Response.Response != nil {
   351  				sc = iter.Response().Response.Response.StatusCode
   352  			}
   353  			tracing.EndSpan(ctx, sc, err)
   354  		}()
   355  	}
   356  	iter.i++
   357  	if iter.i < len(iter.page.Values()) {
   358  		return nil
   359  	}
   360  	err = iter.page.NextWithContext(ctx)
   361  	if err != nil {
   362  		iter.i--
   363  		return err
   364  	}
   365  	iter.i = 0
   366  	return nil
   367  }
   368  
   369  // Next advances to the next value.  If there was an error making
   370  // the request the iterator does not advance and the error is returned.
   371  // Deprecated: Use NextWithContext() instead.
   372  func (iter *OperationListResultIterator) Next() error {
   373  	return iter.NextWithContext(context.Background())
   374  }
   375  
   376  // NotDone returns true if the enumeration should be started or is not yet complete.
   377  func (iter OperationListResultIterator) NotDone() bool {
   378  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   379  }
   380  
   381  // Response returns the raw server response from the last page request.
   382  func (iter OperationListResultIterator) Response() OperationListResult {
   383  	return iter.page.Response()
   384  }
   385  
   386  // Value returns the current value or a zero-initialized value if the
   387  // iterator has advanced beyond the end of the collection.
   388  func (iter OperationListResultIterator) Value() Operation {
   389  	if !iter.page.NotDone() {
   390  		return Operation{}
   391  	}
   392  	return iter.page.Values()[iter.i]
   393  }
   394  
   395  // Creates a new instance of the OperationListResultIterator type.
   396  func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
   397  	return OperationListResultIterator{page: page}
   398  }
   399  
   400  // IsEmpty returns true if the ListResult contains no values.
   401  func (olr OperationListResult) IsEmpty() bool {
   402  	return olr.Value == nil || len(*olr.Value) == 0
   403  }
   404  
   405  // hasNextLink returns true if the NextLink is not empty.
   406  func (olr OperationListResult) hasNextLink() bool {
   407  	return olr.NextLink != nil && len(*olr.NextLink) != 0
   408  }
   409  
   410  // operationListResultPreparer prepares a request to retrieve the next set of results.
   411  // It returns nil if no more results exist.
   412  func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
   413  	if !olr.hasNextLink() {
   414  		return nil, nil
   415  	}
   416  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   417  		autorest.AsJSON(),
   418  		autorest.AsGet(),
   419  		autorest.WithBaseURL(to.String(olr.NextLink)))
   420  }
   421  
   422  // OperationListResultPage contains a page of Operation values.
   423  type OperationListResultPage struct {
   424  	fn  func(context.Context, OperationListResult) (OperationListResult, error)
   425  	olr OperationListResult
   426  }
   427  
   428  // NextWithContext advances to the next page of values.  If there was an error making
   429  // the request the page does not advance and the error is returned.
   430  func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
   431  	if tracing.IsEnabled() {
   432  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
   433  		defer func() {
   434  			sc := -1
   435  			if page.Response().Response.Response != nil {
   436  				sc = page.Response().Response.Response.StatusCode
   437  			}
   438  			tracing.EndSpan(ctx, sc, err)
   439  		}()
   440  	}
   441  	for {
   442  		next, err := page.fn(ctx, page.olr)
   443  		if err != nil {
   444  			return err
   445  		}
   446  		page.olr = next
   447  		if !next.hasNextLink() || !next.IsEmpty() {
   448  			break
   449  		}
   450  	}
   451  	return nil
   452  }
   453  
   454  // Next advances to the next page of values.  If there was an error making
   455  // the request the page does not advance and the error is returned.
   456  // Deprecated: Use NextWithContext() instead.
   457  func (page *OperationListResultPage) Next() error {
   458  	return page.NextWithContext(context.Background())
   459  }
   460  
   461  // NotDone returns true if the page enumeration should be started or is not yet complete.
   462  func (page OperationListResultPage) NotDone() bool {
   463  	return !page.olr.IsEmpty()
   464  }
   465  
   466  // Response returns the raw server response from the last page request.
   467  func (page OperationListResultPage) Response() OperationListResult {
   468  	return page.olr
   469  }
   470  
   471  // Values returns the slice of values for the current page or nil if there are no values.
   472  func (page OperationListResultPage) Values() []Operation {
   473  	if page.olr.IsEmpty() {
   474  		return nil
   475  	}
   476  	return *page.olr.Value
   477  }
   478  
   479  // Creates a new instance of the OperationListResultPage type.
   480  func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
   481  	return OperationListResultPage{
   482  		fn:  getNextPage,
   483  		olr: cur,
   484  	}
   485  }
   486  
   487  // PairedRegion information regarding paired region.
   488  type PairedRegion struct {
   489  	// Name - READ-ONLY; The name of the paired region.
   490  	Name *string `json:"name,omitempty"`
   491  	// ID - READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus.
   492  	ID *string `json:"id,omitempty"`
   493  	// SubscriptionID - READ-ONLY; The subscription ID.
   494  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   495  }
   496  
   497  // MarshalJSON is the custom marshaler for PairedRegion.
   498  func (pr PairedRegion) MarshalJSON() ([]byte, error) {
   499  	objectMap := make(map[string]interface{})
   500  	return json.Marshal(objectMap)
   501  }
   502  
   503  // Policies subscription policies.
   504  type Policies struct {
   505  	// LocationPlacementID - READ-ONLY; The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions.
   506  	LocationPlacementID *string `json:"locationPlacementId,omitempty"`
   507  	// QuotaID - READ-ONLY; The subscription quota ID.
   508  	QuotaID *string `json:"quotaId,omitempty"`
   509  	// SpendingLimit - READ-ONLY; The subscription spending limit. Possible values include: 'SpendingLimitOn', 'SpendingLimitOff', 'SpendingLimitCurrentPeriodOff'
   510  	SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
   511  }
   512  
   513  // MarshalJSON is the custom marshaler for Policies.
   514  func (p Policies) MarshalJSON() ([]byte, error) {
   515  	objectMap := make(map[string]interface{})
   516  	return json.Marshal(objectMap)
   517  }
   518  
   519  // ResourceName name and Type of the Resource
   520  type ResourceName struct {
   521  	// Name - Name of the resource
   522  	Name *string `json:"name,omitempty"`
   523  	// Type - The type of the resource
   524  	Type *string `json:"type,omitempty"`
   525  }
   526  
   527  // Subscription subscription information.
   528  type Subscription struct {
   529  	autorest.Response `json:"-"`
   530  	// ID - READ-ONLY; The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000.
   531  	ID *string `json:"id,omitempty"`
   532  	// SubscriptionID - READ-ONLY; The subscription ID.
   533  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   534  	// DisplayName - READ-ONLY; The subscription display name.
   535  	DisplayName *string `json:"displayName,omitempty"`
   536  	// TenantID - READ-ONLY; The subscription tenant ID.
   537  	TenantID *string `json:"tenantId,omitempty"`
   538  	// State - READ-ONLY; The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: 'StateEnabled', 'StateWarned', 'StatePastDue', 'StateDisabled', 'StateDeleted'
   539  	State State `json:"state,omitempty"`
   540  	// SubscriptionPolicies - The subscription policies.
   541  	SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
   542  	// AuthorizationSource - The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'.
   543  	AuthorizationSource *string `json:"authorizationSource,omitempty"`
   544  	// ManagedByTenants - An array containing the tenants managing the subscription.
   545  	ManagedByTenants *[]ManagedByTenant `json:"managedByTenants,omitempty"`
   546  	// Tags - The tags attached to the subscription.
   547  	Tags map[string]*string `json:"tags"`
   548  }
   549  
   550  // MarshalJSON is the custom marshaler for Subscription.
   551  func (s Subscription) MarshalJSON() ([]byte, error) {
   552  	objectMap := make(map[string]interface{})
   553  	if s.SubscriptionPolicies != nil {
   554  		objectMap["subscriptionPolicies"] = s.SubscriptionPolicies
   555  	}
   556  	if s.AuthorizationSource != nil {
   557  		objectMap["authorizationSource"] = s.AuthorizationSource
   558  	}
   559  	if s.ManagedByTenants != nil {
   560  		objectMap["managedByTenants"] = s.ManagedByTenants
   561  	}
   562  	if s.Tags != nil {
   563  		objectMap["tags"] = s.Tags
   564  	}
   565  	return json.Marshal(objectMap)
   566  }
   567  
   568  // TenantIDDescription tenant Id information.
   569  type TenantIDDescription struct {
   570  	// ID - READ-ONLY; The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000.
   571  	ID *string `json:"id,omitempty"`
   572  	// TenantID - READ-ONLY; The tenant ID. For example, 00000000-0000-0000-0000-000000000000.
   573  	TenantID *string `json:"tenantId,omitempty"`
   574  	// TenantCategory - READ-ONLY; Category of the tenant. Possible values include: 'TenantCategoryHome', 'TenantCategoryProjectedBy', 'TenantCategoryManagedBy'
   575  	TenantCategory TenantCategory `json:"tenantCategory,omitempty"`
   576  	// Country - READ-ONLY; Country/region name of the address for the tenant.
   577  	Country *string `json:"country,omitempty"`
   578  	// CountryCode - READ-ONLY; Country/region abbreviation for the tenant.
   579  	CountryCode *string `json:"countryCode,omitempty"`
   580  	// DisplayName - READ-ONLY; The display name of the tenant.
   581  	DisplayName *string `json:"displayName,omitempty"`
   582  	// Domains - READ-ONLY; The list of domains for the tenant.
   583  	Domains *[]string `json:"domains,omitempty"`
   584  	// DefaultDomain - READ-ONLY; The default domain for the tenant.
   585  	DefaultDomain *string `json:"defaultDomain,omitempty"`
   586  	// TenantType - READ-ONLY; The tenant type. Only available for 'Home' tenant category.
   587  	TenantType *string `json:"tenantType,omitempty"`
   588  	// TenantBrandingLogoURL - READ-ONLY; The tenant's branding logo URL. Only available for 'Home' tenant category.
   589  	TenantBrandingLogoURL *string `json:"tenantBrandingLogoUrl,omitempty"`
   590  }
   591  
   592  // MarshalJSON is the custom marshaler for TenantIDDescription.
   593  func (tid TenantIDDescription) MarshalJSON() ([]byte, error) {
   594  	objectMap := make(map[string]interface{})
   595  	return json.Marshal(objectMap)
   596  }
   597  
   598  // TenantListResult tenant Ids information.
   599  type TenantListResult struct {
   600  	autorest.Response `json:"-"`
   601  	// Value - An array of tenants.
   602  	Value *[]TenantIDDescription `json:"value,omitempty"`
   603  	// NextLink - The URL to use for getting the next set of results.
   604  	NextLink *string `json:"nextLink,omitempty"`
   605  }
   606  
   607  // TenantListResultIterator provides access to a complete listing of TenantIDDescription values.
   608  type TenantListResultIterator struct {
   609  	i    int
   610  	page TenantListResultPage
   611  }
   612  
   613  // NextWithContext advances to the next value.  If there was an error making
   614  // the request the iterator does not advance and the error is returned.
   615  func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
   616  	if tracing.IsEnabled() {
   617  		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
   618  		defer func() {
   619  			sc := -1
   620  			if iter.Response().Response.Response != nil {
   621  				sc = iter.Response().Response.Response.StatusCode
   622  			}
   623  			tracing.EndSpan(ctx, sc, err)
   624  		}()
   625  	}
   626  	iter.i++
   627  	if iter.i < len(iter.page.Values()) {
   628  		return nil
   629  	}
   630  	err = iter.page.NextWithContext(ctx)
   631  	if err != nil {
   632  		iter.i--
   633  		return err
   634  	}
   635  	iter.i = 0
   636  	return nil
   637  }
   638  
   639  // Next advances to the next value.  If there was an error making
   640  // the request the iterator does not advance and the error is returned.
   641  // Deprecated: Use NextWithContext() instead.
   642  func (iter *TenantListResultIterator) Next() error {
   643  	return iter.NextWithContext(context.Background())
   644  }
   645  
   646  // NotDone returns true if the enumeration should be started or is not yet complete.
   647  func (iter TenantListResultIterator) NotDone() bool {
   648  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   649  }
   650  
   651  // Response returns the raw server response from the last page request.
   652  func (iter TenantListResultIterator) Response() TenantListResult {
   653  	return iter.page.Response()
   654  }
   655  
   656  // Value returns the current value or a zero-initialized value if the
   657  // iterator has advanced beyond the end of the collection.
   658  func (iter TenantListResultIterator) Value() TenantIDDescription {
   659  	if !iter.page.NotDone() {
   660  		return TenantIDDescription{}
   661  	}
   662  	return iter.page.Values()[iter.i]
   663  }
   664  
   665  // Creates a new instance of the TenantListResultIterator type.
   666  func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
   667  	return TenantListResultIterator{page: page}
   668  }
   669  
   670  // IsEmpty returns true if the ListResult contains no values.
   671  func (tlr TenantListResult) IsEmpty() bool {
   672  	return tlr.Value == nil || len(*tlr.Value) == 0
   673  }
   674  
   675  // hasNextLink returns true if the NextLink is not empty.
   676  func (tlr TenantListResult) hasNextLink() bool {
   677  	return tlr.NextLink != nil && len(*tlr.NextLink) != 0
   678  }
   679  
   680  // tenantListResultPreparer prepares a request to retrieve the next set of results.
   681  // It returns nil if no more results exist.
   682  func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
   683  	if !tlr.hasNextLink() {
   684  		return nil, nil
   685  	}
   686  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   687  		autorest.AsJSON(),
   688  		autorest.AsGet(),
   689  		autorest.WithBaseURL(to.String(tlr.NextLink)))
   690  }
   691  
   692  // TenantListResultPage contains a page of TenantIDDescription values.
   693  type TenantListResultPage struct {
   694  	fn  func(context.Context, TenantListResult) (TenantListResult, error)
   695  	tlr TenantListResult
   696  }
   697  
   698  // NextWithContext advances to the next page of values.  If there was an error making
   699  // the request the page does not advance and the error is returned.
   700  func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
   701  	if tracing.IsEnabled() {
   702  		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
   703  		defer func() {
   704  			sc := -1
   705  			if page.Response().Response.Response != nil {
   706  				sc = page.Response().Response.Response.StatusCode
   707  			}
   708  			tracing.EndSpan(ctx, sc, err)
   709  		}()
   710  	}
   711  	for {
   712  		next, err := page.fn(ctx, page.tlr)
   713  		if err != nil {
   714  			return err
   715  		}
   716  		page.tlr = next
   717  		if !next.hasNextLink() || !next.IsEmpty() {
   718  			break
   719  		}
   720  	}
   721  	return nil
   722  }
   723  
   724  // Next advances to the next page of values.  If there was an error making
   725  // the request the page does not advance and the error is returned.
   726  // Deprecated: Use NextWithContext() instead.
   727  func (page *TenantListResultPage) Next() error {
   728  	return page.NextWithContext(context.Background())
   729  }
   730  
   731  // NotDone returns true if the page enumeration should be started or is not yet complete.
   732  func (page TenantListResultPage) NotDone() bool {
   733  	return !page.tlr.IsEmpty()
   734  }
   735  
   736  // Response returns the raw server response from the last page request.
   737  func (page TenantListResultPage) Response() TenantListResult {
   738  	return page.tlr
   739  }
   740  
   741  // Values returns the slice of values for the current page or nil if there are no values.
   742  func (page TenantListResultPage) Values() []TenantIDDescription {
   743  	if page.tlr.IsEmpty() {
   744  		return nil
   745  	}
   746  	return *page.tlr.Value
   747  }
   748  
   749  // Creates a new instance of the TenantListResultPage type.
   750  func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
   751  	return TenantListResultPage{
   752  		fn:  getNextPage,
   753  		tlr: cur,
   754  	}
   755  }
   756  

View as plain text