1 package locks
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/2017-04-01/locks"
20
21
22 type ErrorAdditionalInfo struct {
23
24 Type *string `json:"type,omitempty"`
25
26 Info interface{} `json:"info,omitempty"`
27 }
28
29
30 func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
31 objectMap := make(map[string]interface{})
32 return json.Marshal(objectMap)
33 }
34
35
36 type ErrorDetail struct {
37
38 Code *string `json:"code,omitempty"`
39
40 Message *string `json:"message,omitempty"`
41
42 Target *string `json:"target,omitempty"`
43
44 Details *[]ErrorDetail `json:"details,omitempty"`
45
46 AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
47 }
48
49
50 func (ed ErrorDetail) MarshalJSON() ([]byte, error) {
51 objectMap := make(map[string]interface{})
52 return json.Marshal(objectMap)
53 }
54
55
56
57 type ErrorResponse struct {
58
59 Error *ErrorDetail `json:"error,omitempty"`
60 }
61
62
63 type ManagementLockListResult struct {
64 autorest.Response `json:"-"`
65
66 Value *[]ManagementLockObject `json:"value,omitempty"`
67
68 NextLink *string `json:"nextLink,omitempty"`
69 }
70
71
72 type ManagementLockListResultIterator struct {
73 i int
74 page ManagementLockListResultPage
75 }
76
77
78
79 func (iter *ManagementLockListResultIterator) NextWithContext(ctx context.Context) (err error) {
80 if tracing.IsEnabled() {
81 ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLockListResultIterator.NextWithContext")
82 defer func() {
83 sc := -1
84 if iter.Response().Response.Response != nil {
85 sc = iter.Response().Response.Response.StatusCode
86 }
87 tracing.EndSpan(ctx, sc, err)
88 }()
89 }
90 iter.i++
91 if iter.i < len(iter.page.Values()) {
92 return nil
93 }
94 err = iter.page.NextWithContext(ctx)
95 if err != nil {
96 iter.i--
97 return err
98 }
99 iter.i = 0
100 return nil
101 }
102
103
104
105
106 func (iter *ManagementLockListResultIterator) Next() error {
107 return iter.NextWithContext(context.Background())
108 }
109
110
111 func (iter ManagementLockListResultIterator) NotDone() bool {
112 return iter.page.NotDone() && iter.i < len(iter.page.Values())
113 }
114
115
116 func (iter ManagementLockListResultIterator) Response() ManagementLockListResult {
117 return iter.page.Response()
118 }
119
120
121
122 func (iter ManagementLockListResultIterator) Value() ManagementLockObject {
123 if !iter.page.NotDone() {
124 return ManagementLockObject{}
125 }
126 return iter.page.Values()[iter.i]
127 }
128
129
130 func NewManagementLockListResultIterator(page ManagementLockListResultPage) ManagementLockListResultIterator {
131 return ManagementLockListResultIterator{page: page}
132 }
133
134
135 func (mllr ManagementLockListResult) IsEmpty() bool {
136 return mllr.Value == nil || len(*mllr.Value) == 0
137 }
138
139
140 func (mllr ManagementLockListResult) hasNextLink() bool {
141 return mllr.NextLink != nil && len(*mllr.NextLink) != 0
142 }
143
144
145
146 func (mllr ManagementLockListResult) managementLockListResultPreparer(ctx context.Context) (*http.Request, error) {
147 if !mllr.hasNextLink() {
148 return nil, nil
149 }
150 return autorest.Prepare((&http.Request{}).WithContext(ctx),
151 autorest.AsJSON(),
152 autorest.AsGet(),
153 autorest.WithBaseURL(to.String(mllr.NextLink)))
154 }
155
156
157 type ManagementLockListResultPage struct {
158 fn func(context.Context, ManagementLockListResult) (ManagementLockListResult, error)
159 mllr ManagementLockListResult
160 }
161
162
163
164 func (page *ManagementLockListResultPage) NextWithContext(ctx context.Context) (err error) {
165 if tracing.IsEnabled() {
166 ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLockListResultPage.NextWithContext")
167 defer func() {
168 sc := -1
169 if page.Response().Response.Response != nil {
170 sc = page.Response().Response.Response.StatusCode
171 }
172 tracing.EndSpan(ctx, sc, err)
173 }()
174 }
175 for {
176 next, err := page.fn(ctx, page.mllr)
177 if err != nil {
178 return err
179 }
180 page.mllr = next
181 if !next.hasNextLink() || !next.IsEmpty() {
182 break
183 }
184 }
185 return nil
186 }
187
188
189
190
191 func (page *ManagementLockListResultPage) Next() error {
192 return page.NextWithContext(context.Background())
193 }
194
195
196 func (page ManagementLockListResultPage) NotDone() bool {
197 return !page.mllr.IsEmpty()
198 }
199
200
201 func (page ManagementLockListResultPage) Response() ManagementLockListResult {
202 return page.mllr
203 }
204
205
206 func (page ManagementLockListResultPage) Values() []ManagementLockObject {
207 if page.mllr.IsEmpty() {
208 return nil
209 }
210 return *page.mllr.Value
211 }
212
213
214 func NewManagementLockListResultPage(cur ManagementLockListResult, getNextPage func(context.Context, ManagementLockListResult) (ManagementLockListResult, error)) ManagementLockListResultPage {
215 return ManagementLockListResultPage{
216 fn: getNextPage,
217 mllr: cur,
218 }
219 }
220
221
222 type ManagementLockObject struct {
223 autorest.Response `json:"-"`
224
225 *ManagementLockProperties `json:"properties,omitempty"`
226
227 ID *string `json:"id,omitempty"`
228
229 Type *string `json:"type,omitempty"`
230
231 Name *string `json:"name,omitempty"`
232 }
233
234
235 func (mlo ManagementLockObject) MarshalJSON() ([]byte, error) {
236 objectMap := make(map[string]interface{})
237 if mlo.ManagementLockProperties != nil {
238 objectMap["properties"] = mlo.ManagementLockProperties
239 }
240 return json.Marshal(objectMap)
241 }
242
243
244 func (mlo *ManagementLockObject) UnmarshalJSON(body []byte) error {
245 var m map[string]*json.RawMessage
246 err := json.Unmarshal(body, &m)
247 if err != nil {
248 return err
249 }
250 for k, v := range m {
251 switch k {
252 case "properties":
253 if v != nil {
254 var managementLockProperties ManagementLockProperties
255 err = json.Unmarshal(*v, &managementLockProperties)
256 if err != nil {
257 return err
258 }
259 mlo.ManagementLockProperties = &managementLockProperties
260 }
261 case "id":
262 if v != nil {
263 var ID string
264 err = json.Unmarshal(*v, &ID)
265 if err != nil {
266 return err
267 }
268 mlo.ID = &ID
269 }
270 case "type":
271 if v != nil {
272 var typeVar string
273 err = json.Unmarshal(*v, &typeVar)
274 if err != nil {
275 return err
276 }
277 mlo.Type = &typeVar
278 }
279 case "name":
280 if v != nil {
281 var name string
282 err = json.Unmarshal(*v, &name)
283 if err != nil {
284 return err
285 }
286 mlo.Name = &name
287 }
288 }
289 }
290
291 return nil
292 }
293
294
295 type ManagementLockOwner struct {
296
297 ApplicationID *string `json:"applicationId,omitempty"`
298 }
299
300
301 type ManagementLockProperties struct {
302
303 Level LockLevel `json:"level,omitempty"`
304
305 Notes *string `json:"notes,omitempty"`
306
307 Owners *[]ManagementLockOwner `json:"owners,omitempty"`
308 }
309
310
311 type Operation struct {
312
313 Name *string `json:"name,omitempty"`
314
315 Display *OperationDisplay `json:"display,omitempty"`
316 }
317
318
319 type OperationDisplay struct {
320
321 Provider *string `json:"provider,omitempty"`
322
323 Resource *string `json:"resource,omitempty"`
324
325 Operation *string `json:"operation,omitempty"`
326 }
327
328
329
330 type OperationListResult struct {
331 autorest.Response `json:"-"`
332
333 Value *[]Operation `json:"value,omitempty"`
334
335 NextLink *string `json:"nextLink,omitempty"`
336 }
337
338
339 type OperationListResultIterator struct {
340 i int
341 page OperationListResultPage
342 }
343
344
345
346 func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
347 if tracing.IsEnabled() {
348 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
349 defer func() {
350 sc := -1
351 if iter.Response().Response.Response != nil {
352 sc = iter.Response().Response.Response.StatusCode
353 }
354 tracing.EndSpan(ctx, sc, err)
355 }()
356 }
357 iter.i++
358 if iter.i < len(iter.page.Values()) {
359 return nil
360 }
361 err = iter.page.NextWithContext(ctx)
362 if err != nil {
363 iter.i--
364 return err
365 }
366 iter.i = 0
367 return nil
368 }
369
370
371
372
373 func (iter *OperationListResultIterator) Next() error {
374 return iter.NextWithContext(context.Background())
375 }
376
377
378 func (iter OperationListResultIterator) NotDone() bool {
379 return iter.page.NotDone() && iter.i < len(iter.page.Values())
380 }
381
382
383 func (iter OperationListResultIterator) Response() OperationListResult {
384 return iter.page.Response()
385 }
386
387
388
389 func (iter OperationListResultIterator) Value() Operation {
390 if !iter.page.NotDone() {
391 return Operation{}
392 }
393 return iter.page.Values()[iter.i]
394 }
395
396
397 func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
398 return OperationListResultIterator{page: page}
399 }
400
401
402 func (olr OperationListResult) IsEmpty() bool {
403 return olr.Value == nil || len(*olr.Value) == 0
404 }
405
406
407 func (olr OperationListResult) hasNextLink() bool {
408 return olr.NextLink != nil && len(*olr.NextLink) != 0
409 }
410
411
412
413 func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
414 if !olr.hasNextLink() {
415 return nil, nil
416 }
417 return autorest.Prepare((&http.Request{}).WithContext(ctx),
418 autorest.AsJSON(),
419 autorest.AsGet(),
420 autorest.WithBaseURL(to.String(olr.NextLink)))
421 }
422
423
424 type OperationListResultPage struct {
425 fn func(context.Context, OperationListResult) (OperationListResult, error)
426 olr OperationListResult
427 }
428
429
430
431 func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
432 if tracing.IsEnabled() {
433 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
434 defer func() {
435 sc := -1
436 if page.Response().Response.Response != nil {
437 sc = page.Response().Response.Response.StatusCode
438 }
439 tracing.EndSpan(ctx, sc, err)
440 }()
441 }
442 for {
443 next, err := page.fn(ctx, page.olr)
444 if err != nil {
445 return err
446 }
447 page.olr = next
448 if !next.hasNextLink() || !next.IsEmpty() {
449 break
450 }
451 }
452 return nil
453 }
454
455
456
457
458 func (page *OperationListResultPage) Next() error {
459 return page.NextWithContext(context.Background())
460 }
461
462
463 func (page OperationListResultPage) NotDone() bool {
464 return !page.olr.IsEmpty()
465 }
466
467
468 func (page OperationListResultPage) Response() OperationListResult {
469 return page.olr
470 }
471
472
473 func (page OperationListResultPage) Values() []Operation {
474 if page.olr.IsEmpty() {
475 return nil
476 }
477 return *page.olr.Value
478 }
479
480
481 func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
482 return OperationListResultPage{
483 fn: getNextPage,
484 olr: cur,
485 }
486 }
487
View as plain text