...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-06-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-06-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  	// Latitude - READ-ONLY; The latitude of the location.
   217  	Latitude *string `json:"latitude,omitempty"`
   218  	// Longitude - READ-ONLY; The longitude of the location.
   219  	Longitude *string `json:"longitude,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  	return json.Marshal(objectMap)
   226  }
   227  
   228  // LocationListResult location list operation response.
   229  type LocationListResult struct {
   230  	autorest.Response `json:"-"`
   231  	// Value - An array of locations.
   232  	Value *[]Location `json:"value,omitempty"`
   233  }
   234  
   235  // ManagedByTenant information about a tenant managing the subscription.
   236  type ManagedByTenant struct {
   237  	// TenantID - READ-ONLY; The tenant ID of the managing tenant. This is a GUID.
   238  	TenantID *string `json:"tenantId,omitempty"`
   239  }
   240  
   241  // MarshalJSON is the custom marshaler for ManagedByTenant.
   242  func (mbt ManagedByTenant) MarshalJSON() ([]byte, error) {
   243  	objectMap := make(map[string]interface{})
   244  	return json.Marshal(objectMap)
   245  }
   246  
   247  // Operation microsoft.Resources operation
   248  type Operation struct {
   249  	// Name - Operation name: {provider}/{resource}/{operation}
   250  	Name *string `json:"name,omitempty"`
   251  	// Display - The object that represents the operation.
   252  	Display *OperationDisplay `json:"display,omitempty"`
   253  }
   254  
   255  // OperationDisplay the object that represents the operation.
   256  type OperationDisplay struct {
   257  	// Provider - Service provider: Microsoft.Resources
   258  	Provider *string `json:"provider,omitempty"`
   259  	// Resource - Resource on which the operation is performed: Profile, endpoint, etc.
   260  	Resource *string `json:"resource,omitempty"`
   261  	// Operation - Operation type: Read, write, delete, etc.
   262  	Operation *string `json:"operation,omitempty"`
   263  	// Description - Description of the operation.
   264  	Description *string `json:"description,omitempty"`
   265  }
   266  
   267  // OperationListResult result of the request to list Microsoft.Resources operations. It contains a list of
   268  // operations and a URL link to get the next set of results.
   269  type OperationListResult struct {
   270  	autorest.Response `json:"-"`
   271  	// Value - List of Microsoft.Resources operations.
   272  	Value *[]Operation `json:"value,omitempty"`
   273  	// NextLink - URL to get the next set of operation list results if there are any.
   274  	NextLink *string `json:"nextLink,omitempty"`
   275  }
   276  
   277  // OperationListResultIterator provides access to a complete listing of Operation values.
   278  type OperationListResultIterator struct {
   279  	i    int
   280  	page OperationListResultPage
   281  }
   282  
   283  // NextWithContext advances to the next value.  If there was an error making
   284  // the request the iterator does not advance and the error is returned.
   285  func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
   286  	if tracing.IsEnabled() {
   287  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
   288  		defer func() {
   289  			sc := -1
   290  			if iter.Response().Response.Response != nil {
   291  				sc = iter.Response().Response.Response.StatusCode
   292  			}
   293  			tracing.EndSpan(ctx, sc, err)
   294  		}()
   295  	}
   296  	iter.i++
   297  	if iter.i < len(iter.page.Values()) {
   298  		return nil
   299  	}
   300  	err = iter.page.NextWithContext(ctx)
   301  	if err != nil {
   302  		iter.i--
   303  		return err
   304  	}
   305  	iter.i = 0
   306  	return nil
   307  }
   308  
   309  // Next advances to the next value.  If there was an error making
   310  // the request the iterator does not advance and the error is returned.
   311  // Deprecated: Use NextWithContext() instead.
   312  func (iter *OperationListResultIterator) Next() error {
   313  	return iter.NextWithContext(context.Background())
   314  }
   315  
   316  // NotDone returns true if the enumeration should be started or is not yet complete.
   317  func (iter OperationListResultIterator) NotDone() bool {
   318  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   319  }
   320  
   321  // Response returns the raw server response from the last page request.
   322  func (iter OperationListResultIterator) Response() OperationListResult {
   323  	return iter.page.Response()
   324  }
   325  
   326  // Value returns the current value or a zero-initialized value if the
   327  // iterator has advanced beyond the end of the collection.
   328  func (iter OperationListResultIterator) Value() Operation {
   329  	if !iter.page.NotDone() {
   330  		return Operation{}
   331  	}
   332  	return iter.page.Values()[iter.i]
   333  }
   334  
   335  // Creates a new instance of the OperationListResultIterator type.
   336  func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
   337  	return OperationListResultIterator{page: page}
   338  }
   339  
   340  // IsEmpty returns true if the ListResult contains no values.
   341  func (olr OperationListResult) IsEmpty() bool {
   342  	return olr.Value == nil || len(*olr.Value) == 0
   343  }
   344  
   345  // hasNextLink returns true if the NextLink is not empty.
   346  func (olr OperationListResult) hasNextLink() bool {
   347  	return olr.NextLink != nil && len(*olr.NextLink) != 0
   348  }
   349  
   350  // operationListResultPreparer prepares a request to retrieve the next set of results.
   351  // It returns nil if no more results exist.
   352  func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
   353  	if !olr.hasNextLink() {
   354  		return nil, nil
   355  	}
   356  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   357  		autorest.AsJSON(),
   358  		autorest.AsGet(),
   359  		autorest.WithBaseURL(to.String(olr.NextLink)))
   360  }
   361  
   362  // OperationListResultPage contains a page of Operation values.
   363  type OperationListResultPage struct {
   364  	fn  func(context.Context, OperationListResult) (OperationListResult, error)
   365  	olr OperationListResult
   366  }
   367  
   368  // NextWithContext advances to the next page of values.  If there was an error making
   369  // the request the page does not advance and the error is returned.
   370  func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
   371  	if tracing.IsEnabled() {
   372  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
   373  		defer func() {
   374  			sc := -1
   375  			if page.Response().Response.Response != nil {
   376  				sc = page.Response().Response.Response.StatusCode
   377  			}
   378  			tracing.EndSpan(ctx, sc, err)
   379  		}()
   380  	}
   381  	for {
   382  		next, err := page.fn(ctx, page.olr)
   383  		if err != nil {
   384  			return err
   385  		}
   386  		page.olr = next
   387  		if !next.hasNextLink() || !next.IsEmpty() {
   388  			break
   389  		}
   390  	}
   391  	return nil
   392  }
   393  
   394  // Next advances to the next page of values.  If there was an error making
   395  // the request the page does not advance and the error is returned.
   396  // Deprecated: Use NextWithContext() instead.
   397  func (page *OperationListResultPage) Next() error {
   398  	return page.NextWithContext(context.Background())
   399  }
   400  
   401  // NotDone returns true if the page enumeration should be started or is not yet complete.
   402  func (page OperationListResultPage) NotDone() bool {
   403  	return !page.olr.IsEmpty()
   404  }
   405  
   406  // Response returns the raw server response from the last page request.
   407  func (page OperationListResultPage) Response() OperationListResult {
   408  	return page.olr
   409  }
   410  
   411  // Values returns the slice of values for the current page or nil if there are no values.
   412  func (page OperationListResultPage) Values() []Operation {
   413  	if page.olr.IsEmpty() {
   414  		return nil
   415  	}
   416  	return *page.olr.Value
   417  }
   418  
   419  // Creates a new instance of the OperationListResultPage type.
   420  func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
   421  	return OperationListResultPage{
   422  		fn:  getNextPage,
   423  		olr: cur,
   424  	}
   425  }
   426  
   427  // Policies subscription policies.
   428  type Policies struct {
   429  	// 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.
   430  	LocationPlacementID *string `json:"locationPlacementId,omitempty"`
   431  	// QuotaID - READ-ONLY; The subscription quota ID.
   432  	QuotaID *string `json:"quotaId,omitempty"`
   433  	// SpendingLimit - READ-ONLY; The subscription spending limit. Possible values include: 'On', 'Off', 'CurrentPeriodOff'
   434  	SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
   435  }
   436  
   437  // MarshalJSON is the custom marshaler for Policies.
   438  func (p Policies) MarshalJSON() ([]byte, error) {
   439  	objectMap := make(map[string]interface{})
   440  	return json.Marshal(objectMap)
   441  }
   442  
   443  // ResourceName name and Type of the Resource
   444  type ResourceName struct {
   445  	// Name - Name of the resource
   446  	Name *string `json:"name,omitempty"`
   447  	// Type - The type of the resource
   448  	Type *string `json:"type,omitempty"`
   449  }
   450  
   451  // Subscription subscription information.
   452  type Subscription struct {
   453  	autorest.Response `json:"-"`
   454  	// ID - READ-ONLY; The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000.
   455  	ID *string `json:"id,omitempty"`
   456  	// SubscriptionID - READ-ONLY; The subscription ID.
   457  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   458  	// DisplayName - READ-ONLY; The subscription display name.
   459  	DisplayName *string `json:"displayName,omitempty"`
   460  	// TenantID - READ-ONLY; The subscription tenant ID.
   461  	TenantID *string `json:"tenantId,omitempty"`
   462  	// State - READ-ONLY; The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted'
   463  	State State `json:"state,omitempty"`
   464  	// SubscriptionPolicies - The subscription policies.
   465  	SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
   466  	// 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'.
   467  	AuthorizationSource *string `json:"authorizationSource,omitempty"`
   468  	// ManagedByTenants - An array containing the tenants managing the subscription.
   469  	ManagedByTenants *[]ManagedByTenant `json:"managedByTenants,omitempty"`
   470  }
   471  
   472  // MarshalJSON is the custom marshaler for Subscription.
   473  func (s Subscription) MarshalJSON() ([]byte, error) {
   474  	objectMap := make(map[string]interface{})
   475  	if s.SubscriptionPolicies != nil {
   476  		objectMap["subscriptionPolicies"] = s.SubscriptionPolicies
   477  	}
   478  	if s.AuthorizationSource != nil {
   479  		objectMap["authorizationSource"] = s.AuthorizationSource
   480  	}
   481  	if s.ManagedByTenants != nil {
   482  		objectMap["managedByTenants"] = s.ManagedByTenants
   483  	}
   484  	return json.Marshal(objectMap)
   485  }
   486  
   487  // TenantIDDescription tenant Id information.
   488  type TenantIDDescription struct {
   489  	// ID - READ-ONLY; The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000.
   490  	ID *string `json:"id,omitempty"`
   491  	// TenantID - READ-ONLY; The tenant ID. For example, 00000000-0000-0000-0000-000000000000.
   492  	TenantID *string `json:"tenantId,omitempty"`
   493  	// TenantCategory - READ-ONLY; The tenant category. Possible values include: 'Home', 'ProjectedBy', 'ManagedBy'
   494  	TenantCategory TenantCategory `json:"tenantCategory,omitempty"`
   495  	// Country - READ-ONLY; Country/region name of the address for the tenant.
   496  	Country *string `json:"country,omitempty"`
   497  	// CountryCode - READ-ONLY; Country/region abbreviation for the tenant.
   498  	CountryCode *string `json:"countryCode,omitempty"`
   499  	// DisplayName - READ-ONLY; The display name of the tenant.
   500  	DisplayName *string `json:"displayName,omitempty"`
   501  	// Domains - READ-ONLY; The list of domains for the tenant.
   502  	Domains *[]string `json:"domains,omitempty"`
   503  }
   504  
   505  // MarshalJSON is the custom marshaler for TenantIDDescription.
   506  func (tid TenantIDDescription) MarshalJSON() ([]byte, error) {
   507  	objectMap := make(map[string]interface{})
   508  	return json.Marshal(objectMap)
   509  }
   510  
   511  // TenantListResult tenant Ids information.
   512  type TenantListResult struct {
   513  	autorest.Response `json:"-"`
   514  	// Value - An array of tenants.
   515  	Value *[]TenantIDDescription `json:"value,omitempty"`
   516  	// NextLink - The URL to use for getting the next set of results.
   517  	NextLink *string `json:"nextLink,omitempty"`
   518  }
   519  
   520  // TenantListResultIterator provides access to a complete listing of TenantIDDescription values.
   521  type TenantListResultIterator struct {
   522  	i    int
   523  	page TenantListResultPage
   524  }
   525  
   526  // NextWithContext advances to the next value.  If there was an error making
   527  // the request the iterator does not advance and the error is returned.
   528  func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
   529  	if tracing.IsEnabled() {
   530  		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
   531  		defer func() {
   532  			sc := -1
   533  			if iter.Response().Response.Response != nil {
   534  				sc = iter.Response().Response.Response.StatusCode
   535  			}
   536  			tracing.EndSpan(ctx, sc, err)
   537  		}()
   538  	}
   539  	iter.i++
   540  	if iter.i < len(iter.page.Values()) {
   541  		return nil
   542  	}
   543  	err = iter.page.NextWithContext(ctx)
   544  	if err != nil {
   545  		iter.i--
   546  		return err
   547  	}
   548  	iter.i = 0
   549  	return nil
   550  }
   551  
   552  // Next advances to the next value.  If there was an error making
   553  // the request the iterator does not advance and the error is returned.
   554  // Deprecated: Use NextWithContext() instead.
   555  func (iter *TenantListResultIterator) Next() error {
   556  	return iter.NextWithContext(context.Background())
   557  }
   558  
   559  // NotDone returns true if the enumeration should be started or is not yet complete.
   560  func (iter TenantListResultIterator) NotDone() bool {
   561  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   562  }
   563  
   564  // Response returns the raw server response from the last page request.
   565  func (iter TenantListResultIterator) Response() TenantListResult {
   566  	return iter.page.Response()
   567  }
   568  
   569  // Value returns the current value or a zero-initialized value if the
   570  // iterator has advanced beyond the end of the collection.
   571  func (iter TenantListResultIterator) Value() TenantIDDescription {
   572  	if !iter.page.NotDone() {
   573  		return TenantIDDescription{}
   574  	}
   575  	return iter.page.Values()[iter.i]
   576  }
   577  
   578  // Creates a new instance of the TenantListResultIterator type.
   579  func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
   580  	return TenantListResultIterator{page: page}
   581  }
   582  
   583  // IsEmpty returns true if the ListResult contains no values.
   584  func (tlr TenantListResult) IsEmpty() bool {
   585  	return tlr.Value == nil || len(*tlr.Value) == 0
   586  }
   587  
   588  // hasNextLink returns true if the NextLink is not empty.
   589  func (tlr TenantListResult) hasNextLink() bool {
   590  	return tlr.NextLink != nil && len(*tlr.NextLink) != 0
   591  }
   592  
   593  // tenantListResultPreparer prepares a request to retrieve the next set of results.
   594  // It returns nil if no more results exist.
   595  func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
   596  	if !tlr.hasNextLink() {
   597  		return nil, nil
   598  	}
   599  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   600  		autorest.AsJSON(),
   601  		autorest.AsGet(),
   602  		autorest.WithBaseURL(to.String(tlr.NextLink)))
   603  }
   604  
   605  // TenantListResultPage contains a page of TenantIDDescription values.
   606  type TenantListResultPage struct {
   607  	fn  func(context.Context, TenantListResult) (TenantListResult, error)
   608  	tlr TenantListResult
   609  }
   610  
   611  // NextWithContext advances to the next page of values.  If there was an error making
   612  // the request the page does not advance and the error is returned.
   613  func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
   614  	if tracing.IsEnabled() {
   615  		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
   616  		defer func() {
   617  			sc := -1
   618  			if page.Response().Response.Response != nil {
   619  				sc = page.Response().Response.Response.StatusCode
   620  			}
   621  			tracing.EndSpan(ctx, sc, err)
   622  		}()
   623  	}
   624  	for {
   625  		next, err := page.fn(ctx, page.tlr)
   626  		if err != nil {
   627  			return err
   628  		}
   629  		page.tlr = next
   630  		if !next.hasNextLink() || !next.IsEmpty() {
   631  			break
   632  		}
   633  	}
   634  	return nil
   635  }
   636  
   637  // Next advances to the next page of values.  If there was an error making
   638  // the request the page does not advance and the error is returned.
   639  // Deprecated: Use NextWithContext() instead.
   640  func (page *TenantListResultPage) Next() error {
   641  	return page.NextWithContext(context.Background())
   642  }
   643  
   644  // NotDone returns true if the page enumeration should be started or is not yet complete.
   645  func (page TenantListResultPage) NotDone() bool {
   646  	return !page.tlr.IsEmpty()
   647  }
   648  
   649  // Response returns the raw server response from the last page request.
   650  func (page TenantListResultPage) Response() TenantListResult {
   651  	return page.tlr
   652  }
   653  
   654  // Values returns the slice of values for the current page or nil if there are no values.
   655  func (page TenantListResultPage) Values() []TenantIDDescription {
   656  	if page.tlr.IsEmpty() {
   657  		return nil
   658  	}
   659  	return *page.tlr.Value
   660  }
   661  
   662  // Creates a new instance of the TenantListResultPage type.
   663  func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
   664  	return TenantListResultPage{
   665  		fn:  getNextPage,
   666  		tlr: cur,
   667  	}
   668  }
   669  

View as plain text