1package compute
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/tracing"
25	"net/http"
26)
27
28// AvailabilitySetsClient is the compute Client
29type AvailabilitySetsClient struct {
30	BaseClient
31}
32
33// NewAvailabilitySetsClient creates an instance of the AvailabilitySetsClient client.
34func NewAvailabilitySetsClient(subscriptionID string) AvailabilitySetsClient {
35	return NewAvailabilitySetsClientWithBaseURI(DefaultBaseURI, subscriptionID)
36}
37
38// NewAvailabilitySetsClientWithBaseURI creates an instance of the AvailabilitySetsClient client.
39func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string) AvailabilitySetsClient {
40	return AvailabilitySetsClient{NewWithBaseURI(baseURI, subscriptionID)}
41}
42
43// CreateOrUpdate create or update an availability set.
44// Parameters:
45// resourceGroupName - the name of the resource group.
46// availabilitySetName - the name of the availability set.
47// parameters - parameters supplied to the Create Availability Set operation.
48func (client AvailabilitySetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet) (result AvailabilitySet, err error) {
49	if tracing.IsEnabled() {
50		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.CreateOrUpdate")
51		defer func() {
52			sc := -1
53			if result.Response.Response != nil {
54				sc = result.Response.Response.StatusCode
55			}
56			tracing.EndSpan(ctx, sc, err)
57		}()
58	}
59	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, availabilitySetName, parameters)
60	if err != nil {
61		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request")
62		return
63	}
64
65	resp, err := client.CreateOrUpdateSender(req)
66	if err != nil {
67		result.Response = autorest.Response{Response: resp}
68		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request")
69		return
70	}
71
72	result, err = client.CreateOrUpdateResponder(resp)
73	if err != nil {
74		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure responding to request")
75	}
76
77	return
78}
79
80// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
81func (client AvailabilitySetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet) (*http.Request, error) {
82	pathParameters := map[string]interface{}{
83		"availabilitySetName": autorest.Encode("path", availabilitySetName),
84		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
85		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
86	}
87
88	const APIVersion = "2018-10-01"
89	queryParameters := map[string]interface{}{
90		"api-version": APIVersion,
91	}
92
93	preparer := autorest.CreatePreparer(
94		autorest.AsContentType("application/json; charset=utf-8"),
95		autorest.AsPut(),
96		autorest.WithBaseURL(client.BaseURI),
97		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters),
98		autorest.WithJSON(parameters),
99		autorest.WithQueryParameters(queryParameters))
100	return preparer.Prepare((&http.Request{}).WithContext(ctx))
101}
102
103// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
104// http.Response Body if it receives an error.
105func (client AvailabilitySetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
106	return autorest.SendWithSender(client, req,
107		azure.DoRetryWithRegistration(client.Client))
108}
109
110// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
111// closes the http.Response Body.
112func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response) (result AvailabilitySet, err error) {
113	err = autorest.Respond(
114		resp,
115		client.ByInspecting(),
116		azure.WithErrorUnlessStatusCode(http.StatusOK),
117		autorest.ByUnmarshallingJSON(&result),
118		autorest.ByClosing())
119	result.Response = autorest.Response{Response: resp}
120	return
121}
122
123// Delete delete an availability set.
124// Parameters:
125// resourceGroupName - the name of the resource group.
126// availabilitySetName - the name of the availability set.
127func (client AvailabilitySetsClient) Delete(ctx context.Context, resourceGroupName string, availabilitySetName string) (result autorest.Response, err error) {
128	if tracing.IsEnabled() {
129		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Delete")
130		defer func() {
131			sc := -1
132			if result.Response != nil {
133				sc = result.Response.StatusCode
134			}
135			tracing.EndSpan(ctx, sc, err)
136		}()
137	}
138	req, err := client.DeletePreparer(ctx, resourceGroupName, availabilitySetName)
139	if err != nil {
140		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request")
141		return
142	}
143
144	resp, err := client.DeleteSender(req)
145	if err != nil {
146		result.Response = resp
147		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request")
148		return
149	}
150
151	result, err = client.DeleteResponder(resp)
152	if err != nil {
153		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure responding to request")
154	}
155
156	return
157}
158
159// DeletePreparer prepares the Delete request.
160func (client AvailabilitySetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
161	pathParameters := map[string]interface{}{
162		"availabilitySetName": autorest.Encode("path", availabilitySetName),
163		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
164		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
165	}
166
167	const APIVersion = "2018-10-01"
168	queryParameters := map[string]interface{}{
169		"api-version": APIVersion,
170	}
171
172	preparer := autorest.CreatePreparer(
173		autorest.AsDelete(),
174		autorest.WithBaseURL(client.BaseURI),
175		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters),
176		autorest.WithQueryParameters(queryParameters))
177	return preparer.Prepare((&http.Request{}).WithContext(ctx))
178}
179
180// DeleteSender sends the Delete request. The method will close the
181// http.Response Body if it receives an error.
182func (client AvailabilitySetsClient) DeleteSender(req *http.Request) (*http.Response, error) {
183	return autorest.SendWithSender(client, req,
184		azure.DoRetryWithRegistration(client.Client))
185}
186
187// DeleteResponder handles the response to the Delete request. The method always
188// closes the http.Response Body.
189func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
190	err = autorest.Respond(
191		resp,
192		client.ByInspecting(),
193		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
194		autorest.ByClosing())
195	result.Response = resp
196	return
197}
198
199// Get retrieves information about an availability set.
200// Parameters:
201// resourceGroupName - the name of the resource group.
202// availabilitySetName - the name of the availability set.
203func (client AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) {
204	if tracing.IsEnabled() {
205		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Get")
206		defer func() {
207			sc := -1
208			if result.Response.Response != nil {
209				sc = result.Response.Response.StatusCode
210			}
211			tracing.EndSpan(ctx, sc, err)
212		}()
213	}
214	req, err := client.GetPreparer(ctx, resourceGroupName, availabilitySetName)
215	if err != nil {
216		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request")
217		return
218	}
219
220	resp, err := client.GetSender(req)
221	if err != nil {
222		result.Response = autorest.Response{Response: resp}
223		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request")
224		return
225	}
226
227	result, err = client.GetResponder(resp)
228	if err != nil {
229		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure responding to request")
230	}
231
232	return
233}
234
235// GetPreparer prepares the Get request.
236func (client AvailabilitySetsClient) GetPreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
237	pathParameters := map[string]interface{}{
238		"availabilitySetName": autorest.Encode("path", availabilitySetName),
239		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
240		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
241	}
242
243	const APIVersion = "2018-10-01"
244	queryParameters := map[string]interface{}{
245		"api-version": APIVersion,
246	}
247
248	preparer := autorest.CreatePreparer(
249		autorest.AsGet(),
250		autorest.WithBaseURL(client.BaseURI),
251		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters),
252		autorest.WithQueryParameters(queryParameters))
253	return preparer.Prepare((&http.Request{}).WithContext(ctx))
254}
255
256// GetSender sends the Get request. The method will close the
257// http.Response Body if it receives an error.
258func (client AvailabilitySetsClient) GetSender(req *http.Request) (*http.Response, error) {
259	return autorest.SendWithSender(client, req,
260		azure.DoRetryWithRegistration(client.Client))
261}
262
263// GetResponder handles the response to the Get request. The method always
264// closes the http.Response Body.
265func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result AvailabilitySet, err error) {
266	err = autorest.Respond(
267		resp,
268		client.ByInspecting(),
269		azure.WithErrorUnlessStatusCode(http.StatusOK),
270		autorest.ByUnmarshallingJSON(&result),
271		autorest.ByClosing())
272	result.Response = autorest.Response{Response: resp}
273	return
274}
275
276// List lists all availability sets in a resource group.
277// Parameters:
278// resourceGroupName - the name of the resource group.
279func (client AvailabilitySetsClient) List(ctx context.Context, resourceGroupName string) (result AvailabilitySetListResultPage, err error) {
280	if tracing.IsEnabled() {
281		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.List")
282		defer func() {
283			sc := -1
284			if result.aslr.Response.Response != nil {
285				sc = result.aslr.Response.Response.StatusCode
286			}
287			tracing.EndSpan(ctx, sc, err)
288		}()
289	}
290	result.fn = client.listNextResults
291	req, err := client.ListPreparer(ctx, resourceGroupName)
292	if err != nil {
293		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request")
294		return
295	}
296
297	resp, err := client.ListSender(req)
298	if err != nil {
299		result.aslr.Response = autorest.Response{Response: resp}
300		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request")
301		return
302	}
303
304	result.aslr, err = client.ListResponder(resp)
305	if err != nil {
306		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure responding to request")
307	}
308
309	return
310}
311
312// ListPreparer prepares the List request.
313func (client AvailabilitySetsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
314	pathParameters := map[string]interface{}{
315		"resourceGroupName": autorest.Encode("path", resourceGroupName),
316		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
317	}
318
319	const APIVersion = "2018-10-01"
320	queryParameters := map[string]interface{}{
321		"api-version": APIVersion,
322	}
323
324	preparer := autorest.CreatePreparer(
325		autorest.AsGet(),
326		autorest.WithBaseURL(client.BaseURI),
327		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", pathParameters),
328		autorest.WithQueryParameters(queryParameters))
329	return preparer.Prepare((&http.Request{}).WithContext(ctx))
330}
331
332// ListSender sends the List request. The method will close the
333// http.Response Body if it receives an error.
334func (client AvailabilitySetsClient) ListSender(req *http.Request) (*http.Response, error) {
335	return autorest.SendWithSender(client, req,
336		azure.DoRetryWithRegistration(client.Client))
337}
338
339// ListResponder handles the response to the List request. The method always
340// closes the http.Response Body.
341func (client AvailabilitySetsClient) ListResponder(resp *http.Response) (result AvailabilitySetListResult, err error) {
342	err = autorest.Respond(
343		resp,
344		client.ByInspecting(),
345		azure.WithErrorUnlessStatusCode(http.StatusOK),
346		autorest.ByUnmarshallingJSON(&result),
347		autorest.ByClosing())
348	result.Response = autorest.Response{Response: resp}
349	return
350}
351
352// listNextResults retrieves the next set of results, if any.
353func (client AvailabilitySetsClient) listNextResults(ctx context.Context, lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) {
354	req, err := lastResults.availabilitySetListResultPreparer(ctx)
355	if err != nil {
356		return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", nil, "Failure preparing next results request")
357	}
358	if req == nil {
359		return
360	}
361	resp, err := client.ListSender(req)
362	if err != nil {
363		result.Response = autorest.Response{Response: resp}
364		return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", resp, "Failure sending next results request")
365	}
366	result, err = client.ListResponder(resp)
367	if err != nil {
368		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", resp, "Failure responding to next results request")
369	}
370	return
371}
372
373// ListComplete enumerates all values, automatically crossing page boundaries as required.
374func (client AvailabilitySetsClient) ListComplete(ctx context.Context, resourceGroupName string) (result AvailabilitySetListResultIterator, err error) {
375	if tracing.IsEnabled() {
376		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.List")
377		defer func() {
378			sc := -1
379			if result.Response().Response.Response != nil {
380				sc = result.page.Response().Response.Response.StatusCode
381			}
382			tracing.EndSpan(ctx, sc, err)
383		}()
384	}
385	result.page, err = client.List(ctx, resourceGroupName)
386	return
387}
388
389// ListAvailableSizes lists all available virtual machine sizes that can be used to create a new virtual machine in an
390// existing availability set.
391// Parameters:
392// resourceGroupName - the name of the resource group.
393// availabilitySetName - the name of the availability set.
394func (client AvailabilitySetsClient) ListAvailableSizes(ctx context.Context, resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) {
395	if tracing.IsEnabled() {
396		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListAvailableSizes")
397		defer func() {
398			sc := -1
399			if result.Response.Response != nil {
400				sc = result.Response.Response.StatusCode
401			}
402			tracing.EndSpan(ctx, sc, err)
403		}()
404	}
405	req, err := client.ListAvailableSizesPreparer(ctx, resourceGroupName, availabilitySetName)
406	if err != nil {
407		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request")
408		return
409	}
410
411	resp, err := client.ListAvailableSizesSender(req)
412	if err != nil {
413		result.Response = autorest.Response{Response: resp}
414		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request")
415		return
416	}
417
418	result, err = client.ListAvailableSizesResponder(resp)
419	if err != nil {
420		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure responding to request")
421	}
422
423	return
424}
425
426// ListAvailableSizesPreparer prepares the ListAvailableSizes request.
427func (client AvailabilitySetsClient) ListAvailableSizesPreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
428	pathParameters := map[string]interface{}{
429		"availabilitySetName": autorest.Encode("path", availabilitySetName),
430		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
431		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
432	}
433
434	const APIVersion = "2018-10-01"
435	queryParameters := map[string]interface{}{
436		"api-version": APIVersion,
437	}
438
439	preparer := autorest.CreatePreparer(
440		autorest.AsGet(),
441		autorest.WithBaseURL(client.BaseURI),
442		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", pathParameters),
443		autorest.WithQueryParameters(queryParameters))
444	return preparer.Prepare((&http.Request{}).WithContext(ctx))
445}
446
447// ListAvailableSizesSender sends the ListAvailableSizes request. The method will close the
448// http.Response Body if it receives an error.
449func (client AvailabilitySetsClient) ListAvailableSizesSender(req *http.Request) (*http.Response, error) {
450	return autorest.SendWithSender(client, req,
451		azure.DoRetryWithRegistration(client.Client))
452}
453
454// ListAvailableSizesResponder handles the response to the ListAvailableSizes request. The method always
455// closes the http.Response Body.
456func (client AvailabilitySetsClient) ListAvailableSizesResponder(resp *http.Response) (result VirtualMachineSizeListResult, err error) {
457	err = autorest.Respond(
458		resp,
459		client.ByInspecting(),
460		azure.WithErrorUnlessStatusCode(http.StatusOK),
461		autorest.ByUnmarshallingJSON(&result),
462		autorest.ByClosing())
463	result.Response = autorest.Response{Response: resp}
464	return
465}
466
467// ListBySubscription lists all availability sets in a subscription.
468func (client AvailabilitySetsClient) ListBySubscription(ctx context.Context) (result AvailabilitySetListResultPage, err error) {
469	if tracing.IsEnabled() {
470		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListBySubscription")
471		defer func() {
472			sc := -1
473			if result.aslr.Response.Response != nil {
474				sc = result.aslr.Response.Response.StatusCode
475			}
476			tracing.EndSpan(ctx, sc, err)
477		}()
478	}
479	result.fn = client.listBySubscriptionNextResults
480	req, err := client.ListBySubscriptionPreparer(ctx)
481	if err != nil {
482		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", nil, "Failure preparing request")
483		return
484	}
485
486	resp, err := client.ListBySubscriptionSender(req)
487	if err != nil {
488		result.aslr.Response = autorest.Response{Response: resp}
489		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", resp, "Failure sending request")
490		return
491	}
492
493	result.aslr, err = client.ListBySubscriptionResponder(resp)
494	if err != nil {
495		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", resp, "Failure responding to request")
496	}
497
498	return
499}
500
501// ListBySubscriptionPreparer prepares the ListBySubscription request.
502func (client AvailabilitySetsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
503	pathParameters := map[string]interface{}{
504		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
505	}
506
507	const APIVersion = "2018-10-01"
508	queryParameters := map[string]interface{}{
509		"api-version": APIVersion,
510	}
511
512	preparer := autorest.CreatePreparer(
513		autorest.AsGet(),
514		autorest.WithBaseURL(client.BaseURI),
515		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets", pathParameters),
516		autorest.WithQueryParameters(queryParameters))
517	return preparer.Prepare((&http.Request{}).WithContext(ctx))
518}
519
520// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
521// http.Response Body if it receives an error.
522func (client AvailabilitySetsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
523	return autorest.SendWithSender(client, req,
524		azure.DoRetryWithRegistration(client.Client))
525}
526
527// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
528// closes the http.Response Body.
529func (client AvailabilitySetsClient) ListBySubscriptionResponder(resp *http.Response) (result AvailabilitySetListResult, err error) {
530	err = autorest.Respond(
531		resp,
532		client.ByInspecting(),
533		azure.WithErrorUnlessStatusCode(http.StatusOK),
534		autorest.ByUnmarshallingJSON(&result),
535		autorest.ByClosing())
536	result.Response = autorest.Response{Response: resp}
537	return
538}
539
540// listBySubscriptionNextResults retrieves the next set of results, if any.
541func (client AvailabilitySetsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) {
542	req, err := lastResults.availabilitySetListResultPreparer(ctx)
543	if err != nil {
544		return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
545	}
546	if req == nil {
547		return
548	}
549	resp, err := client.ListBySubscriptionSender(req)
550	if err != nil {
551		result.Response = autorest.Response{Response: resp}
552		return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
553	}
554	result, err = client.ListBySubscriptionResponder(resp)
555	if err != nil {
556		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
557	}
558	return
559}
560
561// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
562func (client AvailabilitySetsClient) ListBySubscriptionComplete(ctx context.Context) (result AvailabilitySetListResultIterator, err error) {
563	if tracing.IsEnabled() {
564		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListBySubscription")
565		defer func() {
566			sc := -1
567			if result.Response().Response.Response != nil {
568				sc = result.page.Response().Response.Response.StatusCode
569			}
570			tracing.EndSpan(ctx, sc, err)
571		}()
572	}
573	result.page, err = client.ListBySubscription(ctx)
574	return
575}
576
577// Update update an availability set.
578// Parameters:
579// resourceGroupName - the name of the resource group.
580// availabilitySetName - the name of the availability set.
581// parameters - parameters supplied to the Update Availability Set operation.
582func (client AvailabilitySetsClient) Update(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySetUpdate) (result AvailabilitySet, err error) {
583	if tracing.IsEnabled() {
584		ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Update")
585		defer func() {
586			sc := -1
587			if result.Response.Response != nil {
588				sc = result.Response.Response.StatusCode
589			}
590			tracing.EndSpan(ctx, sc, err)
591		}()
592	}
593	req, err := client.UpdatePreparer(ctx, resourceGroupName, availabilitySetName, parameters)
594	if err != nil {
595		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", nil, "Failure preparing request")
596		return
597	}
598
599	resp, err := client.UpdateSender(req)
600	if err != nil {
601		result.Response = autorest.Response{Response: resp}
602		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", resp, "Failure sending request")
603		return
604	}
605
606	result, err = client.UpdateResponder(resp)
607	if err != nil {
608		err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", resp, "Failure responding to request")
609	}
610
611	return
612}
613
614// UpdatePreparer prepares the Update request.
615func (client AvailabilitySetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySetUpdate) (*http.Request, error) {
616	pathParameters := map[string]interface{}{
617		"availabilitySetName": autorest.Encode("path", availabilitySetName),
618		"resourceGroupName":   autorest.Encode("path", resourceGroupName),
619		"subscriptionId":      autorest.Encode("path", client.SubscriptionID),
620	}
621
622	const APIVersion = "2018-10-01"
623	queryParameters := map[string]interface{}{
624		"api-version": APIVersion,
625	}
626
627	preparer := autorest.CreatePreparer(
628		autorest.AsContentType("application/json; charset=utf-8"),
629		autorest.AsPatch(),
630		autorest.WithBaseURL(client.BaseURI),
631		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters),
632		autorest.WithJSON(parameters),
633		autorest.WithQueryParameters(queryParameters))
634	return preparer.Prepare((&http.Request{}).WithContext(ctx))
635}
636
637// UpdateSender sends the Update request. The method will close the
638// http.Response Body if it receives an error.
639func (client AvailabilitySetsClient) UpdateSender(req *http.Request) (*http.Response, error) {
640	return autorest.SendWithSender(client, req,
641		azure.DoRetryWithRegistration(client.Client))
642}
643
644// UpdateResponder handles the response to the Update request. The method always
645// closes the http.Response Body.
646func (client AvailabilitySetsClient) UpdateResponder(resp *http.Response) (result AvailabilitySet, err error) {
647	err = autorest.Respond(
648		resp,
649		client.ByInspecting(),
650		azure.WithErrorUnlessStatusCode(http.StatusOK),
651		autorest.ByUnmarshallingJSON(&result),
652		autorest.ByClosing())
653	result.Response = autorest.Response{Response: resp}
654	return
655}
656