1package subscription
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/azure"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"net/http"
28)
29
30// The package's fully qualified name.
31const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/subscription/mgmt/2019-10-01-preview/subscription"
32
33// OfferType enumerates the values for offer type.
34type OfferType string
35
36const (
37	// MSAZR0017P ...
38	MSAZR0017P OfferType = "MS-AZR-0017P"
39	// MSAZR0148P ...
40	MSAZR0148P OfferType = "MS-AZR-0148P"
41)
42
43// PossibleOfferTypeValues returns an array of possible values for the OfferType const type.
44func PossibleOfferTypeValues() []OfferType {
45	return []OfferType{MSAZR0017P, MSAZR0148P}
46}
47
48// SpendingLimit enumerates the values for spending limit.
49type SpendingLimit string
50
51const (
52	// CurrentPeriodOff ...
53	CurrentPeriodOff SpendingLimit = "CurrentPeriodOff"
54	// Off ...
55	Off SpendingLimit = "Off"
56	// On ...
57	On SpendingLimit = "On"
58)
59
60// PossibleSpendingLimitValues returns an array of possible values for the SpendingLimit const type.
61func PossibleSpendingLimitValues() []SpendingLimit {
62	return []SpendingLimit{CurrentPeriodOff, Off, On}
63}
64
65// State enumerates the values for state.
66type State string
67
68const (
69	// Deleted ...
70	Deleted State = "Deleted"
71	// Disabled ...
72	Disabled State = "Disabled"
73	// Enabled ...
74	Enabled State = "Enabled"
75	// PastDue ...
76	PastDue State = "PastDue"
77	// Warned ...
78	Warned State = "Warned"
79)
80
81// PossibleStateValues returns an array of possible values for the State const type.
82func PossibleStateValues() []State {
83	return []State{Deleted, Disabled, Enabled, PastDue, Warned}
84}
85
86// AdPrincipal active Directory Principal who’ll get owner access on the new subscription.
87type AdPrincipal struct {
88	// ObjectID - Object id of the Principal
89	ObjectID *string `json:"objectId,omitempty"`
90}
91
92// CanceledSubscriptionID the ID of the canceled subscription
93type CanceledSubscriptionID struct {
94	autorest.Response `json:"-"`
95	// Value - READ-ONLY; The ID of the canceled subscription
96	Value *string `json:"value,omitempty"`
97}
98
99// CreateCspSubscriptionFuture an abstraction for monitoring and retrieving the results of a long-running
100// operation.
101type CreateCspSubscriptionFuture struct {
102	azure.Future
103}
104
105// Result returns the result of the asynchronous operation.
106// If the operation has not completed it will return an error.
107func (future *CreateCspSubscriptionFuture) Result(client Client) (cr CreationResult, err error) {
108	var done bool
109	done, err = future.DoneWithContext(context.Background(), client)
110	if err != nil {
111		err = autorest.NewErrorWithError(err, "subscription.CreateCspSubscriptionFuture", "Result", future.Response(), "Polling failure")
112		return
113	}
114	if !done {
115		err = azure.NewAsyncOpIncompleteError("subscription.CreateCspSubscriptionFuture")
116		return
117	}
118	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
119	if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent {
120		cr, err = client.CreateCspSubscriptionResponder(cr.Response.Response)
121		if err != nil {
122			err = autorest.NewErrorWithError(err, "subscription.CreateCspSubscriptionFuture", "Result", cr.Response.Response, "Failure responding to request")
123		}
124	}
125	return
126}
127
128// CreateSubscriptionFuture an abstraction for monitoring and retrieving the results of a long-running
129// operation.
130type CreateSubscriptionFuture struct {
131	azure.Future
132}
133
134// Result returns the result of the asynchronous operation.
135// If the operation has not completed it will return an error.
136func (future *CreateSubscriptionFuture) Result(client Client) (cr CreationResult, err error) {
137	var done bool
138	done, err = future.DoneWithContext(context.Background(), client)
139	if err != nil {
140		err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionFuture", "Result", future.Response(), "Polling failure")
141		return
142	}
143	if !done {
144		err = azure.NewAsyncOpIncompleteError("subscription.CreateSubscriptionFuture")
145		return
146	}
147	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
148	if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent {
149		cr, err = client.CreateSubscriptionResponder(cr.Response.Response)
150		if err != nil {
151			err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionFuture", "Result", cr.Response.Response, "Failure responding to request")
152		}
153	}
154	return
155}
156
157// CreateSubscriptionInEnrollmentAccountFuture an abstraction for monitoring and retrieving the results of
158// a long-running operation.
159type CreateSubscriptionInEnrollmentAccountFuture struct {
160	azure.Future
161}
162
163// Result returns the result of the asynchronous operation.
164// If the operation has not completed it will return an error.
165func (future *CreateSubscriptionInEnrollmentAccountFuture) Result(client Client) (cr CreationResult, err error) {
166	var done bool
167	done, err = future.DoneWithContext(context.Background(), client)
168	if err != nil {
169		err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionInEnrollmentAccountFuture", "Result", future.Response(), "Polling failure")
170		return
171	}
172	if !done {
173		err = azure.NewAsyncOpIncompleteError("subscription.CreateSubscriptionInEnrollmentAccountFuture")
174		return
175	}
176	sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
177	if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent {
178		cr, err = client.CreateSubscriptionInEnrollmentAccountResponder(cr.Response.Response)
179		if err != nil {
180			err = autorest.NewErrorWithError(err, "subscription.CreateSubscriptionInEnrollmentAccountFuture", "Result", cr.Response.Response, "Failure responding to request")
181		}
182	}
183	return
184}
185
186// CreationParameters subscription Creation Parameters required to create a new Azure subscription.
187type CreationParameters struct {
188	// DisplayName - The display name of the subscription.
189	DisplayName *string `json:"displayName,omitempty"`
190	// ManagementGroupID - The Management Group Id.
191	ManagementGroupID *string `json:"managementGroupId,omitempty"`
192	// Owners - The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.
193	Owners *[]AdPrincipal `json:"owners,omitempty"`
194	// OfferType - The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope. Possible values include: 'MSAZR0017P', 'MSAZR0148P'
195	OfferType OfferType `json:"offerType,omitempty"`
196	// AdditionalParameters - Additional, untyped parameters to support custom subscription creation scenarios.
197	AdditionalParameters map[string]interface{} `json:"additionalParameters"`
198}
199
200// MarshalJSON is the custom marshaler for CreationParameters.
201func (cp CreationParameters) MarshalJSON() ([]byte, error) {
202	objectMap := make(map[string]interface{})
203	if cp.DisplayName != nil {
204		objectMap["displayName"] = cp.DisplayName
205	}
206	if cp.ManagementGroupID != nil {
207		objectMap["managementGroupId"] = cp.ManagementGroupID
208	}
209	if cp.Owners != nil {
210		objectMap["owners"] = cp.Owners
211	}
212	if cp.OfferType != "" {
213		objectMap["offerType"] = cp.OfferType
214	}
215	if cp.AdditionalParameters != nil {
216		objectMap["additionalParameters"] = cp.AdditionalParameters
217	}
218	return json.Marshal(objectMap)
219}
220
221// CreationResult the created subscription object.
222type CreationResult struct {
223	autorest.Response `json:"-"`
224	// SubscriptionLink - The link to the new subscription. Use this link to check the status of subscription creation operation.
225	SubscriptionLink *string `json:"subscriptionLink,omitempty"`
226}
227
228// EnabledSubscriptionID the ID of the subscriptions that is being enabled
229type EnabledSubscriptionID struct {
230	autorest.Response `json:"-"`
231	// Value - READ-ONLY; The ID of the subscriptions that is being enabled
232	Value *string `json:"value,omitempty"`
233}
234
235// ErrorResponse describes the format of Error response.
236type ErrorResponse struct {
237	// Code - Error code
238	Code *string `json:"code,omitempty"`
239	// Message - Error message indicating why the operation failed.
240	Message *string `json:"message,omitempty"`
241}
242
243// ListResult subscription list operation response.
244type ListResult struct {
245	autorest.Response `json:"-"`
246	// Value - An array of subscriptions.
247	Value *[]Model `json:"value,omitempty"`
248	// NextLink - The URL to get the next set of results.
249	NextLink *string `json:"nextLink,omitempty"`
250}
251
252// ListResultIterator provides access to a complete listing of Model values.
253type ListResultIterator struct {
254	i    int
255	page ListResultPage
256}
257
258// NextWithContext advances to the next value.  If there was an error making
259// the request the iterator does not advance and the error is returned.
260func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
261	if tracing.IsEnabled() {
262		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
263		defer func() {
264			sc := -1
265			if iter.Response().Response.Response != nil {
266				sc = iter.Response().Response.Response.StatusCode
267			}
268			tracing.EndSpan(ctx, sc, err)
269		}()
270	}
271	iter.i++
272	if iter.i < len(iter.page.Values()) {
273		return nil
274	}
275	err = iter.page.NextWithContext(ctx)
276	if err != nil {
277		iter.i--
278		return err
279	}
280	iter.i = 0
281	return nil
282}
283
284// Next advances to the next value.  If there was an error making
285// the request the iterator does not advance and the error is returned.
286// Deprecated: Use NextWithContext() instead.
287func (iter *ListResultIterator) Next() error {
288	return iter.NextWithContext(context.Background())
289}
290
291// NotDone returns true if the enumeration should be started or is not yet complete.
292func (iter ListResultIterator) NotDone() bool {
293	return iter.page.NotDone() && iter.i < len(iter.page.Values())
294}
295
296// Response returns the raw server response from the last page request.
297func (iter ListResultIterator) Response() ListResult {
298	return iter.page.Response()
299}
300
301// Value returns the current value or a zero-initialized value if the
302// iterator has advanced beyond the end of the collection.
303func (iter ListResultIterator) Value() Model {
304	if !iter.page.NotDone() {
305		return Model{}
306	}
307	return iter.page.Values()[iter.i]
308}
309
310// Creates a new instance of the ListResultIterator type.
311func NewListResultIterator(page ListResultPage) ListResultIterator {
312	return ListResultIterator{page: page}
313}
314
315// IsEmpty returns true if the ListResult contains no values.
316func (lr ListResult) IsEmpty() bool {
317	return lr.Value == nil || len(*lr.Value) == 0
318}
319
320// listResultPreparer prepares a request to retrieve the next set of results.
321// It returns nil if no more results exist.
322func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
323	if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 {
324		return nil, nil
325	}
326	return autorest.Prepare((&http.Request{}).WithContext(ctx),
327		autorest.AsJSON(),
328		autorest.AsGet(),
329		autorest.WithBaseURL(to.String(lr.NextLink)))
330}
331
332// ListResultPage contains a page of Model values.
333type ListResultPage struct {
334	fn func(context.Context, ListResult) (ListResult, error)
335	lr ListResult
336}
337
338// NextWithContext advances to the next page of values.  If there was an error making
339// the request the page does not advance and the error is returned.
340func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
341	if tracing.IsEnabled() {
342		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
343		defer func() {
344			sc := -1
345			if page.Response().Response.Response != nil {
346				sc = page.Response().Response.Response.StatusCode
347			}
348			tracing.EndSpan(ctx, sc, err)
349		}()
350	}
351	next, err := page.fn(ctx, page.lr)
352	if err != nil {
353		return err
354	}
355	page.lr = next
356	return nil
357}
358
359// Next advances to the next page of values.  If there was an error making
360// the request the page does not advance and the error is returned.
361// Deprecated: Use NextWithContext() instead.
362func (page *ListResultPage) Next() error {
363	return page.NextWithContext(context.Background())
364}
365
366// NotDone returns true if the page enumeration should be started or is not yet complete.
367func (page ListResultPage) NotDone() bool {
368	return !page.lr.IsEmpty()
369}
370
371// Response returns the raw server response from the last page request.
372func (page ListResultPage) Response() ListResult {
373	return page.lr
374}
375
376// Values returns the slice of values for the current page or nil if there are no values.
377func (page ListResultPage) Values() []Model {
378	if page.lr.IsEmpty() {
379		return nil
380	}
381	return *page.lr.Value
382}
383
384// Creates a new instance of the ListResultPage type.
385func NewListResultPage(getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
386	return ListResultPage{fn: getNextPage}
387}
388
389// Location location information.
390type Location struct {
391	// ID - READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus.
392	ID *string `json:"id,omitempty"`
393	// SubscriptionID - READ-ONLY; The subscription ID.
394	SubscriptionID *string `json:"subscriptionId,omitempty"`
395	// Name - READ-ONLY; The location name.
396	Name *string `json:"name,omitempty"`
397	// DisplayName - READ-ONLY; The display name of the location.
398	DisplayName *string `json:"displayName,omitempty"`
399	// Latitude - READ-ONLY; The latitude of the location.
400	Latitude *string `json:"latitude,omitempty"`
401	// Longitude - READ-ONLY; The longitude of the location.
402	Longitude *string `json:"longitude,omitempty"`
403}
404
405// LocationListResult location list operation response.
406type LocationListResult struct {
407	autorest.Response `json:"-"`
408	// Value - An array of locations.
409	Value *[]Location `json:"value,omitempty"`
410}
411
412// Model subscription information.
413type Model struct {
414	autorest.Response `json:"-"`
415	// ID - READ-ONLY; The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000.
416	ID *string `json:"id,omitempty"`
417	// SubscriptionID - READ-ONLY; The subscription ID.
418	SubscriptionID *string `json:"subscriptionId,omitempty"`
419	// DisplayName - READ-ONLY; The subscription display name.
420	DisplayName *string `json:"displayName,omitempty"`
421	// State - READ-ONLY; The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted'
422	State State `json:"state,omitempty"`
423	// SubscriptionPolicies - The subscription policies.
424	SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
425	// 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'.
426	AuthorizationSource *string `json:"authorizationSource,omitempty"`
427}
428
429// ModernCspSubscriptionCreationParameters the parameters required to create a new CSP subscription.
430type ModernCspSubscriptionCreationParameters struct {
431	// DisplayName - The friendly name of the subscription.
432	DisplayName *string `json:"displayName,omitempty"`
433	// SkuID - The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription.  Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.
434	SkuID *string `json:"skuId,omitempty"`
435	// ResellerID - Reseller ID, basically MPN Id.
436	ResellerID *string `json:"resellerId,omitempty"`
437}
438
439// ModernSubscriptionCreationParameters the parameters required to create a new subscription.
440type ModernSubscriptionCreationParameters struct {
441	// DisplayName - The friendly name of the subscription.
442	DisplayName *string `json:"displayName,omitempty"`
443	// SkuID - The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription.  Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.
444	SkuID *string `json:"skuId,omitempty"`
445	// CostCenter - If set, the cost center will show up on the Azure usage and charges file.
446	CostCenter *string `json:"costCenter,omitempty"`
447	// Owner - If specified, the AD principal will get owner access to the subscription, along with the user who is performing the create subscription operation
448	Owner *AdPrincipal `json:"owner,omitempty"`
449	// ManagementGroupID - The identifier of the management group to which this subscription will be associated.
450	ManagementGroupID *string `json:"managementGroupId,omitempty"`
451	// AdditionalParameters - Additional, untyped parameters to support custom subscription creation scenarios.
452	AdditionalParameters map[string]interface{} `json:"additionalParameters"`
453}
454
455// MarshalJSON is the custom marshaler for ModernSubscriptionCreationParameters.
456func (mscp ModernSubscriptionCreationParameters) MarshalJSON() ([]byte, error) {
457	objectMap := make(map[string]interface{})
458	if mscp.DisplayName != nil {
459		objectMap["displayName"] = mscp.DisplayName
460	}
461	if mscp.SkuID != nil {
462		objectMap["skuId"] = mscp.SkuID
463	}
464	if mscp.CostCenter != nil {
465		objectMap["costCenter"] = mscp.CostCenter
466	}
467	if mscp.Owner != nil {
468		objectMap["owner"] = mscp.Owner
469	}
470	if mscp.ManagementGroupID != nil {
471		objectMap["managementGroupId"] = mscp.ManagementGroupID
472	}
473	if mscp.AdditionalParameters != nil {
474		objectMap["additionalParameters"] = mscp.AdditionalParameters
475	}
476	return json.Marshal(objectMap)
477}
478
479// Name the new name of the subscription.
480type Name struct {
481	// SubscriptionName - New subscription name
482	SubscriptionName *string `json:"subscriptionName,omitempty"`
483}
484
485// Operation REST API operation
486type Operation struct {
487	// Name - Operation name: {provider}/{resource}/{operation}
488	Name *string `json:"name,omitempty"`
489	// Display - The object that represents the operation.
490	Display *OperationDisplay `json:"display,omitempty"`
491}
492
493// OperationDisplay the object that represents the operation.
494type OperationDisplay struct {
495	// Provider - Service provider: Microsoft.Subscription
496	Provider *string `json:"provider,omitempty"`
497	// Resource - Resource on which the operation is performed: Profile, endpoint, etc.
498	Resource *string `json:"resource,omitempty"`
499	// Operation - Operation type: Read, write, delete, etc.
500	Operation *string `json:"operation,omitempty"`
501}
502
503// OperationListResult result of the request to list operations. It contains a list of operations and a URL
504// link to get the next set of results.
505type OperationListResult struct {
506	autorest.Response `json:"-"`
507	// Value - List of operations.
508	Value *[]Operation `json:"value,omitempty"`
509	// NextLink - URL to get the next set of operation list results if there are any.
510	NextLink *string `json:"nextLink,omitempty"`
511}
512
513// Policies subscription policies.
514type Policies struct {
515	// 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.
516	LocationPlacementID *string `json:"locationPlacementId,omitempty"`
517	// QuotaID - READ-ONLY; The subscription quota ID.
518	QuotaID *string `json:"quotaId,omitempty"`
519	// SpendingLimit - READ-ONLY; The subscription spending limit. Possible values include: 'On', 'Off', 'CurrentPeriodOff'
520	SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
521}
522
523// RenamedSubscriptionID the ID of the subscriptions that is being renamed
524type RenamedSubscriptionID struct {
525	autorest.Response `json:"-"`
526	// Value - READ-ONLY; The ID of the subscriptions that is being renamed
527	Value *string `json:"value,omitempty"`
528}
529
530// TenantIDDescription tenant Id information.
531type TenantIDDescription struct {
532	// ID - READ-ONLY; The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000.
533	ID *string `json:"id,omitempty"`
534	// TenantID - READ-ONLY; The tenant ID. For example, 00000000-0000-0000-0000-000000000000.
535	TenantID *string `json:"tenantId,omitempty"`
536}
537
538// TenantListResult tenant Ids information.
539type TenantListResult struct {
540	autorest.Response `json:"-"`
541	// Value - An array of tenants.
542	Value *[]TenantIDDescription `json:"value,omitempty"`
543	// NextLink - The URL to use for getting the next set of results.
544	NextLink *string `json:"nextLink,omitempty"`
545}
546
547// TenantListResultIterator provides access to a complete listing of TenantIDDescription values.
548type TenantListResultIterator struct {
549	i    int
550	page TenantListResultPage
551}
552
553// NextWithContext advances to the next value.  If there was an error making
554// the request the iterator does not advance and the error is returned.
555func (iter *TenantListResultIterator) NextWithContext(ctx context.Context) (err error) {
556	if tracing.IsEnabled() {
557		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultIterator.NextWithContext")
558		defer func() {
559			sc := -1
560			if iter.Response().Response.Response != nil {
561				sc = iter.Response().Response.Response.StatusCode
562			}
563			tracing.EndSpan(ctx, sc, err)
564		}()
565	}
566	iter.i++
567	if iter.i < len(iter.page.Values()) {
568		return nil
569	}
570	err = iter.page.NextWithContext(ctx)
571	if err != nil {
572		iter.i--
573		return err
574	}
575	iter.i = 0
576	return nil
577}
578
579// Next advances to the next value.  If there was an error making
580// the request the iterator does not advance and the error is returned.
581// Deprecated: Use NextWithContext() instead.
582func (iter *TenantListResultIterator) Next() error {
583	return iter.NextWithContext(context.Background())
584}
585
586// NotDone returns true if the enumeration should be started or is not yet complete.
587func (iter TenantListResultIterator) NotDone() bool {
588	return iter.page.NotDone() && iter.i < len(iter.page.Values())
589}
590
591// Response returns the raw server response from the last page request.
592func (iter TenantListResultIterator) Response() TenantListResult {
593	return iter.page.Response()
594}
595
596// Value returns the current value or a zero-initialized value if the
597// iterator has advanced beyond the end of the collection.
598func (iter TenantListResultIterator) Value() TenantIDDescription {
599	if !iter.page.NotDone() {
600		return TenantIDDescription{}
601	}
602	return iter.page.Values()[iter.i]
603}
604
605// Creates a new instance of the TenantListResultIterator type.
606func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
607	return TenantListResultIterator{page: page}
608}
609
610// IsEmpty returns true if the ListResult contains no values.
611func (tlr TenantListResult) IsEmpty() bool {
612	return tlr.Value == nil || len(*tlr.Value) == 0
613}
614
615// tenantListResultPreparer prepares a request to retrieve the next set of results.
616// It returns nil if no more results exist.
617func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) {
618	if tlr.NextLink == nil || len(to.String(tlr.NextLink)) < 1 {
619		return nil, nil
620	}
621	return autorest.Prepare((&http.Request{}).WithContext(ctx),
622		autorest.AsJSON(),
623		autorest.AsGet(),
624		autorest.WithBaseURL(to.String(tlr.NextLink)))
625}
626
627// TenantListResultPage contains a page of TenantIDDescription values.
628type TenantListResultPage struct {
629	fn  func(context.Context, TenantListResult) (TenantListResult, error)
630	tlr TenantListResult
631}
632
633// NextWithContext advances to the next page of values.  If there was an error making
634// the request the page does not advance and the error is returned.
635func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err error) {
636	if tracing.IsEnabled() {
637		ctx = tracing.StartSpan(ctx, fqdn+"/TenantListResultPage.NextWithContext")
638		defer func() {
639			sc := -1
640			if page.Response().Response.Response != nil {
641				sc = page.Response().Response.Response.StatusCode
642			}
643			tracing.EndSpan(ctx, sc, err)
644		}()
645	}
646	next, err := page.fn(ctx, page.tlr)
647	if err != nil {
648		return err
649	}
650	page.tlr = next
651	return nil
652}
653
654// Next advances to the next page of values.  If there was an error making
655// the request the page does not advance and the error is returned.
656// Deprecated: Use NextWithContext() instead.
657func (page *TenantListResultPage) Next() error {
658	return page.NextWithContext(context.Background())
659}
660
661// NotDone returns true if the page enumeration should be started or is not yet complete.
662func (page TenantListResultPage) NotDone() bool {
663	return !page.tlr.IsEmpty()
664}
665
666// Response returns the raw server response from the last page request.
667func (page TenantListResultPage) Response() TenantListResult {
668	return page.tlr
669}
670
671// Values returns the slice of values for the current page or nil if there are no values.
672func (page TenantListResultPage) Values() []TenantIDDescription {
673	if page.tlr.IsEmpty() {
674		return nil
675	}
676	return *page.tlr.Value
677}
678
679// Creates a new instance of the TenantListResultPage type.
680func NewTenantListResultPage(getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
681	return TenantListResultPage{fn: getNextPage}
682}
683