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