1 package policy
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/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type VariablesClient struct {
20 BaseClient
21 }
22
23
24 func NewVariablesClient(subscriptionID string) VariablesClient {
25 return NewVariablesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewVariablesClientWithBaseURI(baseURI string, subscriptionID string) VariablesClient {
31 return VariablesClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client VariablesClient) CreateOrUpdate(ctx context.Context, variableName string, parameters Variable) (result Variable, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.CreateOrUpdate")
42 defer func() {
43 sc := -1
44 if result.Response.Response != nil {
45 sc = result.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 if err := validation.Validate([]validation.Validation{
51 {TargetValue: parameters,
52 Constraints: []validation.Constraint{{Target: "parameters.VariableProperties", Name: validation.Null, Rule: true,
53 Chain: []validation.Constraint{{Target: "parameters.VariableProperties.Columns", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
54 return result, validation.NewError("policy.VariablesClient", "CreateOrUpdate", err.Error())
55 }
56
57 req, err := client.CreateOrUpdatePreparer(ctx, variableName, parameters)
58 if err != nil {
59 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "CreateOrUpdate", nil, "Failure preparing request")
60 return
61 }
62
63 resp, err := client.CreateOrUpdateSender(req)
64 if err != nil {
65 result.Response = autorest.Response{Response: resp}
66 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "CreateOrUpdate", resp, "Failure sending request")
67 return
68 }
69
70 result, err = client.CreateOrUpdateResponder(resp)
71 if err != nil {
72 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "CreateOrUpdate", resp, "Failure responding to request")
73 return
74 }
75
76 return
77 }
78
79
80 func (client VariablesClient) CreateOrUpdatePreparer(ctx context.Context, variableName string, parameters Variable) (*http.Request, error) {
81 pathParameters := map[string]interface{}{
82 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
83 "variableName": autorest.Encode("path", variableName),
84 }
85
86 const APIVersion = "2022-08-01-preview"
87 queryParameters := map[string]interface{}{
88 "api-version": APIVersion,
89 }
90
91 parameters.SystemData = nil
92 parameters.ID = nil
93 parameters.Name = nil
94 parameters.Type = nil
95 preparer := autorest.CreatePreparer(
96 autorest.AsContentType("application/json; charset=utf-8"),
97 autorest.AsPut(),
98 autorest.WithBaseURL(client.BaseURI),
99 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}", pathParameters),
100 autorest.WithJSON(parameters),
101 autorest.WithQueryParameters(queryParameters))
102 return preparer.Prepare((&http.Request{}).WithContext(ctx))
103 }
104
105
106
107 func (client VariablesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
108 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
109 }
110
111
112
113 func (client VariablesClient) CreateOrUpdateResponder(resp *http.Response) (result Variable, err error) {
114 err = autorest.Respond(
115 resp,
116 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
117 autorest.ByUnmarshallingJSON(&result),
118 autorest.ByClosing())
119 result.Response = autorest.Response{Response: resp}
120 return
121 }
122
123
124
125
126
127
128
129 func (client VariablesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, parameters Variable) (result Variable, err error) {
130 if tracing.IsEnabled() {
131 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.CreateOrUpdateAtManagementGroup")
132 defer func() {
133 sc := -1
134 if result.Response.Response != nil {
135 sc = result.Response.Response.StatusCode
136 }
137 tracing.EndSpan(ctx, sc, err)
138 }()
139 }
140 if err := validation.Validate([]validation.Validation{
141 {TargetValue: parameters,
142 Constraints: []validation.Constraint{{Target: "parameters.VariableProperties", Name: validation.Null, Rule: true,
143 Chain: []validation.Constraint{{Target: "parameters.VariableProperties.Columns", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
144 return result, validation.NewError("policy.VariablesClient", "CreateOrUpdateAtManagementGroup", err.Error())
145 }
146
147 req, err := client.CreateOrUpdateAtManagementGroupPreparer(ctx, managementGroupID, variableName, parameters)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "CreateOrUpdateAtManagementGroup", nil, "Failure preparing request")
150 return
151 }
152
153 resp, err := client.CreateOrUpdateAtManagementGroupSender(req)
154 if err != nil {
155 result.Response = autorest.Response{Response: resp}
156 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "CreateOrUpdateAtManagementGroup", resp, "Failure sending request")
157 return
158 }
159
160 result, err = client.CreateOrUpdateAtManagementGroupResponder(resp)
161 if err != nil {
162 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "CreateOrUpdateAtManagementGroup", resp, "Failure responding to request")
163 return
164 }
165
166 return
167 }
168
169
170 func (client VariablesClient) CreateOrUpdateAtManagementGroupPreparer(ctx context.Context, managementGroupID string, variableName string, parameters Variable) (*http.Request, error) {
171 pathParameters := map[string]interface{}{
172 "managementGroupId": autorest.Encode("path", managementGroupID),
173 "variableName": autorest.Encode("path", variableName),
174 }
175
176 const APIVersion = "2022-08-01-preview"
177 queryParameters := map[string]interface{}{
178 "api-version": APIVersion,
179 }
180
181 parameters.SystemData = nil
182 parameters.ID = nil
183 parameters.Name = nil
184 parameters.Type = nil
185 preparer := autorest.CreatePreparer(
186 autorest.AsContentType("application/json; charset=utf-8"),
187 autorest.AsPut(),
188 autorest.WithBaseURL(client.BaseURI),
189 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}", pathParameters),
190 autorest.WithJSON(parameters),
191 autorest.WithQueryParameters(queryParameters))
192 return preparer.Prepare((&http.Request{}).WithContext(ctx))
193 }
194
195
196
197 func (client VariablesClient) CreateOrUpdateAtManagementGroupSender(req *http.Request) (*http.Response, error) {
198 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
199 }
200
201
202
203 func (client VariablesClient) CreateOrUpdateAtManagementGroupResponder(resp *http.Response) (result Variable, err error) {
204 err = autorest.Respond(
205 resp,
206 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
207 autorest.ByUnmarshallingJSON(&result),
208 autorest.ByClosing())
209 result.Response = autorest.Response{Response: resp}
210 return
211 }
212
213
214
215
216
217 func (client VariablesClient) Delete(ctx context.Context, variableName string) (result autorest.Response, err error) {
218 if tracing.IsEnabled() {
219 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.Delete")
220 defer func() {
221 sc := -1
222 if result.Response != nil {
223 sc = result.Response.StatusCode
224 }
225 tracing.EndSpan(ctx, sc, err)
226 }()
227 }
228 req, err := client.DeletePreparer(ctx, variableName)
229 if err != nil {
230 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "Delete", nil, "Failure preparing request")
231 return
232 }
233
234 resp, err := client.DeleteSender(req)
235 if err != nil {
236 result.Response = resp
237 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "Delete", resp, "Failure sending request")
238 return
239 }
240
241 result, err = client.DeleteResponder(resp)
242 if err != nil {
243 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "Delete", resp, "Failure responding to request")
244 return
245 }
246
247 return
248 }
249
250
251 func (client VariablesClient) DeletePreparer(ctx context.Context, variableName string) (*http.Request, error) {
252 pathParameters := map[string]interface{}{
253 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
254 "variableName": autorest.Encode("path", variableName),
255 }
256
257 const APIVersion = "2022-08-01-preview"
258 queryParameters := map[string]interface{}{
259 "api-version": APIVersion,
260 }
261
262 preparer := autorest.CreatePreparer(
263 autorest.AsDelete(),
264 autorest.WithBaseURL(client.BaseURI),
265 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}", pathParameters),
266 autorest.WithQueryParameters(queryParameters))
267 return preparer.Prepare((&http.Request{}).WithContext(ctx))
268 }
269
270
271
272 func (client VariablesClient) DeleteSender(req *http.Request) (*http.Response, error) {
273 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
274 }
275
276
277
278 func (client VariablesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
279 err = autorest.Respond(
280 resp,
281 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
282 autorest.ByClosing())
283 result.Response = resp
284 return
285 }
286
287
288
289
290
291
292
293 func (client VariablesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string) (result autorest.Response, err error) {
294 if tracing.IsEnabled() {
295 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.DeleteAtManagementGroup")
296 defer func() {
297 sc := -1
298 if result.Response != nil {
299 sc = result.Response.StatusCode
300 }
301 tracing.EndSpan(ctx, sc, err)
302 }()
303 }
304 req, err := client.DeleteAtManagementGroupPreparer(ctx, managementGroupID, variableName)
305 if err != nil {
306 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "DeleteAtManagementGroup", nil, "Failure preparing request")
307 return
308 }
309
310 resp, err := client.DeleteAtManagementGroupSender(req)
311 if err != nil {
312 result.Response = resp
313 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "DeleteAtManagementGroup", resp, "Failure sending request")
314 return
315 }
316
317 result, err = client.DeleteAtManagementGroupResponder(resp)
318 if err != nil {
319 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "DeleteAtManagementGroup", resp, "Failure responding to request")
320 return
321 }
322
323 return
324 }
325
326
327 func (client VariablesClient) DeleteAtManagementGroupPreparer(ctx context.Context, managementGroupID string, variableName string) (*http.Request, error) {
328 pathParameters := map[string]interface{}{
329 "managementGroupId": autorest.Encode("path", managementGroupID),
330 "variableName": autorest.Encode("path", variableName),
331 }
332
333 const APIVersion = "2022-08-01-preview"
334 queryParameters := map[string]interface{}{
335 "api-version": APIVersion,
336 }
337
338 preparer := autorest.CreatePreparer(
339 autorest.AsDelete(),
340 autorest.WithBaseURL(client.BaseURI),
341 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}", pathParameters),
342 autorest.WithQueryParameters(queryParameters))
343 return preparer.Prepare((&http.Request{}).WithContext(ctx))
344 }
345
346
347
348 func (client VariablesClient) DeleteAtManagementGroupSender(req *http.Request) (*http.Response, error) {
349 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
350 }
351
352
353
354 func (client VariablesClient) DeleteAtManagementGroupResponder(resp *http.Response) (result autorest.Response, err error) {
355 err = autorest.Respond(
356 resp,
357 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
358 autorest.ByClosing())
359 result.Response = resp
360 return
361 }
362
363
364
365
366 func (client VariablesClient) Get(ctx context.Context, variableName string) (result Variable, err error) {
367 if tracing.IsEnabled() {
368 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.Get")
369 defer func() {
370 sc := -1
371 if result.Response.Response != nil {
372 sc = result.Response.Response.StatusCode
373 }
374 tracing.EndSpan(ctx, sc, err)
375 }()
376 }
377 req, err := client.GetPreparer(ctx, variableName)
378 if err != nil {
379 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "Get", nil, "Failure preparing request")
380 return
381 }
382
383 resp, err := client.GetSender(req)
384 if err != nil {
385 result.Response = autorest.Response{Response: resp}
386 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "Get", resp, "Failure sending request")
387 return
388 }
389
390 result, err = client.GetResponder(resp)
391 if err != nil {
392 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "Get", resp, "Failure responding to request")
393 return
394 }
395
396 return
397 }
398
399
400 func (client VariablesClient) GetPreparer(ctx context.Context, variableName string) (*http.Request, error) {
401 pathParameters := map[string]interface{}{
402 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
403 "variableName": autorest.Encode("path", variableName),
404 }
405
406 const APIVersion = "2022-08-01-preview"
407 queryParameters := map[string]interface{}{
408 "api-version": APIVersion,
409 }
410
411 preparer := autorest.CreatePreparer(
412 autorest.AsGet(),
413 autorest.WithBaseURL(client.BaseURI),
414 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}", pathParameters),
415 autorest.WithQueryParameters(queryParameters))
416 return preparer.Prepare((&http.Request{}).WithContext(ctx))
417 }
418
419
420
421 func (client VariablesClient) GetSender(req *http.Request) (*http.Response, error) {
422 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
423 }
424
425
426
427 func (client VariablesClient) GetResponder(resp *http.Response) (result Variable, err error) {
428 err = autorest.Respond(
429 resp,
430 azure.WithErrorUnlessStatusCode(http.StatusOK),
431 autorest.ByUnmarshallingJSON(&result),
432 autorest.ByClosing())
433 result.Response = autorest.Response{Response: resp}
434 return
435 }
436
437
438
439
440
441
442 func (client VariablesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string) (result Variable, err error) {
443 if tracing.IsEnabled() {
444 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.GetAtManagementGroup")
445 defer func() {
446 sc := -1
447 if result.Response.Response != nil {
448 sc = result.Response.Response.StatusCode
449 }
450 tracing.EndSpan(ctx, sc, err)
451 }()
452 }
453 req, err := client.GetAtManagementGroupPreparer(ctx, managementGroupID, variableName)
454 if err != nil {
455 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "GetAtManagementGroup", nil, "Failure preparing request")
456 return
457 }
458
459 resp, err := client.GetAtManagementGroupSender(req)
460 if err != nil {
461 result.Response = autorest.Response{Response: resp}
462 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "GetAtManagementGroup", resp, "Failure sending request")
463 return
464 }
465
466 result, err = client.GetAtManagementGroupResponder(resp)
467 if err != nil {
468 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "GetAtManagementGroup", resp, "Failure responding to request")
469 return
470 }
471
472 return
473 }
474
475
476 func (client VariablesClient) GetAtManagementGroupPreparer(ctx context.Context, managementGroupID string, variableName string) (*http.Request, error) {
477 pathParameters := map[string]interface{}{
478 "managementGroupId": autorest.Encode("path", managementGroupID),
479 "variableName": autorest.Encode("path", variableName),
480 }
481
482 const APIVersion = "2022-08-01-preview"
483 queryParameters := map[string]interface{}{
484 "api-version": APIVersion,
485 }
486
487 preparer := autorest.CreatePreparer(
488 autorest.AsGet(),
489 autorest.WithBaseURL(client.BaseURI),
490 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}", pathParameters),
491 autorest.WithQueryParameters(queryParameters))
492 return preparer.Prepare((&http.Request{}).WithContext(ctx))
493 }
494
495
496
497 func (client VariablesClient) GetAtManagementGroupSender(req *http.Request) (*http.Response, error) {
498 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
499 }
500
501
502
503 func (client VariablesClient) GetAtManagementGroupResponder(resp *http.Response) (result Variable, err error) {
504 err = autorest.Respond(
505 resp,
506 azure.WithErrorUnlessStatusCode(http.StatusOK),
507 autorest.ByUnmarshallingJSON(&result),
508 autorest.ByClosing())
509 result.Response = autorest.Response{Response: resp}
510 return
511 }
512
513
514 func (client VariablesClient) List(ctx context.Context) (result VariableListResultPage, err error) {
515 if tracing.IsEnabled() {
516 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.List")
517 defer func() {
518 sc := -1
519 if result.vlr.Response.Response != nil {
520 sc = result.vlr.Response.Response.StatusCode
521 }
522 tracing.EndSpan(ctx, sc, err)
523 }()
524 }
525 result.fn = client.listNextResults
526 req, err := client.ListPreparer(ctx)
527 if err != nil {
528 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "List", nil, "Failure preparing request")
529 return
530 }
531
532 resp, err := client.ListSender(req)
533 if err != nil {
534 result.vlr.Response = autorest.Response{Response: resp}
535 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "List", resp, "Failure sending request")
536 return
537 }
538
539 result.vlr, err = client.ListResponder(resp)
540 if err != nil {
541 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "List", resp, "Failure responding to request")
542 return
543 }
544 if result.vlr.hasNextLink() && result.vlr.IsEmpty() {
545 err = result.NextWithContext(ctx)
546 return
547 }
548
549 return
550 }
551
552
553 func (client VariablesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
554 pathParameters := map[string]interface{}{
555 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
556 }
557
558 const APIVersion = "2022-08-01-preview"
559 queryParameters := map[string]interface{}{
560 "api-version": APIVersion,
561 }
562
563 preparer := autorest.CreatePreparer(
564 autorest.AsGet(),
565 autorest.WithBaseURL(client.BaseURI),
566 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables", pathParameters),
567 autorest.WithQueryParameters(queryParameters))
568 return preparer.Prepare((&http.Request{}).WithContext(ctx))
569 }
570
571
572
573 func (client VariablesClient) ListSender(req *http.Request) (*http.Response, error) {
574 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
575 }
576
577
578
579 func (client VariablesClient) ListResponder(resp *http.Response) (result VariableListResult, err error) {
580 err = autorest.Respond(
581 resp,
582 azure.WithErrorUnlessStatusCode(http.StatusOK),
583 autorest.ByUnmarshallingJSON(&result),
584 autorest.ByClosing())
585 result.Response = autorest.Response{Response: resp}
586 return
587 }
588
589
590 func (client VariablesClient) listNextResults(ctx context.Context, lastResults VariableListResult) (result VariableListResult, err error) {
591 req, err := lastResults.variableListResultPreparer(ctx)
592 if err != nil {
593 return result, autorest.NewErrorWithError(err, "policy.VariablesClient", "listNextResults", nil, "Failure preparing next results request")
594 }
595 if req == nil {
596 return
597 }
598 resp, err := client.ListSender(req)
599 if err != nil {
600 result.Response = autorest.Response{Response: resp}
601 return result, autorest.NewErrorWithError(err, "policy.VariablesClient", "listNextResults", resp, "Failure sending next results request")
602 }
603 result, err = client.ListResponder(resp)
604 if err != nil {
605 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "listNextResults", resp, "Failure responding to next results request")
606 }
607 return
608 }
609
610
611 func (client VariablesClient) ListComplete(ctx context.Context) (result VariableListResultIterator, err error) {
612 if tracing.IsEnabled() {
613 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.List")
614 defer func() {
615 sc := -1
616 if result.Response().Response.Response != nil {
617 sc = result.page.Response().Response.Response.StatusCode
618 }
619 tracing.EndSpan(ctx, sc, err)
620 }()
621 }
622 result.page, err = client.List(ctx)
623 return
624 }
625
626
627
628
629 func (client VariablesClient) ListForManagementGroup(ctx context.Context, managementGroupID string) (result VariableListResultPage, err error) {
630 if tracing.IsEnabled() {
631 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.ListForManagementGroup")
632 defer func() {
633 sc := -1
634 if result.vlr.Response.Response != nil {
635 sc = result.vlr.Response.Response.StatusCode
636 }
637 tracing.EndSpan(ctx, sc, err)
638 }()
639 }
640 result.fn = client.listForManagementGroupNextResults
641 req, err := client.ListForManagementGroupPreparer(ctx, managementGroupID)
642 if err != nil {
643 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "ListForManagementGroup", nil, "Failure preparing request")
644 return
645 }
646
647 resp, err := client.ListForManagementGroupSender(req)
648 if err != nil {
649 result.vlr.Response = autorest.Response{Response: resp}
650 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "ListForManagementGroup", resp, "Failure sending request")
651 return
652 }
653
654 result.vlr, err = client.ListForManagementGroupResponder(resp)
655 if err != nil {
656 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "ListForManagementGroup", resp, "Failure responding to request")
657 return
658 }
659 if result.vlr.hasNextLink() && result.vlr.IsEmpty() {
660 err = result.NextWithContext(ctx)
661 return
662 }
663
664 return
665 }
666
667
668 func (client VariablesClient) ListForManagementGroupPreparer(ctx context.Context, managementGroupID string) (*http.Request, error) {
669 pathParameters := map[string]interface{}{
670 "managementGroupId": autorest.Encode("path", managementGroupID),
671 }
672
673 const APIVersion = "2022-08-01-preview"
674 queryParameters := map[string]interface{}{
675 "api-version": APIVersion,
676 }
677
678 preparer := autorest.CreatePreparer(
679 autorest.AsGet(),
680 autorest.WithBaseURL(client.BaseURI),
681 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables", pathParameters),
682 autorest.WithQueryParameters(queryParameters))
683 return preparer.Prepare((&http.Request{}).WithContext(ctx))
684 }
685
686
687
688 func (client VariablesClient) ListForManagementGroupSender(req *http.Request) (*http.Response, error) {
689 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
690 }
691
692
693
694 func (client VariablesClient) ListForManagementGroupResponder(resp *http.Response) (result VariableListResult, err error) {
695 err = autorest.Respond(
696 resp,
697 azure.WithErrorUnlessStatusCode(http.StatusOK),
698 autorest.ByUnmarshallingJSON(&result),
699 autorest.ByClosing())
700 result.Response = autorest.Response{Response: resp}
701 return
702 }
703
704
705 func (client VariablesClient) listForManagementGroupNextResults(ctx context.Context, lastResults VariableListResult) (result VariableListResult, err error) {
706 req, err := lastResults.variableListResultPreparer(ctx)
707 if err != nil {
708 return result, autorest.NewErrorWithError(err, "policy.VariablesClient", "listForManagementGroupNextResults", nil, "Failure preparing next results request")
709 }
710 if req == nil {
711 return
712 }
713 resp, err := client.ListForManagementGroupSender(req)
714 if err != nil {
715 result.Response = autorest.Response{Response: resp}
716 return result, autorest.NewErrorWithError(err, "policy.VariablesClient", "listForManagementGroupNextResults", resp, "Failure sending next results request")
717 }
718 result, err = client.ListForManagementGroupResponder(resp)
719 if err != nil {
720 err = autorest.NewErrorWithError(err, "policy.VariablesClient", "listForManagementGroupNextResults", resp, "Failure responding to next results request")
721 }
722 return
723 }
724
725
726 func (client VariablesClient) ListForManagementGroupComplete(ctx context.Context, managementGroupID string) (result VariableListResultIterator, err error) {
727 if tracing.IsEnabled() {
728 ctx = tracing.StartSpan(ctx, fqdn+"/VariablesClient.ListForManagementGroup")
729 defer func() {
730 sc := -1
731 if result.Response().Response.Response != nil {
732 sc = result.page.Response().Response.Response.StatusCode
733 }
734 tracing.EndSpan(ctx, sc, err)
735 }()
736 }
737 result.page, err = client.ListForManagementGroup(ctx, managementGroupID)
738 return
739 }
740
View as plain text