1 package features
2
3
4
5
6
7
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
18 const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features"
19
20
21 type Operation struct {
22
23 Name *string `json:"name,omitempty"`
24
25 Display *OperationDisplay `json:"display,omitempty"`
26 }
27
28
29 type OperationDisplay struct {
30
31 Provider *string `json:"provider,omitempty"`
32
33 Resource *string `json:"resource,omitempty"`
34
35 Operation *string `json:"operation,omitempty"`
36 }
37
38
39
40 type OperationListResult struct {
41 autorest.Response `json:"-"`
42
43 Value *[]Operation `json:"value,omitempty"`
44
45 NextLink *string `json:"nextLink,omitempty"`
46 }
47
48
49 type OperationListResultIterator struct {
50 i int
51 page OperationListResultPage
52 }
53
54
55
56 func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
57 if tracing.IsEnabled() {
58 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
59 defer func() {
60 sc := -1
61 if iter.Response().Response.Response != nil {
62 sc = iter.Response().Response.Response.StatusCode
63 }
64 tracing.EndSpan(ctx, sc, err)
65 }()
66 }
67 iter.i++
68 if iter.i < len(iter.page.Values()) {
69 return nil
70 }
71 err = iter.page.NextWithContext(ctx)
72 if err != nil {
73 iter.i--
74 return err
75 }
76 iter.i = 0
77 return nil
78 }
79
80
81
82
83 func (iter *OperationListResultIterator) Next() error {
84 return iter.NextWithContext(context.Background())
85 }
86
87
88 func (iter OperationListResultIterator) NotDone() bool {
89 return iter.page.NotDone() && iter.i < len(iter.page.Values())
90 }
91
92
93 func (iter OperationListResultIterator) Response() OperationListResult {
94 return iter.page.Response()
95 }
96
97
98
99 func (iter OperationListResultIterator) Value() Operation {
100 if !iter.page.NotDone() {
101 return Operation{}
102 }
103 return iter.page.Values()[iter.i]
104 }
105
106
107 func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
108 return OperationListResultIterator{page: page}
109 }
110
111
112 func (olr OperationListResult) IsEmpty() bool {
113 return olr.Value == nil || len(*olr.Value) == 0
114 }
115
116
117 func (olr OperationListResult) hasNextLink() bool {
118 return olr.NextLink != nil && len(*olr.NextLink) != 0
119 }
120
121
122
123 func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
124 if !olr.hasNextLink() {
125 return nil, nil
126 }
127 return autorest.Prepare((&http.Request{}).WithContext(ctx),
128 autorest.AsJSON(),
129 autorest.AsGet(),
130 autorest.WithBaseURL(to.String(olr.NextLink)))
131 }
132
133
134 type OperationListResultPage struct {
135 fn func(context.Context, OperationListResult) (OperationListResult, error)
136 olr OperationListResult
137 }
138
139
140
141 func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
142 if tracing.IsEnabled() {
143 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
144 defer func() {
145 sc := -1
146 if page.Response().Response.Response != nil {
147 sc = page.Response().Response.Response.StatusCode
148 }
149 tracing.EndSpan(ctx, sc, err)
150 }()
151 }
152 for {
153 next, err := page.fn(ctx, page.olr)
154 if err != nil {
155 return err
156 }
157 page.olr = next
158 if !next.hasNextLink() || !next.IsEmpty() {
159 break
160 }
161 }
162 return nil
163 }
164
165
166
167
168 func (page *OperationListResultPage) Next() error {
169 return page.NextWithContext(context.Background())
170 }
171
172
173 func (page OperationListResultPage) NotDone() bool {
174 return !page.olr.IsEmpty()
175 }
176
177
178 func (page OperationListResultPage) Response() OperationListResult {
179 return page.olr
180 }
181
182
183 func (page OperationListResultPage) Values() []Operation {
184 if page.olr.IsEmpty() {
185 return nil
186 }
187 return *page.olr.Value
188 }
189
190
191 func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
192 return OperationListResultPage{
193 fn: getNextPage,
194 olr: cur,
195 }
196 }
197
198
199 type OperationsListResult struct {
200 autorest.Response `json:"-"`
201
202 Value *[]Result `json:"value,omitempty"`
203
204 NextLink *string `json:"nextLink,omitempty"`
205 }
206
207
208 type OperationsListResultIterator struct {
209 i int
210 page OperationsListResultPage
211 }
212
213
214
215 func (iter *OperationsListResultIterator) NextWithContext(ctx context.Context) (err error) {
216 if tracing.IsEnabled() {
217 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListResultIterator.NextWithContext")
218 defer func() {
219 sc := -1
220 if iter.Response().Response.Response != nil {
221 sc = iter.Response().Response.Response.StatusCode
222 }
223 tracing.EndSpan(ctx, sc, err)
224 }()
225 }
226 iter.i++
227 if iter.i < len(iter.page.Values()) {
228 return nil
229 }
230 err = iter.page.NextWithContext(ctx)
231 if err != nil {
232 iter.i--
233 return err
234 }
235 iter.i = 0
236 return nil
237 }
238
239
240
241
242 func (iter *OperationsListResultIterator) Next() error {
243 return iter.NextWithContext(context.Background())
244 }
245
246
247 func (iter OperationsListResultIterator) NotDone() bool {
248 return iter.page.NotDone() && iter.i < len(iter.page.Values())
249 }
250
251
252 func (iter OperationsListResultIterator) Response() OperationsListResult {
253 return iter.page.Response()
254 }
255
256
257
258 func (iter OperationsListResultIterator) Value() Result {
259 if !iter.page.NotDone() {
260 return Result{}
261 }
262 return iter.page.Values()[iter.i]
263 }
264
265
266 func NewOperationsListResultIterator(page OperationsListResultPage) OperationsListResultIterator {
267 return OperationsListResultIterator{page: page}
268 }
269
270
271 func (olr OperationsListResult) IsEmpty() bool {
272 return olr.Value == nil || len(*olr.Value) == 0
273 }
274
275
276 func (olr OperationsListResult) hasNextLink() bool {
277 return olr.NextLink != nil && len(*olr.NextLink) != 0
278 }
279
280
281
282 func (olr OperationsListResult) operationsListResultPreparer(ctx context.Context) (*http.Request, error) {
283 if !olr.hasNextLink() {
284 return nil, nil
285 }
286 return autorest.Prepare((&http.Request{}).WithContext(ctx),
287 autorest.AsJSON(),
288 autorest.AsGet(),
289 autorest.WithBaseURL(to.String(olr.NextLink)))
290 }
291
292
293 type OperationsListResultPage struct {
294 fn func(context.Context, OperationsListResult) (OperationsListResult, error)
295 olr OperationsListResult
296 }
297
298
299
300 func (page *OperationsListResultPage) NextWithContext(ctx context.Context) (err error) {
301 if tracing.IsEnabled() {
302 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListResultPage.NextWithContext")
303 defer func() {
304 sc := -1
305 if page.Response().Response.Response != nil {
306 sc = page.Response().Response.Response.StatusCode
307 }
308 tracing.EndSpan(ctx, sc, err)
309 }()
310 }
311 for {
312 next, err := page.fn(ctx, page.olr)
313 if err != nil {
314 return err
315 }
316 page.olr = next
317 if !next.hasNextLink() || !next.IsEmpty() {
318 break
319 }
320 }
321 return nil
322 }
323
324
325
326
327 func (page *OperationsListResultPage) Next() error {
328 return page.NextWithContext(context.Background())
329 }
330
331
332 func (page OperationsListResultPage) NotDone() bool {
333 return !page.olr.IsEmpty()
334 }
335
336
337 func (page OperationsListResultPage) Response() OperationsListResult {
338 return page.olr
339 }
340
341
342 func (page OperationsListResultPage) Values() []Result {
343 if page.olr.IsEmpty() {
344 return nil
345 }
346 return *page.olr.Value
347 }
348
349
350 func NewOperationsListResultPage(cur OperationsListResult, getNextPage func(context.Context, OperationsListResult) (OperationsListResult, error)) OperationsListResultPage {
351 return OperationsListResultPage{
352 fn: getNextPage,
353 olr: cur,
354 }
355 }
356
357
358 type Properties struct {
359
360 State *string `json:"state,omitempty"`
361 }
362
363
364 type Result struct {
365 autorest.Response `json:"-"`
366
367 Name *string `json:"name,omitempty"`
368
369 Properties *Properties `json:"properties,omitempty"`
370
371 ID *string `json:"id,omitempty"`
372
373 Type *string `json:"type,omitempty"`
374 }
375
View as plain text