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