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