1 package diagnostics
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 AutoscaleSettingsClient struct {
20 BaseClient
21 }
22
23
24 func NewAutoscaleSettingsClient(subscriptionID string) AutoscaleSettingsClient {
25 return NewAutoscaleSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewAutoscaleSettingsClientWithBaseURI(baseURI string, subscriptionID string) AutoscaleSettingsClient {
32 return AutoscaleSettingsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40 func (client AutoscaleSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (result AutoscaleSettingResource, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.CreateOrUpdate")
43 defer func() {
44 sc := -1
45 if result.Response.Response != nil {
46 sc = result.Response.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.MaxLength, Rule: 90, Chain: nil},
54 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
55 {TargetValue: parameters,
56 Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
57 {Target: "parameters.AutoscaleSetting", Name: validation.Null, Rule: true,
58 Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.Null, Rule: true,
59 Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.MaxItems, Rule: 20, Chain: nil}}},
60 }}}},
61 {TargetValue: client.SubscriptionID,
62 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
63 return result, validation.NewError("diagnostics.AutoscaleSettingsClient", "CreateOrUpdate", err.Error())
64 }
65
66 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, parameters)
67 if err != nil {
68 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "CreateOrUpdate", nil, "Failure preparing request")
69 return
70 }
71
72 resp, err := client.CreateOrUpdateSender(req)
73 if err != nil {
74 result.Response = autorest.Response{Response: resp}
75 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure sending request")
76 return
77 }
78
79 result, err = client.CreateOrUpdateResponder(resp)
80 if err != nil {
81 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure responding to request")
82 return
83 }
84
85 return
86 }
87
88
89 func (client AutoscaleSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (*http.Request, error) {
90 pathParameters := map[string]interface{}{
91 "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName),
92 "resourceGroupName": autorest.Encode("path", resourceGroupName),
93 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
94 }
95
96 const APIVersion = "2021-05-01-preview"
97 queryParameters := map[string]interface{}{
98 "api-version": APIVersion,
99 }
100
101 parameters.ID = nil
102 parameters.Name = nil
103 parameters.Type = nil
104 parameters.SystemData = nil
105 preparer := autorest.CreatePreparer(
106 autorest.AsContentType("application/json; charset=utf-8"),
107 autorest.AsPut(),
108 autorest.WithBaseURL(client.BaseURI),
109 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", pathParameters),
110 autorest.WithJSON(parameters),
111 autorest.WithQueryParameters(queryParameters))
112 return preparer.Prepare((&http.Request{}).WithContext(ctx))
113 }
114
115
116
117 func (client AutoscaleSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
118 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
119 }
120
121
122
123 func (client AutoscaleSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) {
124 err = autorest.Respond(
125 resp,
126 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
127 autorest.ByUnmarshallingJSON(&result),
128 autorest.ByClosing())
129 result.Response = autorest.Response{Response: resp}
130 return
131 }
132
133
134
135
136
137 func (client AutoscaleSettingsClient) Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) {
138 if tracing.IsEnabled() {
139 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Delete")
140 defer func() {
141 sc := -1
142 if result.Response != nil {
143 sc = result.Response.StatusCode
144 }
145 tracing.EndSpan(ctx, sc, err)
146 }()
147 }
148 if err := validation.Validate([]validation.Validation{
149 {TargetValue: resourceGroupName,
150 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
151 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
152 {TargetValue: client.SubscriptionID,
153 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
154 return result, validation.NewError("diagnostics.AutoscaleSettingsClient", "Delete", err.Error())
155 }
156
157 req, err := client.DeletePreparer(ctx, resourceGroupName, autoscaleSettingName)
158 if err != nil {
159 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Delete", nil, "Failure preparing request")
160 return
161 }
162
163 resp, err := client.DeleteSender(req)
164 if err != nil {
165 result.Response = resp
166 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Delete", resp, "Failure sending request")
167 return
168 }
169
170 result, err = client.DeleteResponder(resp)
171 if err != nil {
172 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Delete", resp, "Failure responding to request")
173 return
174 }
175
176 return
177 }
178
179
180 func (client AutoscaleSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) {
181 pathParameters := map[string]interface{}{
182 "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName),
183 "resourceGroupName": autorest.Encode("path", resourceGroupName),
184 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
185 }
186
187 const APIVersion = "2021-05-01-preview"
188 queryParameters := map[string]interface{}{
189 "api-version": APIVersion,
190 }
191
192 preparer := autorest.CreatePreparer(
193 autorest.AsDelete(),
194 autorest.WithBaseURL(client.BaseURI),
195 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", pathParameters),
196 autorest.WithQueryParameters(queryParameters))
197 return preparer.Prepare((&http.Request{}).WithContext(ctx))
198 }
199
200
201
202 func (client AutoscaleSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) {
203 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
204 }
205
206
207
208 func (client AutoscaleSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
209 err = autorest.Respond(
210 resp,
211 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
212 autorest.ByClosing())
213 result.Response = resp
214 return
215 }
216
217
218
219
220
221 func (client AutoscaleSettingsClient) Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result AutoscaleSettingResource, err error) {
222 if tracing.IsEnabled() {
223 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Get")
224 defer func() {
225 sc := -1
226 if result.Response.Response != nil {
227 sc = result.Response.Response.StatusCode
228 }
229 tracing.EndSpan(ctx, sc, err)
230 }()
231 }
232 if err := validation.Validate([]validation.Validation{
233 {TargetValue: resourceGroupName,
234 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
235 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
236 {TargetValue: client.SubscriptionID,
237 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
238 return result, validation.NewError("diagnostics.AutoscaleSettingsClient", "Get", err.Error())
239 }
240
241 req, err := client.GetPreparer(ctx, resourceGroupName, autoscaleSettingName)
242 if err != nil {
243 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Get", nil, "Failure preparing request")
244 return
245 }
246
247 resp, err := client.GetSender(req)
248 if err != nil {
249 result.Response = autorest.Response{Response: resp}
250 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Get", resp, "Failure sending request")
251 return
252 }
253
254 result, err = client.GetResponder(resp)
255 if err != nil {
256 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Get", resp, "Failure responding to request")
257 return
258 }
259
260 return
261 }
262
263
264 func (client AutoscaleSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) {
265 pathParameters := map[string]interface{}{
266 "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName),
267 "resourceGroupName": autorest.Encode("path", resourceGroupName),
268 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
269 }
270
271 const APIVersion = "2021-05-01-preview"
272 queryParameters := map[string]interface{}{
273 "api-version": APIVersion,
274 }
275
276 preparer := autorest.CreatePreparer(
277 autorest.AsGet(),
278 autorest.WithBaseURL(client.BaseURI),
279 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", pathParameters),
280 autorest.WithQueryParameters(queryParameters))
281 return preparer.Prepare((&http.Request{}).WithContext(ctx))
282 }
283
284
285
286 func (client AutoscaleSettingsClient) GetSender(req *http.Request) (*http.Response, error) {
287 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
288 }
289
290
291
292 func (client AutoscaleSettingsClient) GetResponder(resp *http.Response) (result AutoscaleSettingResource, err error) {
293 err = autorest.Respond(
294 resp,
295 azure.WithErrorUnlessStatusCode(http.StatusOK),
296 autorest.ByUnmarshallingJSON(&result),
297 autorest.ByClosing())
298 result.Response = autorest.Response{Response: resp}
299 return
300 }
301
302
303
304
305 func (client AutoscaleSettingsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionPage, err error) {
306 if tracing.IsEnabled() {
307 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListByResourceGroup")
308 defer func() {
309 sc := -1
310 if result.asrc.Response.Response != nil {
311 sc = result.asrc.Response.Response.StatusCode
312 }
313 tracing.EndSpan(ctx, sc, err)
314 }()
315 }
316 if err := validation.Validate([]validation.Validation{
317 {TargetValue: resourceGroupName,
318 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
319 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
320 {TargetValue: client.SubscriptionID,
321 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
322 return result, validation.NewError("diagnostics.AutoscaleSettingsClient", "ListByResourceGroup", err.Error())
323 }
324
325 result.fn = client.listByResourceGroupNextResults
326 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
327 if err != nil {
328 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "ListByResourceGroup", nil, "Failure preparing request")
329 return
330 }
331
332 resp, err := client.ListByResourceGroupSender(req)
333 if err != nil {
334 result.asrc.Response = autorest.Response{Response: resp}
335 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure sending request")
336 return
337 }
338
339 result.asrc, err = client.ListByResourceGroupResponder(resp)
340 if err != nil {
341 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure responding to request")
342 return
343 }
344 if result.asrc.hasNextLink() && result.asrc.IsEmpty() {
345 err = result.NextWithContext(ctx)
346 return
347 }
348
349 return
350 }
351
352
353 func (client AutoscaleSettingsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
354 pathParameters := map[string]interface{}{
355 "resourceGroupName": autorest.Encode("path", resourceGroupName),
356 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
357 }
358
359 const APIVersion = "2021-05-01-preview"
360 queryParameters := map[string]interface{}{
361 "api-version": APIVersion,
362 }
363
364 preparer := autorest.CreatePreparer(
365 autorest.AsGet(),
366 autorest.WithBaseURL(client.BaseURI),
367 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", pathParameters),
368 autorest.WithQueryParameters(queryParameters))
369 return preparer.Prepare((&http.Request{}).WithContext(ctx))
370 }
371
372
373
374 func (client AutoscaleSettingsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
375 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
376 }
377
378
379
380 func (client AutoscaleSettingsClient) ListByResourceGroupResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) {
381 err = autorest.Respond(
382 resp,
383 azure.WithErrorUnlessStatusCode(http.StatusOK),
384 autorest.ByUnmarshallingJSON(&result),
385 autorest.ByClosing())
386 result.Response = autorest.Response{Response: resp}
387 return
388 }
389
390
391 func (client AutoscaleSettingsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) {
392 req, err := lastResults.autoscaleSettingResourceCollectionPreparer(ctx)
393 if err != nil {
394 return result, autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
395 }
396 if req == nil {
397 return
398 }
399 resp, err := client.ListByResourceGroupSender(req)
400 if err != nil {
401 result.Response = autorest.Response{Response: resp}
402 return result, autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
403 }
404 result, err = client.ListByResourceGroupResponder(resp)
405 if err != nil {
406 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
407 }
408 return
409 }
410
411
412 func (client AutoscaleSettingsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionIterator, err error) {
413 if tracing.IsEnabled() {
414 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListByResourceGroup")
415 defer func() {
416 sc := -1
417 if result.Response().Response.Response != nil {
418 sc = result.page.Response().Response.Response.StatusCode
419 }
420 tracing.EndSpan(ctx, sc, err)
421 }()
422 }
423 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
424 return
425 }
426
427
428 func (client AutoscaleSettingsClient) ListBySubscription(ctx context.Context) (result AutoscaleSettingResourceCollectionPage, err error) {
429 if tracing.IsEnabled() {
430 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListBySubscription")
431 defer func() {
432 sc := -1
433 if result.asrc.Response.Response != nil {
434 sc = result.asrc.Response.Response.StatusCode
435 }
436 tracing.EndSpan(ctx, sc, err)
437 }()
438 }
439 if err := validation.Validate([]validation.Validation{
440 {TargetValue: client.SubscriptionID,
441 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
442 return result, validation.NewError("diagnostics.AutoscaleSettingsClient", "ListBySubscription", err.Error())
443 }
444
445 result.fn = client.listBySubscriptionNextResults
446 req, err := client.ListBySubscriptionPreparer(ctx)
447 if err != nil {
448 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "ListBySubscription", nil, "Failure preparing request")
449 return
450 }
451
452 resp, err := client.ListBySubscriptionSender(req)
453 if err != nil {
454 result.asrc.Response = autorest.Response{Response: resp}
455 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "ListBySubscription", resp, "Failure sending request")
456 return
457 }
458
459 result.asrc, err = client.ListBySubscriptionResponder(resp)
460 if err != nil {
461 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "ListBySubscription", resp, "Failure responding to request")
462 return
463 }
464 if result.asrc.hasNextLink() && result.asrc.IsEmpty() {
465 err = result.NextWithContext(ctx)
466 return
467 }
468
469 return
470 }
471
472
473 func (client AutoscaleSettingsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
474 pathParameters := map[string]interface{}{
475 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
476 }
477
478 const APIVersion = "2021-05-01-preview"
479 queryParameters := map[string]interface{}{
480 "api-version": APIVersion,
481 }
482
483 preparer := autorest.CreatePreparer(
484 autorest.AsGet(),
485 autorest.WithBaseURL(client.BaseURI),
486 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings", pathParameters),
487 autorest.WithQueryParameters(queryParameters))
488 return preparer.Prepare((&http.Request{}).WithContext(ctx))
489 }
490
491
492
493 func (client AutoscaleSettingsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
494 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
495 }
496
497
498
499 func (client AutoscaleSettingsClient) ListBySubscriptionResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) {
500 err = autorest.Respond(
501 resp,
502 azure.WithErrorUnlessStatusCode(http.StatusOK),
503 autorest.ByUnmarshallingJSON(&result),
504 autorest.ByClosing())
505 result.Response = autorest.Response{Response: resp}
506 return
507 }
508
509
510 func (client AutoscaleSettingsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) {
511 req, err := lastResults.autoscaleSettingResourceCollectionPreparer(ctx)
512 if err != nil {
513 return result, autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
514 }
515 if req == nil {
516 return
517 }
518 resp, err := client.ListBySubscriptionSender(req)
519 if err != nil {
520 result.Response = autorest.Response{Response: resp}
521 return result, autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
522 }
523 result, err = client.ListBySubscriptionResponder(resp)
524 if err != nil {
525 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
526 }
527 return
528 }
529
530
531 func (client AutoscaleSettingsClient) ListBySubscriptionComplete(ctx context.Context) (result AutoscaleSettingResourceCollectionIterator, err error) {
532 if tracing.IsEnabled() {
533 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListBySubscription")
534 defer func() {
535 sc := -1
536 if result.Response().Response.Response != nil {
537 sc = result.page.Response().Response.Response.StatusCode
538 }
539 tracing.EndSpan(ctx, sc, err)
540 }()
541 }
542 result.page, err = client.ListBySubscription(ctx)
543 return
544 }
545
546
547
548
549
550
551 func (client AutoscaleSettingsClient) Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (result AutoscaleSettingResource, err error) {
552 if tracing.IsEnabled() {
553 ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Update")
554 defer func() {
555 sc := -1
556 if result.Response.Response != nil {
557 sc = result.Response.Response.StatusCode
558 }
559 tracing.EndSpan(ctx, sc, err)
560 }()
561 }
562 if err := validation.Validate([]validation.Validation{
563 {TargetValue: client.SubscriptionID,
564 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
565 {TargetValue: resourceGroupName,
566 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
567 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
568 return result, validation.NewError("diagnostics.AutoscaleSettingsClient", "Update", err.Error())
569 }
570
571 req, err := client.UpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, autoscaleSettingResource)
572 if err != nil {
573 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Update", nil, "Failure preparing request")
574 return
575 }
576
577 resp, err := client.UpdateSender(req)
578 if err != nil {
579 result.Response = autorest.Response{Response: resp}
580 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Update", resp, "Failure sending request")
581 return
582 }
583
584 result, err = client.UpdateResponder(resp)
585 if err != nil {
586 err = autorest.NewErrorWithError(err, "diagnostics.AutoscaleSettingsClient", "Update", resp, "Failure responding to request")
587 return
588 }
589
590 return
591 }
592
593
594 func (client AutoscaleSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (*http.Request, error) {
595 pathParameters := map[string]interface{}{
596 "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName),
597 "resourceGroupName": autorest.Encode("path", resourceGroupName),
598 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
599 }
600
601 const APIVersion = "2021-05-01-preview"
602 queryParameters := map[string]interface{}{
603 "api-version": APIVersion,
604 }
605
606 preparer := autorest.CreatePreparer(
607 autorest.AsContentType("application/json; charset=utf-8"),
608 autorest.AsPatch(),
609 autorest.WithBaseURL(client.BaseURI),
610 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", pathParameters),
611 autorest.WithJSON(autoscaleSettingResource),
612 autorest.WithQueryParameters(queryParameters))
613 return preparer.Prepare((&http.Request{}).WithContext(ctx))
614 }
615
616
617
618 func (client AutoscaleSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) {
619 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
620 }
621
622
623
624 func (client AutoscaleSettingsClient) UpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) {
625 err = autorest.Respond(
626 resp,
627 azure.WithErrorUnlessStatusCode(http.StatusOK),
628 autorest.ByUnmarshallingJSON(&result),
629 autorest.ByClosing())
630 result.Response = autorest.Response{Response: resp}
631 return
632 }
633
View as plain text