1package storagepool
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// DiskPoolsClient is the client for the DiskPools methods of the Storagepool service.
19type DiskPoolsClient struct {
20	BaseClient
21}
22
23// NewDiskPoolsClient creates an instance of the DiskPoolsClient client.
24func NewDiskPoolsClient(subscriptionID string) DiskPoolsClient {
25	return NewDiskPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewDiskPoolsClientWithBaseURI creates an instance of the DiskPoolsClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewDiskPoolsClientWithBaseURI(baseURI string, subscriptionID string) DiskPoolsClient {
31	return DiskPoolsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate create or Update Disk pool.
35// Parameters:
36// resourceGroupName - the name of the resource group. The name is case insensitive.
37// diskPoolName - the name of the Disk Pool.
38// diskPoolCreatePayload - request payload for Disk Pool create operation
39func (client DiskPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, diskPoolName string, diskPoolCreatePayload DiskPoolCreate) (result DiskPoolsCreateOrUpdateFuture, err error) {
40	if tracing.IsEnabled() {
41		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.CreateOrUpdate")
42		defer func() {
43			sc := -1
44			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
45				sc = result.FutureAPI.Response().StatusCode
46			}
47			tracing.EndSpan(ctx, sc, err)
48		}()
49	}
50	if err := validation.Validate([]validation.Validation{
51		{TargetValue: client.SubscriptionID,
52			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
53		{TargetValue: resourceGroupName,
54			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
55				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
56				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}},
57		{TargetValue: diskPoolCreatePayload,
58			Constraints: []validation.Constraint{{Target: "diskPoolCreatePayload.Sku", Name: validation.Null, Rule: true,
59				Chain: []validation.Constraint{{Target: "diskPoolCreatePayload.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}},
60				{Target: "diskPoolCreatePayload.DiskPoolCreateProperties", Name: validation.Null, Rule: true,
61					Chain: []validation.Constraint{{Target: "diskPoolCreatePayload.DiskPoolCreateProperties.SubnetID", Name: validation.Null, Rule: true, Chain: nil}}},
62				{Target: "diskPoolCreatePayload.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
63		return result, validation.NewError("storagepool.DiskPoolsClient", "CreateOrUpdate", err.Error())
64	}
65
66	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, diskPoolName, diskPoolCreatePayload)
67	if err != nil {
68		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "CreateOrUpdate", nil, "Failure preparing request")
69		return
70	}
71
72	result, err = client.CreateOrUpdateSender(req)
73	if err != nil {
74		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "CreateOrUpdate", nil, "Failure sending request")
75		return
76	}
77
78	return
79}
80
81// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
82func (client DiskPoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, diskPoolName string, diskPoolCreatePayload DiskPoolCreate) (*http.Request, error) {
83	pathParameters := map[string]interface{}{
84		"diskPoolName":      autorest.Encode("path", diskPoolName),
85		"resourceGroupName": autorest.Encode("path", resourceGroupName),
86		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
87	}
88
89	const APIVersion = "2021-04-01-preview"
90	queryParameters := map[string]interface{}{
91		"api-version": APIVersion,
92	}
93
94	diskPoolCreatePayload.ID = nil
95	diskPoolCreatePayload.Name = nil
96	diskPoolCreatePayload.Type = nil
97	preparer := autorest.CreatePreparer(
98		autorest.AsContentType("application/json; charset=utf-8"),
99		autorest.AsPut(),
100		autorest.WithBaseURL(client.BaseURI),
101		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}", pathParameters),
102		autorest.WithJSON(diskPoolCreatePayload),
103		autorest.WithQueryParameters(queryParameters))
104	return preparer.Prepare((&http.Request{}).WithContext(ctx))
105}
106
107// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
108// http.Response Body if it receives an error.
109func (client DiskPoolsClient) CreateOrUpdateSender(req *http.Request) (future DiskPoolsCreateOrUpdateFuture, err error) {
110	var resp *http.Response
111	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
112	if err != nil {
113		return
114	}
115	var azf azure.Future
116	azf, err = azure.NewFutureFromResponse(resp)
117	future.FutureAPI = &azf
118	future.Result = future.result
119	return
120}
121
122// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
123// closes the http.Response Body.
124func (client DiskPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result DiskPool, err error) {
125	err = autorest.Respond(
126		resp,
127		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
128		autorest.ByUnmarshallingJSON(&result),
129		autorest.ByClosing())
130	result.Response = autorest.Response{Response: resp}
131	return
132}
133
134// Deallocate shuts down the Disk Pool and releases the compute resources. You are not billed for the compute resources
135// that this Disk Pool uses.
136// Parameters:
137// resourceGroupName - the name of the resource group. The name is case insensitive.
138// diskPoolName - the name of the Disk Pool.
139func (client DiskPoolsClient) Deallocate(ctx context.Context, resourceGroupName string, diskPoolName string) (result DiskPoolsDeallocateFuture, err error) {
140	if tracing.IsEnabled() {
141		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.Deallocate")
142		defer func() {
143			sc := -1
144			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
145				sc = result.FutureAPI.Response().StatusCode
146			}
147			tracing.EndSpan(ctx, sc, err)
148		}()
149	}
150	if err := validation.Validate([]validation.Validation{
151		{TargetValue: client.SubscriptionID,
152			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
153		{TargetValue: resourceGroupName,
154			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
155				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
156				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
157		return result, validation.NewError("storagepool.DiskPoolsClient", "Deallocate", err.Error())
158	}
159
160	req, err := client.DeallocatePreparer(ctx, resourceGroupName, diskPoolName)
161	if err != nil {
162		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Deallocate", nil, "Failure preparing request")
163		return
164	}
165
166	result, err = client.DeallocateSender(req)
167	if err != nil {
168		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Deallocate", nil, "Failure sending request")
169		return
170	}
171
172	return
173}
174
175// DeallocatePreparer prepares the Deallocate request.
176func (client DiskPoolsClient) DeallocatePreparer(ctx context.Context, resourceGroupName string, diskPoolName string) (*http.Request, error) {
177	pathParameters := map[string]interface{}{
178		"diskPoolName":      autorest.Encode("path", diskPoolName),
179		"resourceGroupName": autorest.Encode("path", resourceGroupName),
180		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
181	}
182
183	const APIVersion = "2021-04-01-preview"
184	queryParameters := map[string]interface{}{
185		"api-version": APIVersion,
186	}
187
188	preparer := autorest.CreatePreparer(
189		autorest.AsPost(),
190		autorest.WithBaseURL(client.BaseURI),
191		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}/deallocate", pathParameters),
192		autorest.WithQueryParameters(queryParameters))
193	return preparer.Prepare((&http.Request{}).WithContext(ctx))
194}
195
196// DeallocateSender sends the Deallocate request. The method will close the
197// http.Response Body if it receives an error.
198func (client DiskPoolsClient) DeallocateSender(req *http.Request) (future DiskPoolsDeallocateFuture, err error) {
199	var resp *http.Response
200	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
201	if err != nil {
202		return
203	}
204	var azf azure.Future
205	azf, err = azure.NewFutureFromResponse(resp)
206	future.FutureAPI = &azf
207	future.Result = future.result
208	return
209}
210
211// DeallocateResponder handles the response to the Deallocate request. The method always
212// closes the http.Response Body.
213func (client DiskPoolsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) {
214	err = autorest.Respond(
215		resp,
216		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
217		autorest.ByClosing())
218	result.Response = resp
219	return
220}
221
222// Delete delete a Disk pool.
223// Parameters:
224// resourceGroupName - the name of the resource group. The name is case insensitive.
225// diskPoolName - the name of the Disk Pool.
226func (client DiskPoolsClient) Delete(ctx context.Context, resourceGroupName string, diskPoolName string) (result DiskPoolsDeleteFuture, err error) {
227	if tracing.IsEnabled() {
228		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.Delete")
229		defer func() {
230			sc := -1
231			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
232				sc = result.FutureAPI.Response().StatusCode
233			}
234			tracing.EndSpan(ctx, sc, err)
235		}()
236	}
237	if err := validation.Validate([]validation.Validation{
238		{TargetValue: client.SubscriptionID,
239			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
240		{TargetValue: resourceGroupName,
241			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
242				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
243				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
244		return result, validation.NewError("storagepool.DiskPoolsClient", "Delete", err.Error())
245	}
246
247	req, err := client.DeletePreparer(ctx, resourceGroupName, diskPoolName)
248	if err != nil {
249		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Delete", nil, "Failure preparing request")
250		return
251	}
252
253	result, err = client.DeleteSender(req)
254	if err != nil {
255		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Delete", nil, "Failure sending request")
256		return
257	}
258
259	return
260}
261
262// DeletePreparer prepares the Delete request.
263func (client DiskPoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, diskPoolName string) (*http.Request, error) {
264	pathParameters := map[string]interface{}{
265		"diskPoolName":      autorest.Encode("path", diskPoolName),
266		"resourceGroupName": autorest.Encode("path", resourceGroupName),
267		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
268	}
269
270	const APIVersion = "2021-04-01-preview"
271	queryParameters := map[string]interface{}{
272		"api-version": APIVersion,
273	}
274
275	preparer := autorest.CreatePreparer(
276		autorest.AsDelete(),
277		autorest.WithBaseURL(client.BaseURI),
278		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}", pathParameters),
279		autorest.WithQueryParameters(queryParameters))
280	return preparer.Prepare((&http.Request{}).WithContext(ctx))
281}
282
283// DeleteSender sends the Delete request. The method will close the
284// http.Response Body if it receives an error.
285func (client DiskPoolsClient) DeleteSender(req *http.Request) (future DiskPoolsDeleteFuture, err error) {
286	var resp *http.Response
287	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
288	if err != nil {
289		return
290	}
291	var azf azure.Future
292	azf, err = azure.NewFutureFromResponse(resp)
293	future.FutureAPI = &azf
294	future.Result = future.result
295	return
296}
297
298// DeleteResponder handles the response to the Delete request. The method always
299// closes the http.Response Body.
300func (client DiskPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
301	err = autorest.Respond(
302		resp,
303		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
304		autorest.ByClosing())
305	result.Response = resp
306	return
307}
308
309// Get get a Disk pool.
310// Parameters:
311// resourceGroupName - the name of the resource group. The name is case insensitive.
312// diskPoolName - the name of the Disk Pool.
313func (client DiskPoolsClient) Get(ctx context.Context, resourceGroupName string, diskPoolName string) (result DiskPool, err error) {
314	if tracing.IsEnabled() {
315		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.Get")
316		defer func() {
317			sc := -1
318			if result.Response.Response != nil {
319				sc = result.Response.Response.StatusCode
320			}
321			tracing.EndSpan(ctx, sc, err)
322		}()
323	}
324	if err := validation.Validate([]validation.Validation{
325		{TargetValue: client.SubscriptionID,
326			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
327		{TargetValue: resourceGroupName,
328			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
329				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
330				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
331		return result, validation.NewError("storagepool.DiskPoolsClient", "Get", err.Error())
332	}
333
334	req, err := client.GetPreparer(ctx, resourceGroupName, diskPoolName)
335	if err != nil {
336		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Get", nil, "Failure preparing request")
337		return
338	}
339
340	resp, err := client.GetSender(req)
341	if err != nil {
342		result.Response = autorest.Response{Response: resp}
343		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Get", resp, "Failure sending request")
344		return
345	}
346
347	result, err = client.GetResponder(resp)
348	if err != nil {
349		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Get", resp, "Failure responding to request")
350		return
351	}
352
353	return
354}
355
356// GetPreparer prepares the Get request.
357func (client DiskPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, diskPoolName string) (*http.Request, error) {
358	pathParameters := map[string]interface{}{
359		"diskPoolName":      autorest.Encode("path", diskPoolName),
360		"resourceGroupName": autorest.Encode("path", resourceGroupName),
361		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
362	}
363
364	const APIVersion = "2021-04-01-preview"
365	queryParameters := map[string]interface{}{
366		"api-version": APIVersion,
367	}
368
369	preparer := autorest.CreatePreparer(
370		autorest.AsGet(),
371		autorest.WithBaseURL(client.BaseURI),
372		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}", pathParameters),
373		autorest.WithQueryParameters(queryParameters))
374	return preparer.Prepare((&http.Request{}).WithContext(ctx))
375}
376
377// GetSender sends the Get request. The method will close the
378// http.Response Body if it receives an error.
379func (client DiskPoolsClient) GetSender(req *http.Request) (*http.Response, error) {
380	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
381}
382
383// GetResponder handles the response to the Get request. The method always
384// closes the http.Response Body.
385func (client DiskPoolsClient) GetResponder(resp *http.Response) (result DiskPool, err error) {
386	err = autorest.Respond(
387		resp,
388		azure.WithErrorUnlessStatusCode(http.StatusOK),
389		autorest.ByUnmarshallingJSON(&result),
390		autorest.ByClosing())
391	result.Response = autorest.Response{Response: resp}
392	return
393}
394
395// ListByResourceGroup gets a list of DiskPools in a resource group.
396// Parameters:
397// resourceGroupName - the name of the resource group. The name is case insensitive.
398func (client DiskPoolsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DiskPoolListResultPage, err error) {
399	if tracing.IsEnabled() {
400		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.ListByResourceGroup")
401		defer func() {
402			sc := -1
403			if result.dplr.Response.Response != nil {
404				sc = result.dplr.Response.Response.StatusCode
405			}
406			tracing.EndSpan(ctx, sc, err)
407		}()
408	}
409	if err := validation.Validate([]validation.Validation{
410		{TargetValue: client.SubscriptionID,
411			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
412		{TargetValue: resourceGroupName,
413			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
414				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
415				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
416		return result, validation.NewError("storagepool.DiskPoolsClient", "ListByResourceGroup", err.Error())
417	}
418
419	result.fn = client.listByResourceGroupNextResults
420	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
421	if err != nil {
422		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListByResourceGroup", nil, "Failure preparing request")
423		return
424	}
425
426	resp, err := client.ListByResourceGroupSender(req)
427	if err != nil {
428		result.dplr.Response = autorest.Response{Response: resp}
429		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListByResourceGroup", resp, "Failure sending request")
430		return
431	}
432
433	result.dplr, err = client.ListByResourceGroupResponder(resp)
434	if err != nil {
435		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListByResourceGroup", resp, "Failure responding to request")
436		return
437	}
438	if result.dplr.hasNextLink() && result.dplr.IsEmpty() {
439		err = result.NextWithContext(ctx)
440		return
441	}
442
443	return
444}
445
446// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
447func (client DiskPoolsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
448	pathParameters := map[string]interface{}{
449		"resourceGroupName": autorest.Encode("path", resourceGroupName),
450		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
451	}
452
453	const APIVersion = "2021-04-01-preview"
454	queryParameters := map[string]interface{}{
455		"api-version": APIVersion,
456	}
457
458	preparer := autorest.CreatePreparer(
459		autorest.AsGet(),
460		autorest.WithBaseURL(client.BaseURI),
461		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools", pathParameters),
462		autorest.WithQueryParameters(queryParameters))
463	return preparer.Prepare((&http.Request{}).WithContext(ctx))
464}
465
466// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
467// http.Response Body if it receives an error.
468func (client DiskPoolsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
469	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
470}
471
472// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
473// closes the http.Response Body.
474func (client DiskPoolsClient) ListByResourceGroupResponder(resp *http.Response) (result DiskPoolListResult, err error) {
475	err = autorest.Respond(
476		resp,
477		azure.WithErrorUnlessStatusCode(http.StatusOK),
478		autorest.ByUnmarshallingJSON(&result),
479		autorest.ByClosing())
480	result.Response = autorest.Response{Response: resp}
481	return
482}
483
484// listByResourceGroupNextResults retrieves the next set of results, if any.
485func (client DiskPoolsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DiskPoolListResult) (result DiskPoolListResult, err error) {
486	req, err := lastResults.diskPoolListResultPreparer(ctx)
487	if err != nil {
488		return result, autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
489	}
490	if req == nil {
491		return
492	}
493	resp, err := client.ListByResourceGroupSender(req)
494	if err != nil {
495		result.Response = autorest.Response{Response: resp}
496		return result, autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
497	}
498	result, err = client.ListByResourceGroupResponder(resp)
499	if err != nil {
500		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
501	}
502	return
503}
504
505// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
506func (client DiskPoolsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DiskPoolListResultIterator, err error) {
507	if tracing.IsEnabled() {
508		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.ListByResourceGroup")
509		defer func() {
510			sc := -1
511			if result.Response().Response.Response != nil {
512				sc = result.page.Response().Response.Response.StatusCode
513			}
514			tracing.EndSpan(ctx, sc, err)
515		}()
516	}
517	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
518	return
519}
520
521// ListBySubscription gets a list of Disk Pools in a subscription
522func (client DiskPoolsClient) ListBySubscription(ctx context.Context) (result DiskPoolListResultPage, err error) {
523	if tracing.IsEnabled() {
524		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.ListBySubscription")
525		defer func() {
526			sc := -1
527			if result.dplr.Response.Response != nil {
528				sc = result.dplr.Response.Response.StatusCode
529			}
530			tracing.EndSpan(ctx, sc, err)
531		}()
532	}
533	if err := validation.Validate([]validation.Validation{
534		{TargetValue: client.SubscriptionID,
535			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
536		return result, validation.NewError("storagepool.DiskPoolsClient", "ListBySubscription", err.Error())
537	}
538
539	result.fn = client.listBySubscriptionNextResults
540	req, err := client.ListBySubscriptionPreparer(ctx)
541	if err != nil {
542		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListBySubscription", nil, "Failure preparing request")
543		return
544	}
545
546	resp, err := client.ListBySubscriptionSender(req)
547	if err != nil {
548		result.dplr.Response = autorest.Response{Response: resp}
549		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListBySubscription", resp, "Failure sending request")
550		return
551	}
552
553	result.dplr, err = client.ListBySubscriptionResponder(resp)
554	if err != nil {
555		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListBySubscription", resp, "Failure responding to request")
556		return
557	}
558	if result.dplr.hasNextLink() && result.dplr.IsEmpty() {
559		err = result.NextWithContext(ctx)
560		return
561	}
562
563	return
564}
565
566// ListBySubscriptionPreparer prepares the ListBySubscription request.
567func (client DiskPoolsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
568	pathParameters := map[string]interface{}{
569		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
570	}
571
572	const APIVersion = "2021-04-01-preview"
573	queryParameters := map[string]interface{}{
574		"api-version": APIVersion,
575	}
576
577	preparer := autorest.CreatePreparer(
578		autorest.AsGet(),
579		autorest.WithBaseURL(client.BaseURI),
580		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StoragePool/diskPools", pathParameters),
581		autorest.WithQueryParameters(queryParameters))
582	return preparer.Prepare((&http.Request{}).WithContext(ctx))
583}
584
585// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
586// http.Response Body if it receives an error.
587func (client DiskPoolsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
588	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
589}
590
591// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
592// closes the http.Response Body.
593func (client DiskPoolsClient) ListBySubscriptionResponder(resp *http.Response) (result DiskPoolListResult, err error) {
594	err = autorest.Respond(
595		resp,
596		azure.WithErrorUnlessStatusCode(http.StatusOK),
597		autorest.ByUnmarshallingJSON(&result),
598		autorest.ByClosing())
599	result.Response = autorest.Response{Response: resp}
600	return
601}
602
603// listBySubscriptionNextResults retrieves the next set of results, if any.
604func (client DiskPoolsClient) listBySubscriptionNextResults(ctx context.Context, lastResults DiskPoolListResult) (result DiskPoolListResult, err error) {
605	req, err := lastResults.diskPoolListResultPreparer(ctx)
606	if err != nil {
607		return result, autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
608	}
609	if req == nil {
610		return
611	}
612	resp, err := client.ListBySubscriptionSender(req)
613	if err != nil {
614		result.Response = autorest.Response{Response: resp}
615		return result, autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
616	}
617	result, err = client.ListBySubscriptionResponder(resp)
618	if err != nil {
619		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
620	}
621	return
622}
623
624// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
625func (client DiskPoolsClient) ListBySubscriptionComplete(ctx context.Context) (result DiskPoolListResultIterator, err error) {
626	if tracing.IsEnabled() {
627		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.ListBySubscription")
628		defer func() {
629			sc := -1
630			if result.Response().Response.Response != nil {
631				sc = result.page.Response().Response.Response.StatusCode
632			}
633			tracing.EndSpan(ctx, sc, err)
634		}()
635	}
636	result.page, err = client.ListBySubscription(ctx)
637	return
638}
639
640// ListOutboundNetworkDependenciesEndpoints gets the network endpoints of all outbound dependencies of a Disk Pool
641// Parameters:
642// resourceGroupName - the name of the resource group. The name is case insensitive.
643// diskPoolName - the name of the Disk Pool.
644func (client DiskPoolsClient) ListOutboundNetworkDependenciesEndpoints(ctx context.Context, resourceGroupName string, diskPoolName string) (result OutboundEnvironmentEndpointListPage, err error) {
645	if tracing.IsEnabled() {
646		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.ListOutboundNetworkDependenciesEndpoints")
647		defer func() {
648			sc := -1
649			if result.oeel.Response.Response != nil {
650				sc = result.oeel.Response.Response.StatusCode
651			}
652			tracing.EndSpan(ctx, sc, err)
653		}()
654	}
655	if err := validation.Validate([]validation.Validation{
656		{TargetValue: client.SubscriptionID,
657			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
658		{TargetValue: resourceGroupName,
659			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
660				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
661				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
662		return result, validation.NewError("storagepool.DiskPoolsClient", "ListOutboundNetworkDependenciesEndpoints", err.Error())
663	}
664
665	result.fn = client.listOutboundNetworkDependenciesEndpointsNextResults
666	req, err := client.ListOutboundNetworkDependenciesEndpointsPreparer(ctx, resourceGroupName, diskPoolName)
667	if err != nil {
668		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListOutboundNetworkDependenciesEndpoints", nil, "Failure preparing request")
669		return
670	}
671
672	resp, err := client.ListOutboundNetworkDependenciesEndpointsSender(req)
673	if err != nil {
674		result.oeel.Response = autorest.Response{Response: resp}
675		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListOutboundNetworkDependenciesEndpoints", resp, "Failure sending request")
676		return
677	}
678
679	result.oeel, err = client.ListOutboundNetworkDependenciesEndpointsResponder(resp)
680	if err != nil {
681		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "ListOutboundNetworkDependenciesEndpoints", resp, "Failure responding to request")
682		return
683	}
684	if result.oeel.hasNextLink() && result.oeel.IsEmpty() {
685		err = result.NextWithContext(ctx)
686		return
687	}
688
689	return
690}
691
692// ListOutboundNetworkDependenciesEndpointsPreparer prepares the ListOutboundNetworkDependenciesEndpoints request.
693func (client DiskPoolsClient) ListOutboundNetworkDependenciesEndpointsPreparer(ctx context.Context, resourceGroupName string, diskPoolName string) (*http.Request, error) {
694	pathParameters := map[string]interface{}{
695		"diskPoolName":      autorest.Encode("path", diskPoolName),
696		"resourceGroupName": autorest.Encode("path", resourceGroupName),
697		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
698	}
699
700	const APIVersion = "2021-04-01-preview"
701	queryParameters := map[string]interface{}{
702		"api-version": APIVersion,
703	}
704
705	preparer := autorest.CreatePreparer(
706		autorest.AsGet(),
707		autorest.WithBaseURL(client.BaseURI),
708		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}/outboundNetworkDependenciesEndpoints", pathParameters),
709		autorest.WithQueryParameters(queryParameters))
710	return preparer.Prepare((&http.Request{}).WithContext(ctx))
711}
712
713// ListOutboundNetworkDependenciesEndpointsSender sends the ListOutboundNetworkDependenciesEndpoints request. The method will close the
714// http.Response Body if it receives an error.
715func (client DiskPoolsClient) ListOutboundNetworkDependenciesEndpointsSender(req *http.Request) (*http.Response, error) {
716	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
717}
718
719// ListOutboundNetworkDependenciesEndpointsResponder handles the response to the ListOutboundNetworkDependenciesEndpoints request. The method always
720// closes the http.Response Body.
721func (client DiskPoolsClient) ListOutboundNetworkDependenciesEndpointsResponder(resp *http.Response) (result OutboundEnvironmentEndpointList, err error) {
722	err = autorest.Respond(
723		resp,
724		azure.WithErrorUnlessStatusCode(http.StatusOK),
725		autorest.ByUnmarshallingJSON(&result),
726		autorest.ByClosing())
727	result.Response = autorest.Response{Response: resp}
728	return
729}
730
731// listOutboundNetworkDependenciesEndpointsNextResults retrieves the next set of results, if any.
732func (client DiskPoolsClient) listOutboundNetworkDependenciesEndpointsNextResults(ctx context.Context, lastResults OutboundEnvironmentEndpointList) (result OutboundEnvironmentEndpointList, err error) {
733	req, err := lastResults.outboundEnvironmentEndpointListPreparer(ctx)
734	if err != nil {
735		return result, autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listOutboundNetworkDependenciesEndpointsNextResults", nil, "Failure preparing next results request")
736	}
737	if req == nil {
738		return
739	}
740	resp, err := client.ListOutboundNetworkDependenciesEndpointsSender(req)
741	if err != nil {
742		result.Response = autorest.Response{Response: resp}
743		return result, autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listOutboundNetworkDependenciesEndpointsNextResults", resp, "Failure sending next results request")
744	}
745	result, err = client.ListOutboundNetworkDependenciesEndpointsResponder(resp)
746	if err != nil {
747		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "listOutboundNetworkDependenciesEndpointsNextResults", resp, "Failure responding to next results request")
748	}
749	return
750}
751
752// ListOutboundNetworkDependenciesEndpointsComplete enumerates all values, automatically crossing page boundaries as required.
753func (client DiskPoolsClient) ListOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, resourceGroupName string, diskPoolName string) (result OutboundEnvironmentEndpointListIterator, err error) {
754	if tracing.IsEnabled() {
755		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.ListOutboundNetworkDependenciesEndpoints")
756		defer func() {
757			sc := -1
758			if result.Response().Response.Response != nil {
759				sc = result.page.Response().Response.Response.StatusCode
760			}
761			tracing.EndSpan(ctx, sc, err)
762		}()
763	}
764	result.page, err = client.ListOutboundNetworkDependenciesEndpoints(ctx, resourceGroupName, diskPoolName)
765	return
766}
767
768// Start the operation to start a Disk Pool.
769// Parameters:
770// resourceGroupName - the name of the resource group. The name is case insensitive.
771// diskPoolName - the name of the Disk Pool.
772func (client DiskPoolsClient) Start(ctx context.Context, resourceGroupName string, diskPoolName string) (result DiskPoolsStartFuture, err error) {
773	if tracing.IsEnabled() {
774		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.Start")
775		defer func() {
776			sc := -1
777			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
778				sc = result.FutureAPI.Response().StatusCode
779			}
780			tracing.EndSpan(ctx, sc, err)
781		}()
782	}
783	if err := validation.Validate([]validation.Validation{
784		{TargetValue: client.SubscriptionID,
785			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
786		{TargetValue: resourceGroupName,
787			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
788				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
789				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
790		return result, validation.NewError("storagepool.DiskPoolsClient", "Start", err.Error())
791	}
792
793	req, err := client.StartPreparer(ctx, resourceGroupName, diskPoolName)
794	if err != nil {
795		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Start", nil, "Failure preparing request")
796		return
797	}
798
799	result, err = client.StartSender(req)
800	if err != nil {
801		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Start", nil, "Failure sending request")
802		return
803	}
804
805	return
806}
807
808// StartPreparer prepares the Start request.
809func (client DiskPoolsClient) StartPreparer(ctx context.Context, resourceGroupName string, diskPoolName string) (*http.Request, error) {
810	pathParameters := map[string]interface{}{
811		"diskPoolName":      autorest.Encode("path", diskPoolName),
812		"resourceGroupName": autorest.Encode("path", resourceGroupName),
813		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
814	}
815
816	const APIVersion = "2021-04-01-preview"
817	queryParameters := map[string]interface{}{
818		"api-version": APIVersion,
819	}
820
821	preparer := autorest.CreatePreparer(
822		autorest.AsPost(),
823		autorest.WithBaseURL(client.BaseURI),
824		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}/start", pathParameters),
825		autorest.WithQueryParameters(queryParameters))
826	return preparer.Prepare((&http.Request{}).WithContext(ctx))
827}
828
829// StartSender sends the Start request. The method will close the
830// http.Response Body if it receives an error.
831func (client DiskPoolsClient) StartSender(req *http.Request) (future DiskPoolsStartFuture, err error) {
832	var resp *http.Response
833	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
834	if err != nil {
835		return
836	}
837	var azf azure.Future
838	azf, err = azure.NewFutureFromResponse(resp)
839	future.FutureAPI = &azf
840	future.Result = future.result
841	return
842}
843
844// StartResponder handles the response to the Start request. The method always
845// closes the http.Response Body.
846func (client DiskPoolsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
847	err = autorest.Respond(
848		resp,
849		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
850		autorest.ByClosing())
851	result.Response = resp
852	return
853}
854
855// Update update a Disk pool.
856// Parameters:
857// resourceGroupName - the name of the resource group. The name is case insensitive.
858// diskPoolName - the name of the Disk Pool.
859// diskPoolUpdatePayload - request payload for Disk Pool update operation.
860func (client DiskPoolsClient) Update(ctx context.Context, resourceGroupName string, diskPoolName string, diskPoolUpdatePayload DiskPoolUpdate) (result DiskPoolsUpdateFuture, err error) {
861	if tracing.IsEnabled() {
862		ctx = tracing.StartSpan(ctx, fqdn+"/DiskPoolsClient.Update")
863		defer func() {
864			sc := -1
865			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
866				sc = result.FutureAPI.Response().StatusCode
867			}
868			tracing.EndSpan(ctx, sc, err)
869		}()
870	}
871	if err := validation.Validate([]validation.Validation{
872		{TargetValue: client.SubscriptionID,
873			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
874		{TargetValue: resourceGroupName,
875			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
876				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
877				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]*[0-9A-Za-z]$`, Chain: nil}}}}); err != nil {
878		return result, validation.NewError("storagepool.DiskPoolsClient", "Update", err.Error())
879	}
880
881	req, err := client.UpdatePreparer(ctx, resourceGroupName, diskPoolName, diskPoolUpdatePayload)
882	if err != nil {
883		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Update", nil, "Failure preparing request")
884		return
885	}
886
887	result, err = client.UpdateSender(req)
888	if err != nil {
889		err = autorest.NewErrorWithError(err, "storagepool.DiskPoolsClient", "Update", nil, "Failure sending request")
890		return
891	}
892
893	return
894}
895
896// UpdatePreparer prepares the Update request.
897func (client DiskPoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, diskPoolName string, diskPoolUpdatePayload DiskPoolUpdate) (*http.Request, error) {
898	pathParameters := map[string]interface{}{
899		"diskPoolName":      autorest.Encode("path", diskPoolName),
900		"resourceGroupName": autorest.Encode("path", resourceGroupName),
901		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
902	}
903
904	const APIVersion = "2021-04-01-preview"
905	queryParameters := map[string]interface{}{
906		"api-version": APIVersion,
907	}
908
909	preparer := autorest.CreatePreparer(
910		autorest.AsContentType("application/json; charset=utf-8"),
911		autorest.AsPatch(),
912		autorest.WithBaseURL(client.BaseURI),
913		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}", pathParameters),
914		autorest.WithJSON(diskPoolUpdatePayload),
915		autorest.WithQueryParameters(queryParameters))
916	return preparer.Prepare((&http.Request{}).WithContext(ctx))
917}
918
919// UpdateSender sends the Update request. The method will close the
920// http.Response Body if it receives an error.
921func (client DiskPoolsClient) UpdateSender(req *http.Request) (future DiskPoolsUpdateFuture, err error) {
922	var resp *http.Response
923	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
924	if err != nil {
925		return
926	}
927	var azf azure.Future
928	azf, err = azure.NewFutureFromResponse(resp)
929	future.FutureAPI = &azf
930	future.Result = future.result
931	return
932}
933
934// UpdateResponder handles the response to the Update request. The method always
935// closes the http.Response Body.
936func (client DiskPoolsClient) UpdateResponder(resp *http.Response) (result DiskPool, err error) {
937	err = autorest.Respond(
938		resp,
939		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
940		autorest.ByUnmarshallingJSON(&result),
941		autorest.ByClosing())
942	result.Response = autorest.Response{Response: resp}
943	return
944}
945