1package compute
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
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// DiskEncryptionSetsClient is the compute Client
19type DiskEncryptionSetsClient struct {
20	BaseClient
21}
22
23// NewDiskEncryptionSetsClient creates an instance of the DiskEncryptionSetsClient client.
24func NewDiskEncryptionSetsClient(subscriptionID string) DiskEncryptionSetsClient {
25	return NewDiskEncryptionSetsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewDiskEncryptionSetsClientWithBaseURI creates an instance of the DiskEncryptionSetsClient client using a custom
29// endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
30// stack).
31func NewDiskEncryptionSetsClientWithBaseURI(baseURI string, subscriptionID string) DiskEncryptionSetsClient {
32	return DiskEncryptionSetsClient{NewWithBaseURI(baseURI, subscriptionID)}
33}
34
35// CreateOrUpdate creates or updates a disk encryption set
36// Parameters:
37// resourceGroupName - the name of the resource group.
38// diskEncryptionSetName - the name of the disk encryption set that is being created. The name can't be changed
39// after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The
40// maximum name length is 80 characters.
41// diskEncryptionSet - disk encryption set object supplied in the body of the Put disk encryption set
42// operation.
43func (client DiskEncryptionSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, diskEncryptionSet DiskEncryptionSet) (result DiskEncryptionSetsCreateOrUpdateFuture, err error) {
44	if tracing.IsEnabled() {
45		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.CreateOrUpdate")
46		defer func() {
47			sc := -1
48			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
49				sc = result.FutureAPI.Response().StatusCode
50			}
51			tracing.EndSpan(ctx, sc, err)
52		}()
53	}
54	if err := validation.Validate([]validation.Validation{
55		{TargetValue: diskEncryptionSet,
56			Constraints: []validation.Constraint{{Target: "diskEncryptionSet.EncryptionSetProperties", Name: validation.Null, Rule: false,
57				Chain: []validation.Constraint{{Target: "diskEncryptionSet.EncryptionSetProperties.ActiveKey", Name: validation.Null, Rule: false,
58					Chain: []validation.Constraint{{Target: "diskEncryptionSet.EncryptionSetProperties.ActiveKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil}}},
59				}}}}}); err != nil {
60		return result, validation.NewError("compute.DiskEncryptionSetsClient", "CreateOrUpdate", err.Error())
61	}
62
63	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, diskEncryptionSetName, diskEncryptionSet)
64	if err != nil {
65		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "CreateOrUpdate", nil, "Failure preparing request")
66		return
67	}
68
69	result, err = client.CreateOrUpdateSender(req)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "CreateOrUpdate", nil, "Failure sending request")
72		return
73	}
74
75	return
76}
77
78// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
79func (client DiskEncryptionSetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, diskEncryptionSet DiskEncryptionSet) (*http.Request, error) {
80	pathParameters := map[string]interface{}{
81		"diskEncryptionSetName": autorest.Encode("path", diskEncryptionSetName),
82		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
83		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
84	}
85
86	const APIVersion = "2020-12-01"
87	queryParameters := map[string]interface{}{
88		"api-version": APIVersion,
89	}
90
91	preparer := autorest.CreatePreparer(
92		autorest.AsContentType("application/json; charset=utf-8"),
93		autorest.AsPut(),
94		autorest.WithBaseURL(client.BaseURI),
95		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", pathParameters),
96		autorest.WithJSON(diskEncryptionSet),
97		autorest.WithQueryParameters(queryParameters))
98	return preparer.Prepare((&http.Request{}).WithContext(ctx))
99}
100
101// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
102// http.Response Body if it receives an error.
103func (client DiskEncryptionSetsClient) CreateOrUpdateSender(req *http.Request) (future DiskEncryptionSetsCreateOrUpdateFuture, err error) {
104	var resp *http.Response
105	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
106	if err != nil {
107		return
108	}
109	var azf azure.Future
110	azf, err = azure.NewFutureFromResponse(resp)
111	future.FutureAPI = &azf
112	future.Result = future.result
113	return
114}
115
116// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
117// closes the http.Response Body.
118func (client DiskEncryptionSetsClient) CreateOrUpdateResponder(resp *http.Response) (result DiskEncryptionSet, err error) {
119	err = autorest.Respond(
120		resp,
121		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
122		autorest.ByUnmarshallingJSON(&result),
123		autorest.ByClosing())
124	result.Response = autorest.Response{Response: resp}
125	return
126}
127
128// Delete deletes a disk encryption set.
129// Parameters:
130// resourceGroupName - the name of the resource group.
131// diskEncryptionSetName - the name of the disk encryption set that is being created. The name can't be changed
132// after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The
133// maximum name length is 80 characters.
134func (client DiskEncryptionSetsClient) Delete(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (result DiskEncryptionSetsDeleteFuture, err error) {
135	if tracing.IsEnabled() {
136		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.Delete")
137		defer func() {
138			sc := -1
139			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
140				sc = result.FutureAPI.Response().StatusCode
141			}
142			tracing.EndSpan(ctx, sc, err)
143		}()
144	}
145	req, err := client.DeletePreparer(ctx, resourceGroupName, diskEncryptionSetName)
146	if err != nil {
147		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Delete", nil, "Failure preparing request")
148		return
149	}
150
151	result, err = client.DeleteSender(req)
152	if err != nil {
153		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Delete", nil, "Failure sending request")
154		return
155	}
156
157	return
158}
159
160// DeletePreparer prepares the Delete request.
161func (client DiskEncryptionSetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (*http.Request, error) {
162	pathParameters := map[string]interface{}{
163		"diskEncryptionSetName": autorest.Encode("path", diskEncryptionSetName),
164		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
165		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
166	}
167
168	const APIVersion = "2020-12-01"
169	queryParameters := map[string]interface{}{
170		"api-version": APIVersion,
171	}
172
173	preparer := autorest.CreatePreparer(
174		autorest.AsDelete(),
175		autorest.WithBaseURL(client.BaseURI),
176		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", pathParameters),
177		autorest.WithQueryParameters(queryParameters))
178	return preparer.Prepare((&http.Request{}).WithContext(ctx))
179}
180
181// DeleteSender sends the Delete request. The method will close the
182// http.Response Body if it receives an error.
183func (client DiskEncryptionSetsClient) DeleteSender(req *http.Request) (future DiskEncryptionSetsDeleteFuture, err error) {
184	var resp *http.Response
185	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
186	if err != nil {
187		return
188	}
189	var azf azure.Future
190	azf, err = azure.NewFutureFromResponse(resp)
191	future.FutureAPI = &azf
192	future.Result = future.result
193	return
194}
195
196// DeleteResponder handles the response to the Delete request. The method always
197// closes the http.Response Body.
198func (client DiskEncryptionSetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
199	err = autorest.Respond(
200		resp,
201		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
202		autorest.ByClosing())
203	result.Response = resp
204	return
205}
206
207// Get gets information about a disk encryption set.
208// Parameters:
209// resourceGroupName - the name of the resource group.
210// diskEncryptionSetName - the name of the disk encryption set that is being created. The name can't be changed
211// after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The
212// maximum name length is 80 characters.
213func (client DiskEncryptionSetsClient) Get(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (result DiskEncryptionSet, err error) {
214	if tracing.IsEnabled() {
215		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.Get")
216		defer func() {
217			sc := -1
218			if result.Response.Response != nil {
219				sc = result.Response.Response.StatusCode
220			}
221			tracing.EndSpan(ctx, sc, err)
222		}()
223	}
224	req, err := client.GetPreparer(ctx, resourceGroupName, diskEncryptionSetName)
225	if err != nil {
226		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Get", nil, "Failure preparing request")
227		return
228	}
229
230	resp, err := client.GetSender(req)
231	if err != nil {
232		result.Response = autorest.Response{Response: resp}
233		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Get", resp, "Failure sending request")
234		return
235	}
236
237	result, err = client.GetResponder(resp)
238	if err != nil {
239		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Get", resp, "Failure responding to request")
240		return
241	}
242
243	return
244}
245
246// GetPreparer prepares the Get request.
247func (client DiskEncryptionSetsClient) GetPreparer(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (*http.Request, error) {
248	pathParameters := map[string]interface{}{
249		"diskEncryptionSetName": autorest.Encode("path", diskEncryptionSetName),
250		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
251		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
252	}
253
254	const APIVersion = "2020-12-01"
255	queryParameters := map[string]interface{}{
256		"api-version": APIVersion,
257	}
258
259	preparer := autorest.CreatePreparer(
260		autorest.AsGet(),
261		autorest.WithBaseURL(client.BaseURI),
262		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", pathParameters),
263		autorest.WithQueryParameters(queryParameters))
264	return preparer.Prepare((&http.Request{}).WithContext(ctx))
265}
266
267// GetSender sends the Get request. The method will close the
268// http.Response Body if it receives an error.
269func (client DiskEncryptionSetsClient) GetSender(req *http.Request) (*http.Response, error) {
270	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
271}
272
273// GetResponder handles the response to the Get request. The method always
274// closes the http.Response Body.
275func (client DiskEncryptionSetsClient) GetResponder(resp *http.Response) (result DiskEncryptionSet, err error) {
276	err = autorest.Respond(
277		resp,
278		azure.WithErrorUnlessStatusCode(http.StatusOK),
279		autorest.ByUnmarshallingJSON(&result),
280		autorest.ByClosing())
281	result.Response = autorest.Response{Response: resp}
282	return
283}
284
285// List lists all the disk encryption sets under a subscription.
286func (client DiskEncryptionSetsClient) List(ctx context.Context) (result DiskEncryptionSetListPage, err error) {
287	if tracing.IsEnabled() {
288		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.List")
289		defer func() {
290			sc := -1
291			if result.desl.Response.Response != nil {
292				sc = result.desl.Response.Response.StatusCode
293			}
294			tracing.EndSpan(ctx, sc, err)
295		}()
296	}
297	result.fn = client.listNextResults
298	req, err := client.ListPreparer(ctx)
299	if err != nil {
300		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "List", nil, "Failure preparing request")
301		return
302	}
303
304	resp, err := client.ListSender(req)
305	if err != nil {
306		result.desl.Response = autorest.Response{Response: resp}
307		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "List", resp, "Failure sending request")
308		return
309	}
310
311	result.desl, err = client.ListResponder(resp)
312	if err != nil {
313		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "List", resp, "Failure responding to request")
314		return
315	}
316	if result.desl.hasNextLink() && result.desl.IsEmpty() {
317		err = result.NextWithContext(ctx)
318		return
319	}
320
321	return
322}
323
324// ListPreparer prepares the List request.
325func (client DiskEncryptionSetsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
326	pathParameters := map[string]interface{}{
327		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
328	}
329
330	const APIVersion = "2020-12-01"
331	queryParameters := map[string]interface{}{
332		"api-version": APIVersion,
333	}
334
335	preparer := autorest.CreatePreparer(
336		autorest.AsGet(),
337		autorest.WithBaseURL(client.BaseURI),
338		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets", pathParameters),
339		autorest.WithQueryParameters(queryParameters))
340	return preparer.Prepare((&http.Request{}).WithContext(ctx))
341}
342
343// ListSender sends the List request. The method will close the
344// http.Response Body if it receives an error.
345func (client DiskEncryptionSetsClient) ListSender(req *http.Request) (*http.Response, error) {
346	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
347}
348
349// ListResponder handles the response to the List request. The method always
350// closes the http.Response Body.
351func (client DiskEncryptionSetsClient) ListResponder(resp *http.Response) (result DiskEncryptionSetList, err error) {
352	err = autorest.Respond(
353		resp,
354		azure.WithErrorUnlessStatusCode(http.StatusOK),
355		autorest.ByUnmarshallingJSON(&result),
356		autorest.ByClosing())
357	result.Response = autorest.Response{Response: resp}
358	return
359}
360
361// listNextResults retrieves the next set of results, if any.
362func (client DiskEncryptionSetsClient) listNextResults(ctx context.Context, lastResults DiskEncryptionSetList) (result DiskEncryptionSetList, err error) {
363	req, err := lastResults.diskEncryptionSetListPreparer(ctx)
364	if err != nil {
365		return result, autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listNextResults", nil, "Failure preparing next results request")
366	}
367	if req == nil {
368		return
369	}
370	resp, err := client.ListSender(req)
371	if err != nil {
372		result.Response = autorest.Response{Response: resp}
373		return result, autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listNextResults", resp, "Failure sending next results request")
374	}
375	result, err = client.ListResponder(resp)
376	if err != nil {
377		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listNextResults", resp, "Failure responding to next results request")
378	}
379	return
380}
381
382// ListComplete enumerates all values, automatically crossing page boundaries as required.
383func (client DiskEncryptionSetsClient) ListComplete(ctx context.Context) (result DiskEncryptionSetListIterator, err error) {
384	if tracing.IsEnabled() {
385		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.List")
386		defer func() {
387			sc := -1
388			if result.Response().Response.Response != nil {
389				sc = result.page.Response().Response.Response.StatusCode
390			}
391			tracing.EndSpan(ctx, sc, err)
392		}()
393	}
394	result.page, err = client.List(ctx)
395	return
396}
397
398// ListAssociatedResources lists all resources that are encrypted with this disk encryption set.
399// Parameters:
400// resourceGroupName - the name of the resource group.
401// diskEncryptionSetName - the name of the disk encryption set that is being created. The name can't be changed
402// after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The
403// maximum name length is 80 characters.
404func (client DiskEncryptionSetsClient) ListAssociatedResources(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (result ResourceURIListPage, err error) {
405	if tracing.IsEnabled() {
406		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.ListAssociatedResources")
407		defer func() {
408			sc := -1
409			if result.rul.Response.Response != nil {
410				sc = result.rul.Response.Response.StatusCode
411			}
412			tracing.EndSpan(ctx, sc, err)
413		}()
414	}
415	result.fn = client.listAssociatedResourcesNextResults
416	req, err := client.ListAssociatedResourcesPreparer(ctx, resourceGroupName, diskEncryptionSetName)
417	if err != nil {
418		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "ListAssociatedResources", nil, "Failure preparing request")
419		return
420	}
421
422	resp, err := client.ListAssociatedResourcesSender(req)
423	if err != nil {
424		result.rul.Response = autorest.Response{Response: resp}
425		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "ListAssociatedResources", resp, "Failure sending request")
426		return
427	}
428
429	result.rul, err = client.ListAssociatedResourcesResponder(resp)
430	if err != nil {
431		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "ListAssociatedResources", resp, "Failure responding to request")
432		return
433	}
434	if result.rul.hasNextLink() && result.rul.IsEmpty() {
435		err = result.NextWithContext(ctx)
436		return
437	}
438
439	return
440}
441
442// ListAssociatedResourcesPreparer prepares the ListAssociatedResources request.
443func (client DiskEncryptionSetsClient) ListAssociatedResourcesPreparer(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (*http.Request, error) {
444	pathParameters := map[string]interface{}{
445		"diskEncryptionSetName": autorest.Encode("path", diskEncryptionSetName),
446		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
447		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
448	}
449
450	const APIVersion = "2020-12-01"
451	queryParameters := map[string]interface{}{
452		"api-version": APIVersion,
453	}
454
455	preparer := autorest.CreatePreparer(
456		autorest.AsGet(),
457		autorest.WithBaseURL(client.BaseURI),
458		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", pathParameters),
459		autorest.WithQueryParameters(queryParameters))
460	return preparer.Prepare((&http.Request{}).WithContext(ctx))
461}
462
463// ListAssociatedResourcesSender sends the ListAssociatedResources request. The method will close the
464// http.Response Body if it receives an error.
465func (client DiskEncryptionSetsClient) ListAssociatedResourcesSender(req *http.Request) (*http.Response, error) {
466	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
467}
468
469// ListAssociatedResourcesResponder handles the response to the ListAssociatedResources request. The method always
470// closes the http.Response Body.
471func (client DiskEncryptionSetsClient) ListAssociatedResourcesResponder(resp *http.Response) (result ResourceURIList, err error) {
472	err = autorest.Respond(
473		resp,
474		azure.WithErrorUnlessStatusCode(http.StatusOK),
475		autorest.ByUnmarshallingJSON(&result),
476		autorest.ByClosing())
477	result.Response = autorest.Response{Response: resp}
478	return
479}
480
481// listAssociatedResourcesNextResults retrieves the next set of results, if any.
482func (client DiskEncryptionSetsClient) listAssociatedResourcesNextResults(ctx context.Context, lastResults ResourceURIList) (result ResourceURIList, err error) {
483	req, err := lastResults.resourceURIListPreparer(ctx)
484	if err != nil {
485		return result, autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listAssociatedResourcesNextResults", nil, "Failure preparing next results request")
486	}
487	if req == nil {
488		return
489	}
490	resp, err := client.ListAssociatedResourcesSender(req)
491	if err != nil {
492		result.Response = autorest.Response{Response: resp}
493		return result, autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listAssociatedResourcesNextResults", resp, "Failure sending next results request")
494	}
495	result, err = client.ListAssociatedResourcesResponder(resp)
496	if err != nil {
497		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listAssociatedResourcesNextResults", resp, "Failure responding to next results request")
498	}
499	return
500}
501
502// ListAssociatedResourcesComplete enumerates all values, automatically crossing page boundaries as required.
503func (client DiskEncryptionSetsClient) ListAssociatedResourcesComplete(ctx context.Context, resourceGroupName string, diskEncryptionSetName string) (result ResourceURIListIterator, err error) {
504	if tracing.IsEnabled() {
505		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.ListAssociatedResources")
506		defer func() {
507			sc := -1
508			if result.Response().Response.Response != nil {
509				sc = result.page.Response().Response.Response.StatusCode
510			}
511			tracing.EndSpan(ctx, sc, err)
512		}()
513	}
514	result.page, err = client.ListAssociatedResources(ctx, resourceGroupName, diskEncryptionSetName)
515	return
516}
517
518// ListByResourceGroup lists all the disk encryption sets under a resource group.
519// Parameters:
520// resourceGroupName - the name of the resource group.
521func (client DiskEncryptionSetsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DiskEncryptionSetListPage, err error) {
522	if tracing.IsEnabled() {
523		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.ListByResourceGroup")
524		defer func() {
525			sc := -1
526			if result.desl.Response.Response != nil {
527				sc = result.desl.Response.Response.StatusCode
528			}
529			tracing.EndSpan(ctx, sc, err)
530		}()
531	}
532	result.fn = client.listByResourceGroupNextResults
533	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
534	if err != nil {
535		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "ListByResourceGroup", nil, "Failure preparing request")
536		return
537	}
538
539	resp, err := client.ListByResourceGroupSender(req)
540	if err != nil {
541		result.desl.Response = autorest.Response{Response: resp}
542		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "ListByResourceGroup", resp, "Failure sending request")
543		return
544	}
545
546	result.desl, err = client.ListByResourceGroupResponder(resp)
547	if err != nil {
548		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "ListByResourceGroup", resp, "Failure responding to request")
549		return
550	}
551	if result.desl.hasNextLink() && result.desl.IsEmpty() {
552		err = result.NextWithContext(ctx)
553		return
554	}
555
556	return
557}
558
559// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
560func (client DiskEncryptionSetsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
561	pathParameters := map[string]interface{}{
562		"resourceGroupName": autorest.Encode("path", resourceGroupName),
563		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
564	}
565
566	const APIVersion = "2020-12-01"
567	queryParameters := map[string]interface{}{
568		"api-version": APIVersion,
569	}
570
571	preparer := autorest.CreatePreparer(
572		autorest.AsGet(),
573		autorest.WithBaseURL(client.BaseURI),
574		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", pathParameters),
575		autorest.WithQueryParameters(queryParameters))
576	return preparer.Prepare((&http.Request{}).WithContext(ctx))
577}
578
579// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
580// http.Response Body if it receives an error.
581func (client DiskEncryptionSetsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
582	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
583}
584
585// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
586// closes the http.Response Body.
587func (client DiskEncryptionSetsClient) ListByResourceGroupResponder(resp *http.Response) (result DiskEncryptionSetList, err error) {
588	err = autorest.Respond(
589		resp,
590		azure.WithErrorUnlessStatusCode(http.StatusOK),
591		autorest.ByUnmarshallingJSON(&result),
592		autorest.ByClosing())
593	result.Response = autorest.Response{Response: resp}
594	return
595}
596
597// listByResourceGroupNextResults retrieves the next set of results, if any.
598func (client DiskEncryptionSetsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DiskEncryptionSetList) (result DiskEncryptionSetList, err error) {
599	req, err := lastResults.diskEncryptionSetListPreparer(ctx)
600	if err != nil {
601		return result, autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
602	}
603	if req == nil {
604		return
605	}
606	resp, err := client.ListByResourceGroupSender(req)
607	if err != nil {
608		result.Response = autorest.Response{Response: resp}
609		return result, autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
610	}
611	result, err = client.ListByResourceGroupResponder(resp)
612	if err != nil {
613		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
614	}
615	return
616}
617
618// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
619func (client DiskEncryptionSetsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DiskEncryptionSetListIterator, err error) {
620	if tracing.IsEnabled() {
621		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.ListByResourceGroup")
622		defer func() {
623			sc := -1
624			if result.Response().Response.Response != nil {
625				sc = result.page.Response().Response.Response.StatusCode
626			}
627			tracing.EndSpan(ctx, sc, err)
628		}()
629	}
630	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
631	return
632}
633
634// Update updates (patches) a disk encryption set.
635// Parameters:
636// resourceGroupName - the name of the resource group.
637// diskEncryptionSetName - the name of the disk encryption set that is being created. The name can't be changed
638// after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The
639// maximum name length is 80 characters.
640// diskEncryptionSet - disk encryption set object supplied in the body of the Patch disk encryption set
641// operation.
642func (client DiskEncryptionSetsClient) Update(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, diskEncryptionSet DiskEncryptionSetUpdate) (result DiskEncryptionSetsUpdateFuture, err error) {
643	if tracing.IsEnabled() {
644		ctx = tracing.StartSpan(ctx, fqdn+"/DiskEncryptionSetsClient.Update")
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	req, err := client.UpdatePreparer(ctx, resourceGroupName, diskEncryptionSetName, diskEncryptionSet)
654	if err != nil {
655		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Update", nil, "Failure preparing request")
656		return
657	}
658
659	result, err = client.UpdateSender(req)
660	if err != nil {
661		err = autorest.NewErrorWithError(err, "compute.DiskEncryptionSetsClient", "Update", nil, "Failure sending request")
662		return
663	}
664
665	return
666}
667
668// UpdatePreparer prepares the Update request.
669func (client DiskEncryptionSetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, diskEncryptionSet DiskEncryptionSetUpdate) (*http.Request, error) {
670	pathParameters := map[string]interface{}{
671		"diskEncryptionSetName": autorest.Encode("path", diskEncryptionSetName),
672		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
673		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
674	}
675
676	const APIVersion = "2020-12-01"
677	queryParameters := map[string]interface{}{
678		"api-version": APIVersion,
679	}
680
681	preparer := autorest.CreatePreparer(
682		autorest.AsContentType("application/json; charset=utf-8"),
683		autorest.AsPatch(),
684		autorest.WithBaseURL(client.BaseURI),
685		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", pathParameters),
686		autorest.WithJSON(diskEncryptionSet),
687		autorest.WithQueryParameters(queryParameters))
688	return preparer.Prepare((&http.Request{}).WithContext(ctx))
689}
690
691// UpdateSender sends the Update request. The method will close the
692// http.Response Body if it receives an error.
693func (client DiskEncryptionSetsClient) UpdateSender(req *http.Request) (future DiskEncryptionSetsUpdateFuture, err error) {
694	var resp *http.Response
695	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
696	if err != nil {
697		return
698	}
699	var azf azure.Future
700	azf, err = azure.NewFutureFromResponse(resp)
701	future.FutureAPI = &azf
702	future.Result = future.result
703	return
704}
705
706// UpdateResponder handles the response to the Update request. The method always
707// closes the http.Response Body.
708func (client DiskEncryptionSetsClient) UpdateResponder(resp *http.Response) (result DiskEncryptionSet, err error) {
709	err = autorest.Respond(
710		resp,
711		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
712		autorest.ByUnmarshallingJSON(&result),
713		autorest.ByClosing())
714	result.Response = autorest.Response{Response: resp}
715	return
716}
717