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