...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-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  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/to"
    13  	"github.com/Azure/go-autorest/tracing"
    14  	"net/http"
    15  )
    16  
    17  // The package's fully qualified name.
    18  const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-11-01/subscriptions"
    19  
    20  // CheckResourceNameResult resource Name valid if not a reserved word, does not contain a reserved word and
    21  // does not start with a reserved word
    22  type CheckResourceNameResult struct {
    23  	autorest.Response `json:"-"`
    24  	// Name - Name of Resource
    25  	Name *string `json:"name,omitempty"`
    26  	// Type - Type of Resource
    27  	Type *string `json:"type,omitempty"`
    28  	// Status - Is the resource name Allowed or Reserved. Possible values include: 'Allowed', 'Reserved'
    29  	Status ResourceNameStatus `json:"status,omitempty"`
    30  }
    31  
    32  // ErrorDefinition error description and code explaining why resource name is invalid.
    33  type ErrorDefinition struct {
    34  	// Message - Description of the error.
    35  	Message *string `json:"message,omitempty"`
    36  	// Code - Code of the error.
    37  	Code *string `json:"code,omitempty"`
    38  }
    39  
    40  // ErrorResponse error response.
    41  type ErrorResponse struct {
    42  	// Error - The error details.
    43  	Error *ErrorDefinition `json:"error,omitempty"`
    44  }
    45  
    46  // ListResult subscription list operation response.
    47  type ListResult struct {
    48  	autorest.Response `json:"-"`
    49  	// Value - Gets or sets subscriptions.
    50  	Value *[]Subscription `json:"value,omitempty"`
    51  	// NextLink - Gets or sets the URL to get the next set of results.
    52  	NextLink *string `json:"nextLink,omitempty"`
    53  }
    54  
    55  // ListResultIterator provides access to a complete listing of Subscription values.
    56  type ListResultIterator struct {
    57  	i    int
    58  	page ListResultPage
    59  }
    60  
    61  // NextWithContext advances to the next value.  If there was an error making
    62  // the request the iterator does not advance and the error is returned.
    63  func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
    64  	if tracing.IsEnabled() {
    65  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
    66  		defer func() {
    67  			sc := -1
    68  			if iter.Response().Response.Response != nil {
    69  				sc = iter.Response().Response.Response.StatusCode
    70  			}
    71  			tracing.EndSpan(ctx, sc, err)
    72  		}()
    73  	}
    74  	iter.i++
    75  	if iter.i < len(iter.page.Values()) {
    76  		return nil
    77  	}
    78  	err = iter.page.NextWithContext(ctx)
    79  	if err != nil {
    80  		iter.i--
    81  		return err
    82  	}
    83  	iter.i = 0
    84  	return nil
    85  }
    86  
    87  // Next advances to the next value.  If there was an error making
    88  // the request the iterator does not advance and the error is returned.
    89  // Deprecated: Use NextWithContext() instead.
    90  func (iter *ListResultIterator) Next() error {
    91  	return iter.NextWithContext(context.Background())
    92  }
    93  
    94  // NotDone returns true if the enumeration should be started or is not yet complete.
    95  func (iter ListResultIterator) NotDone() bool {
    96  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
    97  }
    98  
    99  // Response returns the raw server response from the last page request.
   100  func (iter ListResultIterator) Response() ListResult {
   101  	return iter.page.Response()
   102  }
   103  
   104  // Value returns the current value or a zero-initialized value if the
   105  // iterator has advanced beyond the end of the collection.
   106  func (iter ListResultIterator) Value() Subscription {
   107  	if !iter.page.NotDone() {
   108  		return Subscription{}
   109  	}
   110  	return iter.page.Values()[iter.i]
   111  }
   112  
   113  // Creates a new instance of the ListResultIterator type.
   114  func NewListResultIterator(page ListResultPage) ListResultIterator {
   115  	return ListResultIterator{page: page}
   116  }
   117  
   118  // IsEmpty returns true if the ListResult contains no values.
   119  func (lr ListResult) IsEmpty() bool {
   120  	return lr.Value == nil || len(*lr.Value) == 0
   121  }
   122  
   123  // hasNextLink returns true if the NextLink is not empty.
   124  func (lr ListResult) hasNextLink() bool {
   125  	return lr.NextLink != nil && len(*lr.NextLink) != 0
   126  }
   127  
   128  // listResultPreparer prepares a request to retrieve the next set of results.
   129  // It returns nil if no more results exist.
   130  func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
   131  	if !lr.hasNextLink() {
   132  		return nil, nil
   133  	}
   134  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   135  		autorest.AsJSON(),
   136  		autorest.AsGet(),
   137  		autorest.WithBaseURL(to.String(lr.NextLink)))
   138  }
   139  
   140  // ListResultPage contains a page of Subscription values.
   141  type ListResultPage struct {
   142  	fn func(context.Context, ListResult) (ListResult, error)
   143  	lr ListResult
   144  }
   145  
   146  // NextWithContext advances to the next page of values.  If there was an error making
   147  // the request the page does not advance and the error is returned.
   148  func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
   149  	if tracing.IsEnabled() {
   150  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
   151  		defer func() {
   152  			sc := -1
   153  			if page.Response().Response.Response != nil {
   154  				sc = page.Response().Response.Response.StatusCode
   155  			}
   156  			tracing.EndSpan(ctx, sc, err)
   157  		}()
   158  	}
   159  	for {
   160  		next, err := page.fn(ctx, page.lr)
   161  		if err != nil {
   162  			return err
   163  		}
   164  		page.lr = next
   165  		if !next.hasNextLink() || !next.IsEmpty() {
   166  			break
   167  		}
   168  	}
   169  	return nil
   170  }
   171  
   172  // Next advances to the next page of values.  If there was an error making
   173  // the request the page does not advance and the error is returned.
   174  // Deprecated: Use NextWithContext() instead.
   175  func (page *ListResultPage) Next() error {
   176  	return page.NextWithContext(context.Background())
   177  }
   178  
   179  // NotDone returns true if the page enumeration should be started or is not yet complete.
   180  func (page ListResultPage) NotDone() bool {
   181  	return !page.lr.IsEmpty()
   182  }
   183  
   184  // Response returns the raw server response from the last page request.
   185  func (page ListResultPage) Response() ListResult {
   186  	return page.lr
   187  }
   188  
   189  // Values returns the slice of values for the current page or nil if there are no values.
   190  func (page ListResultPage) Values() []Subscription {
   191  	if page.lr.IsEmpty() {
   192  		return nil
   193  	}
   194  	return *page.lr.Value
   195  }
   196  
   197  // Creates a new instance of the ListResultPage type.
   198  func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
   199  	return ListResultPage{
   200  		fn: getNextPage,
   201  		lr: cur,
   202  	}
   203  }
   204  
   205  // Location location information.
   206  type Location struct {
   207  	// ID - Gets or sets the ID of the resource (/subscriptions/SubscriptionId).
   208  	ID *string `json:"id,omitempty"`
   209  	// SubscriptionID - Gets or sets the subscription Id.
   210  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   211  	// Name - Gets or sets the location name
   212  	Name *string `json:"name,omitempty"`
   213  	// DisplayName - Gets or sets the display name of the location
   214  	DisplayName *string `json:"displayName,omitempty"`
   215  	// Latitude - Gets or sets the latitude of the location
   216  	Latitude *string `json:"latitude,omitempty"`
   217  	// Longitude - Gets or sets the longitude of the location
   218  	Longitude *string `json:"longitude,omitempty"`
   219  }
   220  
   221  // LocationListResult location list operation response.
   222  type LocationListResult struct {
   223  	autorest.Response `json:"-"`
   224  	// Value - Gets the locations.
   225  	Value *[]Location `json:"value,omitempty"`
   226  }
   227  
   228  // Policies subscription policies.
   229  type Policies struct {
   230  	// LocationPlacementID - Gets or sets the subscription location placement Id.
   231  	LocationPlacementID *string `json:"locationPlacementId,omitempty"`
   232  	// QuotaID - Gets or sets the subscription quota Id.
   233  	QuotaID *string `json:"quotaId,omitempty"`
   234  }
   235  
   236  // ResourceName name and Type of the Resource
   237  type ResourceName struct {
   238  	// Name - Name of the resource
   239  	Name *string `json:"name,omitempty"`
   240  	// Type - The type of the resource
   241  	Type *string `json:"type,omitempty"`
   242  }
   243  
   244  // Subscription subscription information.
   245  type Subscription struct {
   246  	autorest.Response `json:"-"`
   247  	// ID - Gets or sets the ID of the resource (/subscriptions/SubscriptionId).
   248  	ID *string `json:"id,omitempty"`
   249  	// SubscriptionID - Gets or sets the subscription Id.
   250  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   251  	// DisplayName - Gets or sets the subscription display name
   252  	DisplayName *string `json:"displayName,omitempty"`
   253  	// State - Gets or sets the subscription state
   254  	State *string `json:"state,omitempty"`
   255  	// SubscriptionPolicies - Gets or sets the subscription policies.
   256  	SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
   257  }
   258  
   259  // TenantIDDescription tenant Id information
   260  type TenantIDDescription struct {
   261  	// ID - Gets or sets Id
   262  	ID *string `json:"id,omitempty"`
   263  	// TenantID - Gets or sets tenantId
   264  	TenantID *string `json:"tenantId,omitempty"`
   265  }
   266  
   267  // TenantListResult tenant Ids information.
   268  type TenantListResult struct {
   269  	autorest.Response `json:"-"`
   270  	// Value - Gets or sets tenant Ids.
   271  	Value *[]TenantIDDescription `json:"value,omitempty"`
   272  	// NextLink - Gets or sets the URL to get the next set of results.
   273  	NextLink *string `json:"nextLink,omitempty"`
   274  }
   275  
   276  // TenantListResultIterator provides access to a complete listing of TenantIDDescription values.
   277  type TenantListResultIterator struct {
   278  	i    int
   279  	page TenantListResultPage
   280  }
   281  
   282  // NextWithContext advances to the next value.  If there was an error making
   283  // the request the iterator does not advance and the error is returned.
   284  func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
   285  	if tracing.IsEnabled() {
   286  		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
   287  		defer func() {
   288  			sc := -1
   289  			if iter.Response().Response.Response != nil {
   290  				sc = iter.Response().Response.Response.StatusCode
   291  			}
   292  			tracing.EndSpan(ctx, sc, err)
   293  		}()
   294  	}
   295  	iter.i++
   296  	if iter.i < len(iter.page.Values()) {
   297  		return nil
   298  	}
   299  	err = iter.page.NextWithContext(ctx)
   300  	if err != nil {
   301  		iter.i--
   302  		return err
   303  	}
   304  	iter.i = 0
   305  	return nil
   306  }
   307  
   308  // Next advances to the next value.  If there was an error making
   309  // the request the iterator does not advance and the error is returned.
   310  // Deprecated: Use NextWithContext() instead.
   311  func (iter *TenantListResultIterator) Next() error {
   312  	return iter.NextWithContext(context.Background())
   313  }
   314  
   315  // NotDone returns true if the enumeration should be started or is not yet complete.
   316  func (iter TenantListResultIterator) NotDone() bool {
   317  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   318  }
   319  
   320  // Response returns the raw server response from the last page request.
   321  func (iter TenantListResultIterator) Response() TenantListResult {
   322  	return iter.page.Response()
   323  }
   324  
   325  // Value returns the current value or a zero-initialized value if the
   326  // iterator has advanced beyond the end of the collection.
   327  func (iter TenantListResultIterator) Value() TenantIDDescription {
   328  	if !iter.page.NotDone() {
   329  		return TenantIDDescription{}
   330  	}
   331  	return iter.page.Values()[iter.i]
   332  }
   333  
   334  // Creates a new instance of the TenantListResultIterator type.
   335  func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
   336  	return TenantListResultIterator{page: page}
   337  }
   338  
   339  // IsEmpty returns true if the ListResult contains no values.
   340  func (tlr TenantListResult) IsEmpty() bool {
   341  	return tlr.Value == nil || len(*tlr.Value) == 0
   342  }
   343  
   344  // hasNextLink returns true if the NextLink is not empty.
   345  func (tlr TenantListResult) hasNextLink() bool {
   346  	return tlr.NextLink != nil && len(*tlr.NextLink) != 0
   347  }
   348  
   349  // tenantListResultPreparer prepares a request to retrieve the next set of results.
   350  // It returns nil if no more results exist.
   351  func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
   352  	if !tlr.hasNextLink() {
   353  		return nil, nil
   354  	}
   355  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   356  		autorest.AsJSON(),
   357  		autorest.AsGet(),
   358  		autorest.WithBaseURL(to.String(tlr.NextLink)))
   359  }
   360  
   361  // TenantListResultPage contains a page of TenantIDDescription values.
   362  type TenantListResultPage struct {
   363  	fn  func(context.Context, TenantListResult) (TenantListResult, error)
   364  	tlr TenantListResult
   365  }
   366  
   367  // NextWithContext advances to the next page of values.  If there was an error making
   368  // the request the page does not advance and the error is returned.
   369  func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
   370  	if tracing.IsEnabled() {
   371  		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
   372  		defer func() {
   373  			sc := -1
   374  			if page.Response().Response.Response != nil {
   375  				sc = page.Response().Response.Response.StatusCode
   376  			}
   377  			tracing.EndSpan(ctx, sc, err)
   378  		}()
   379  	}
   380  	for {
   381  		next, err := page.fn(ctx, page.tlr)
   382  		if err != nil {
   383  			return err
   384  		}
   385  		page.tlr = next
   386  		if !next.hasNextLink() || !next.IsEmpty() {
   387  			break
   388  		}
   389  	}
   390  	return nil
   391  }
   392  
   393  // Next advances to the next page of values.  If there was an error making
   394  // the request the page does not advance and the error is returned.
   395  // Deprecated: Use NextWithContext() instead.
   396  func (page *TenantListResultPage) Next() error {
   397  	return page.NextWithContext(context.Background())
   398  }
   399  
   400  // NotDone returns true if the page enumeration should be started or is not yet complete.
   401  func (page TenantListResultPage) NotDone() bool {
   402  	return !page.tlr.IsEmpty()
   403  }
   404  
   405  // Response returns the raw server response from the last page request.
   406  func (page TenantListResultPage) Response() TenantListResult {
   407  	return page.tlr
   408  }
   409  
   410  // Values returns the slice of values for the current page or nil if there are no values.
   411  func (page TenantListResultPage) Values() []TenantIDDescription {
   412  	if page.tlr.IsEmpty() {
   413  		return nil
   414  	}
   415  	return *page.tlr.Value
   416  }
   417  
   418  // Creates a new instance of the TenantListResultPage type.
   419  func NewTenantListResultPage(cur TenantListResult, getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
   420  	return TenantListResultPage{
   421  		fn:  getNextPage,
   422  		tlr: cur,
   423  	}
   424  }
   425  

View as plain text