...

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

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

View as plain text