1package subscriptions
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	"github.com/Azure/go-autorest/autorest"
22	"github.com/Azure/go-autorest/autorest/to"
23	"net/http"
24)
25
26// SpendingLimit enumerates the values for spending limit.
27type SpendingLimit string
28
29const (
30	// CurrentPeriodOff ...
31	CurrentPeriodOff SpendingLimit = "CurrentPeriodOff"
32	// Off ...
33	Off SpendingLimit = "Off"
34	// On ...
35	On SpendingLimit = "On"
36)
37
38// PossibleSpendingLimitValues returns an array of possible values for the SpendingLimit const type.
39func PossibleSpendingLimitValues() []SpendingLimit {
40	return []SpendingLimit{CurrentPeriodOff, Off, On}
41}
42
43// State enumerates the values for state.
44type State string
45
46const (
47	// Deleted ...
48	Deleted State = "Deleted"
49	// Disabled ...
50	Disabled State = "Disabled"
51	// Enabled ...
52	Enabled State = "Enabled"
53	// PastDue ...
54	PastDue State = "PastDue"
55	// Warned ...
56	Warned State = "Warned"
57)
58
59// PossibleStateValues returns an array of possible values for the State const type.
60func PossibleStateValues() []State {
61	return []State{Deleted, Disabled, Enabled, PastDue, Warned}
62}
63
64// ListResult subscription list operation response.
65type ListResult struct {
66	autorest.Response `json:"-"`
67	// Value - An array of subscriptions.
68	Value *[]Subscription `json:"value,omitempty"`
69	// NextLink - The URL to get the next set of results.
70	NextLink *string `json:"nextLink,omitempty"`
71}
72
73// ListResultIterator provides access to a complete listing of Subscription values.
74type ListResultIterator struct {
75	i    int
76	page ListResultPage
77}
78
79// Next advances to the next value.  If there was an error making
80// the request the iterator does not advance and the error is returned.
81func (iter *ListResultIterator) Next() error {
82	iter.i++
83	if iter.i < len(iter.page.Values()) {
84		return nil
85	}
86	err := iter.page.Next()
87	if err != nil {
88		iter.i--
89		return err
90	}
91	iter.i = 0
92	return nil
93}
94
95// NotDone returns true if the enumeration should be started or is not yet complete.
96func (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.
101func (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.
107func (iter ListResultIterator) Value() Subscription {
108	if !iter.page.NotDone() {
109		return Subscription{}
110	}
111	return iter.page.Values()[iter.i]
112}
113
114// IsEmpty returns true if the ListResult contains no values.
115func (lr ListResult) IsEmpty() bool {
116	return lr.Value == nil || len(*lr.Value) == 0
117}
118
119// listResultPreparer prepares a request to retrieve the next set of results.
120// It returns nil if no more results exist.
121func (lr ListResult) listResultPreparer() (*http.Request, error) {
122	if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 {
123		return nil, nil
124	}
125	return autorest.Prepare(&http.Request{},
126		autorest.AsJSON(),
127		autorest.AsGet(),
128		autorest.WithBaseURL(to.String(lr.NextLink)))
129}
130
131// ListResultPage contains a page of Subscription values.
132type ListResultPage struct {
133	fn func(ListResult) (ListResult, error)
134	lr ListResult
135}
136
137// Next advances to the next page of values.  If there was an error making
138// the request the page does not advance and the error is returned.
139func (page *ListResultPage) Next() error {
140	next, err := page.fn(page.lr)
141	if err != nil {
142		return err
143	}
144	page.lr = next
145	return nil
146}
147
148// NotDone returns true if the page enumeration should be started or is not yet complete.
149func (page ListResultPage) NotDone() bool {
150	return !page.lr.IsEmpty()
151}
152
153// Response returns the raw server response from the last page request.
154func (page ListResultPage) Response() ListResult {
155	return page.lr
156}
157
158// Values returns the slice of values for the current page or nil if there are no values.
159func (page ListResultPage) Values() []Subscription {
160	if page.lr.IsEmpty() {
161		return nil
162	}
163	return *page.lr.Value
164}
165
166// Location location information.
167type Location struct {
168	// ID - The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus.
169	ID *string `json:"id,omitempty"`
170	// SubscriptionID - The subscription ID.
171	SubscriptionID *string `json:"subscriptionId,omitempty"`
172	// Name - The location name.
173	Name *string `json:"name,omitempty"`
174	// DisplayName - The display name of the location.
175	DisplayName *string `json:"displayName,omitempty"`
176	// Latitude - The latitude of the location.
177	Latitude *string `json:"latitude,omitempty"`
178	// Longitude - The longitude of the location.
179	Longitude *string `json:"longitude,omitempty"`
180}
181
182// LocationListResult location list operation response.
183type LocationListResult struct {
184	autorest.Response `json:"-"`
185	// Value - An array of locations.
186	Value *[]Location `json:"value,omitempty"`
187}
188
189// Policies subscription policies.
190type Policies struct {
191	// LocationPlacementID - 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.
192	LocationPlacementID *string `json:"locationPlacementId,omitempty"`
193	// QuotaID - The subscription quota ID.
194	QuotaID *string `json:"quotaId,omitempty"`
195	// SpendingLimit - The subscription spending limit. Possible values include: 'On', 'Off', 'CurrentPeriodOff'
196	SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
197}
198
199// Subscription subscription information.
200type Subscription struct {
201	autorest.Response `json:"-"`
202	// ID - The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000.
203	ID *string `json:"id,omitempty"`
204	// SubscriptionID - The subscription ID.
205	SubscriptionID *string `json:"subscriptionId,omitempty"`
206	// DisplayName - The subscription display name.
207	DisplayName *string `json:"displayName,omitempty"`
208	// State - The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted'
209	State State `json:"state,omitempty"`
210	// SubscriptionPolicies - The subscription policies.
211	SubscriptionPolicies *Policies `json:"subscriptionPolicies,omitempty"`
212	// 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'.
213	AuthorizationSource *string `json:"authorizationSource,omitempty"`
214}
215
216// TenantIDDescription tenant Id information.
217type TenantIDDescription struct {
218	// ID - The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000.
219	ID *string `json:"id,omitempty"`
220	// TenantID - The tenant ID. For example, 00000000-0000-0000-0000-000000000000.
221	TenantID *string `json:"tenantId,omitempty"`
222}
223
224// TenantListResult tenant Ids information.
225type TenantListResult struct {
226	autorest.Response `json:"-"`
227	// Value - An array of tenants.
228	Value *[]TenantIDDescription `json:"value,omitempty"`
229	// NextLink - The URL to use for getting the next set of results.
230	NextLink *string `json:"nextLink,omitempty"`
231}
232
233// TenantListResultIterator provides access to a complete listing of TenantIDDescription values.
234type TenantListResultIterator struct {
235	i    int
236	page TenantListResultPage
237}
238
239// Next advances to the next value.  If there was an error making
240// the request the iterator does not advance and the error is returned.
241func (iter *TenantListResultIterator) Next() error {
242	iter.i++
243	if iter.i < len(iter.page.Values()) {
244		return nil
245	}
246	err := iter.page.Next()
247	if err != nil {
248		iter.i--
249		return err
250	}
251	iter.i = 0
252	return nil
253}
254
255// NotDone returns true if the enumeration should be started or is not yet complete.
256func (iter TenantListResultIterator) NotDone() bool {
257	return iter.page.NotDone() && iter.i < len(iter.page.Values())
258}
259
260// Response returns the raw server response from the last page request.
261func (iter TenantListResultIterator) Response() TenantListResult {
262	return iter.page.Response()
263}
264
265// Value returns the current value or a zero-initialized value if the
266// iterator has advanced beyond the end of the collection.
267func (iter TenantListResultIterator) Value() TenantIDDescription {
268	if !iter.page.NotDone() {
269		return TenantIDDescription{}
270	}
271	return iter.page.Values()[iter.i]
272}
273
274// IsEmpty returns true if the ListResult contains no values.
275func (tlr TenantListResult) IsEmpty() bool {
276	return tlr.Value == nil || len(*tlr.Value) == 0
277}
278
279// tenantListResultPreparer prepares a request to retrieve the next set of results.
280// It returns nil if no more results exist.
281func (tlr TenantListResult) tenantListResultPreparer() (*http.Request, error) {
282	if tlr.NextLink == nil || len(to.String(tlr.NextLink)) < 1 {
283		return nil, nil
284	}
285	return autorest.Prepare(&http.Request{},
286		autorest.AsJSON(),
287		autorest.AsGet(),
288		autorest.WithBaseURL(to.String(tlr.NextLink)))
289}
290
291// TenantListResultPage contains a page of TenantIDDescription values.
292type TenantListResultPage struct {
293	fn  func(TenantListResult) (TenantListResult, error)
294	tlr TenantListResult
295}
296
297// Next advances to the next page of values.  If there was an error making
298// the request the page does not advance and the error is returned.
299func (page *TenantListResultPage) Next() error {
300	next, err := page.fn(page.tlr)
301	if err != nil {
302		return err
303	}
304	page.tlr = next
305	return nil
306}
307
308// NotDone returns true if the page enumeration should be started or is not yet complete.
309func (page TenantListResultPage) NotDone() bool {
310	return !page.tlr.IsEmpty()
311}
312
313// Response returns the raw server response from the last page request.
314func (page TenantListResultPage) Response() TenantListResult {
315	return page.tlr
316}
317
318// Values returns the slice of values for the current page or nil if there are no values.
319func (page TenantListResultPage) Values() []TenantIDDescription {
320	if page.tlr.IsEmpty() {
321		return nil
322	}
323	return *page.tlr.Value
324}
325