1package storsimple
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// VolumesClient is the client for the Volumes methods of the Storsimple service.
19type VolumesClient struct {
20	BaseClient
21}
22
23// NewVolumesClient creates an instance of the VolumesClient client.
24func NewVolumesClient(subscriptionID string) VolumesClient {
25	return NewVolumesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewVolumesClientWithBaseURI creates an instance of the VolumesClient client using a custom endpoint.  Use this when
29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewVolumesClientWithBaseURI(baseURI string, subscriptionID string) VolumesClient {
31	return VolumesClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate creates or updates the volume.
35// Parameters:
36// deviceName - the device name
37// volumeContainerName - the volume container name.
38// volumeName - the volume name.
39// parameters - volume to be created or updated.
40// resourceGroupName - the resource group name
41// managerName - the manager name
42func (client VolumesClient) CreateOrUpdate(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, parameters Volume, resourceGroupName string, managerName string) (result VolumesCreateOrUpdateFuture, err error) {
43	if tracing.IsEnabled() {
44		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.CreateOrUpdate")
45		defer func() {
46			sc := -1
47			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
48				sc = result.FutureAPI.Response().StatusCode
49			}
50			tracing.EndSpan(ctx, sc, err)
51		}()
52	}
53	if err := validation.Validate([]validation.Validation{
54		{TargetValue: parameters,
55			Constraints: []validation.Constraint{{Target: "parameters.VolumeProperties", Name: validation.Null, Rule: true,
56				Chain: []validation.Constraint{{Target: "parameters.VolumeProperties.SizeInBytes", Name: validation.Null, Rule: true, Chain: nil},
57					{Target: "parameters.VolumeProperties.AccessControlRecordIds", Name: validation.Null, Rule: true, Chain: nil},
58				}}}},
59		{TargetValue: managerName,
60			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
61				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
62		return result, validation.NewError("storsimple.VolumesClient", "CreateOrUpdate", err.Error())
63	}
64
65	req, err := client.CreateOrUpdatePreparer(ctx, deviceName, volumeContainerName, volumeName, parameters, resourceGroupName, managerName)
66	if err != nil {
67		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "CreateOrUpdate", nil, "Failure preparing request")
68		return
69	}
70
71	result, err = client.CreateOrUpdateSender(req)
72	if err != nil {
73		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "CreateOrUpdate", nil, "Failure sending request")
74		return
75	}
76
77	return
78}
79
80// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
81func (client VolumesClient) CreateOrUpdatePreparer(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, parameters Volume, resourceGroupName string, managerName string) (*http.Request, error) {
82	pathParameters := map[string]interface{}{
83		"deviceName":          deviceName,
84		"managerName":         managerName,
85		"resourceGroupName":   resourceGroupName,
86		"subscriptionId":      client.SubscriptionID,
87		"volumeContainerName": volumeContainerName,
88		"volumeName":          volumeName,
89	}
90
91	const APIVersion = "2017-06-01"
92	queryParameters := map[string]interface{}{
93		"api-version": APIVersion,
94	}
95
96	preparer := autorest.CreatePreparer(
97		autorest.AsContentType("application/json; charset=utf-8"),
98		autorest.AsPut(),
99		autorest.WithBaseURL(client.BaseURI),
100		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}", pathParameters),
101		autorest.WithJSON(parameters),
102		autorest.WithQueryParameters(queryParameters))
103	return preparer.Prepare((&http.Request{}).WithContext(ctx))
104}
105
106// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
107// http.Response Body if it receives an error.
108func (client VolumesClient) CreateOrUpdateSender(req *http.Request) (future VolumesCreateOrUpdateFuture, err error) {
109	var resp *http.Response
110	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
111	if err != nil {
112		return
113	}
114	var azf azure.Future
115	azf, err = azure.NewFutureFromResponse(resp)
116	future.FutureAPI = &azf
117	future.Result = future.result
118	return
119}
120
121// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
122// closes the http.Response Body.
123func (client VolumesClient) CreateOrUpdateResponder(resp *http.Response) (result Volume, err error) {
124	err = autorest.Respond(
125		resp,
126		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
127		autorest.ByUnmarshallingJSON(&result),
128		autorest.ByClosing())
129	result.Response = autorest.Response{Response: resp}
130	return
131}
132
133// Delete deletes the volume.
134// Parameters:
135// deviceName - the device name
136// volumeContainerName - the volume container name.
137// volumeName - the volume name.
138// resourceGroupName - the resource group name
139// managerName - the manager name
140func (client VolumesClient) Delete(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (result VolumesDeleteFuture, err error) {
141	if tracing.IsEnabled() {
142		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Delete")
143		defer func() {
144			sc := -1
145			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
146				sc = result.FutureAPI.Response().StatusCode
147			}
148			tracing.EndSpan(ctx, sc, err)
149		}()
150	}
151	if err := validation.Validate([]validation.Validation{
152		{TargetValue: managerName,
153			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
154				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
155		return result, validation.NewError("storsimple.VolumesClient", "Delete", err.Error())
156	}
157
158	req, err := client.DeletePreparer(ctx, deviceName, volumeContainerName, volumeName, resourceGroupName, managerName)
159	if err != nil {
160		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "Delete", nil, "Failure preparing request")
161		return
162	}
163
164	result, err = client.DeleteSender(req)
165	if err != nil {
166		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "Delete", nil, "Failure sending request")
167		return
168	}
169
170	return
171}
172
173// DeletePreparer prepares the Delete request.
174func (client VolumesClient) DeletePreparer(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (*http.Request, error) {
175	pathParameters := map[string]interface{}{
176		"deviceName":          deviceName,
177		"managerName":         managerName,
178		"resourceGroupName":   resourceGroupName,
179		"subscriptionId":      client.SubscriptionID,
180		"volumeContainerName": volumeContainerName,
181		"volumeName":          volumeName,
182	}
183
184	const APIVersion = "2017-06-01"
185	queryParameters := map[string]interface{}{
186		"api-version": APIVersion,
187	}
188
189	preparer := autorest.CreatePreparer(
190		autorest.AsDelete(),
191		autorest.WithBaseURL(client.BaseURI),
192		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}", pathParameters),
193		autorest.WithQueryParameters(queryParameters))
194	return preparer.Prepare((&http.Request{}).WithContext(ctx))
195}
196
197// DeleteSender sends the Delete request. The method will close the
198// http.Response Body if it receives an error.
199func (client VolumesClient) DeleteSender(req *http.Request) (future VolumesDeleteFuture, err error) {
200	var resp *http.Response
201	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
202	if err != nil {
203		return
204	}
205	var azf azure.Future
206	azf, err = azure.NewFutureFromResponse(resp)
207	future.FutureAPI = &azf
208	future.Result = future.result
209	return
210}
211
212// DeleteResponder handles the response to the Delete request. The method always
213// closes the http.Response Body.
214func (client VolumesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
215	err = autorest.Respond(
216		resp,
217		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
218		autorest.ByClosing())
219	result.Response = resp
220	return
221}
222
223// Get returns the properties of the specified volume name.
224// Parameters:
225// deviceName - the device name
226// volumeContainerName - the volume container name.
227// volumeName - the volume name.
228// resourceGroupName - the resource group name
229// managerName - the manager name
230func (client VolumesClient) Get(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (result Volume, err error) {
231	if tracing.IsEnabled() {
232		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Get")
233		defer func() {
234			sc := -1
235			if result.Response.Response != nil {
236				sc = result.Response.Response.StatusCode
237			}
238			tracing.EndSpan(ctx, sc, err)
239		}()
240	}
241	if err := validation.Validate([]validation.Validation{
242		{TargetValue: managerName,
243			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
244				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
245		return result, validation.NewError("storsimple.VolumesClient", "Get", err.Error())
246	}
247
248	req, err := client.GetPreparer(ctx, deviceName, volumeContainerName, volumeName, resourceGroupName, managerName)
249	if err != nil {
250		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "Get", nil, "Failure preparing request")
251		return
252	}
253
254	resp, err := client.GetSender(req)
255	if err != nil {
256		result.Response = autorest.Response{Response: resp}
257		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "Get", resp, "Failure sending request")
258		return
259	}
260
261	result, err = client.GetResponder(resp)
262	if err != nil {
263		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "Get", resp, "Failure responding to request")
264		return
265	}
266
267	return
268}
269
270// GetPreparer prepares the Get request.
271func (client VolumesClient) GetPreparer(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (*http.Request, error) {
272	pathParameters := map[string]interface{}{
273		"deviceName":          deviceName,
274		"managerName":         managerName,
275		"resourceGroupName":   resourceGroupName,
276		"subscriptionId":      client.SubscriptionID,
277		"volumeContainerName": volumeContainerName,
278		"volumeName":          volumeName,
279	}
280
281	const APIVersion = "2017-06-01"
282	queryParameters := map[string]interface{}{
283		"api-version": APIVersion,
284	}
285
286	preparer := autorest.CreatePreparer(
287		autorest.AsGet(),
288		autorest.WithBaseURL(client.BaseURI),
289		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}", pathParameters),
290		autorest.WithQueryParameters(queryParameters))
291	return preparer.Prepare((&http.Request{}).WithContext(ctx))
292}
293
294// GetSender sends the Get request. The method will close the
295// http.Response Body if it receives an error.
296func (client VolumesClient) GetSender(req *http.Request) (*http.Response, error) {
297	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
298}
299
300// GetResponder handles the response to the Get request. The method always
301// closes the http.Response Body.
302func (client VolumesClient) GetResponder(resp *http.Response) (result Volume, err error) {
303	err = autorest.Respond(
304		resp,
305		azure.WithErrorUnlessStatusCode(http.StatusOK),
306		autorest.ByUnmarshallingJSON(&result),
307		autorest.ByClosing())
308	result.Response = autorest.Response{Response: resp}
309	return
310}
311
312// ListByDevice retrieves all the volumes in a device.
313// Parameters:
314// deviceName - the device name
315// resourceGroupName - the resource group name
316// managerName - the manager name
317func (client VolumesClient) ListByDevice(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result VolumeList, err error) {
318	if tracing.IsEnabled() {
319		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.ListByDevice")
320		defer func() {
321			sc := -1
322			if result.Response.Response != nil {
323				sc = result.Response.Response.StatusCode
324			}
325			tracing.EndSpan(ctx, sc, err)
326		}()
327	}
328	if err := validation.Validate([]validation.Validation{
329		{TargetValue: managerName,
330			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
331				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
332		return result, validation.NewError("storsimple.VolumesClient", "ListByDevice", err.Error())
333	}
334
335	req, err := client.ListByDevicePreparer(ctx, deviceName, resourceGroupName, managerName)
336	if err != nil {
337		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListByDevice", nil, "Failure preparing request")
338		return
339	}
340
341	resp, err := client.ListByDeviceSender(req)
342	if err != nil {
343		result.Response = autorest.Response{Response: resp}
344		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListByDevice", resp, "Failure sending request")
345		return
346	}
347
348	result, err = client.ListByDeviceResponder(resp)
349	if err != nil {
350		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListByDevice", resp, "Failure responding to request")
351		return
352	}
353
354	return
355}
356
357// ListByDevicePreparer prepares the ListByDevice request.
358func (client VolumesClient) ListByDevicePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
359	pathParameters := map[string]interface{}{
360		"deviceName":        deviceName,
361		"managerName":       managerName,
362		"resourceGroupName": resourceGroupName,
363		"subscriptionId":    client.SubscriptionID,
364	}
365
366	const APIVersion = "2017-06-01"
367	queryParameters := map[string]interface{}{
368		"api-version": APIVersion,
369	}
370
371	preparer := autorest.CreatePreparer(
372		autorest.AsGet(),
373		autorest.WithBaseURL(client.BaseURI),
374		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumes", pathParameters),
375		autorest.WithQueryParameters(queryParameters))
376	return preparer.Prepare((&http.Request{}).WithContext(ctx))
377}
378
379// ListByDeviceSender sends the ListByDevice request. The method will close the
380// http.Response Body if it receives an error.
381func (client VolumesClient) ListByDeviceSender(req *http.Request) (*http.Response, error) {
382	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
383}
384
385// ListByDeviceResponder handles the response to the ListByDevice request. The method always
386// closes the http.Response Body.
387func (client VolumesClient) ListByDeviceResponder(resp *http.Response) (result VolumeList, err error) {
388	err = autorest.Respond(
389		resp,
390		azure.WithErrorUnlessStatusCode(http.StatusOK),
391		autorest.ByUnmarshallingJSON(&result),
392		autorest.ByClosing())
393	result.Response = autorest.Response{Response: resp}
394	return
395}
396
397// ListByVolumeContainer retrieves all the volumes in a volume container.
398// Parameters:
399// deviceName - the device name
400// volumeContainerName - the volume container name.
401// resourceGroupName - the resource group name
402// managerName - the manager name
403func (client VolumesClient) ListByVolumeContainer(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result VolumeList, err error) {
404	if tracing.IsEnabled() {
405		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.ListByVolumeContainer")
406		defer func() {
407			sc := -1
408			if result.Response.Response != nil {
409				sc = result.Response.Response.StatusCode
410			}
411			tracing.EndSpan(ctx, sc, err)
412		}()
413	}
414	if err := validation.Validate([]validation.Validation{
415		{TargetValue: managerName,
416			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
417				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
418		return result, validation.NewError("storsimple.VolumesClient", "ListByVolumeContainer", err.Error())
419	}
420
421	req, err := client.ListByVolumeContainerPreparer(ctx, deviceName, volumeContainerName, resourceGroupName, managerName)
422	if err != nil {
423		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListByVolumeContainer", nil, "Failure preparing request")
424		return
425	}
426
427	resp, err := client.ListByVolumeContainerSender(req)
428	if err != nil {
429		result.Response = autorest.Response{Response: resp}
430		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListByVolumeContainer", resp, "Failure sending request")
431		return
432	}
433
434	result, err = client.ListByVolumeContainerResponder(resp)
435	if err != nil {
436		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListByVolumeContainer", resp, "Failure responding to request")
437		return
438	}
439
440	return
441}
442
443// ListByVolumeContainerPreparer prepares the ListByVolumeContainer request.
444func (client VolumesClient) ListByVolumeContainerPreparer(ctx context.Context, deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) {
445	pathParameters := map[string]interface{}{
446		"deviceName":          deviceName,
447		"managerName":         managerName,
448		"resourceGroupName":   resourceGroupName,
449		"subscriptionId":      client.SubscriptionID,
450		"volumeContainerName": volumeContainerName,
451	}
452
453	const APIVersion = "2017-06-01"
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.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes", pathParameters),
462		autorest.WithQueryParameters(queryParameters))
463	return preparer.Prepare((&http.Request{}).WithContext(ctx))
464}
465
466// ListByVolumeContainerSender sends the ListByVolumeContainer request. The method will close the
467// http.Response Body if it receives an error.
468func (client VolumesClient) ListByVolumeContainerSender(req *http.Request) (*http.Response, error) {
469	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
470}
471
472// ListByVolumeContainerResponder handles the response to the ListByVolumeContainer request. The method always
473// closes the http.Response Body.
474func (client VolumesClient) ListByVolumeContainerResponder(resp *http.Response) (result VolumeList, 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// ListMetricDefinition gets the metric definitions for the specified volume.
485// Parameters:
486// deviceName - the device name
487// volumeContainerName - the volume container name.
488// volumeName - the volume name.
489// resourceGroupName - the resource group name
490// managerName - the manager name
491func (client VolumesClient) ListMetricDefinition(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) {
492	if tracing.IsEnabled() {
493		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.ListMetricDefinition")
494		defer func() {
495			sc := -1
496			if result.Response.Response != nil {
497				sc = result.Response.Response.StatusCode
498			}
499			tracing.EndSpan(ctx, sc, err)
500		}()
501	}
502	if err := validation.Validate([]validation.Validation{
503		{TargetValue: managerName,
504			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
505				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
506		return result, validation.NewError("storsimple.VolumesClient", "ListMetricDefinition", err.Error())
507	}
508
509	req, err := client.ListMetricDefinitionPreparer(ctx, deviceName, volumeContainerName, volumeName, resourceGroupName, managerName)
510	if err != nil {
511		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListMetricDefinition", nil, "Failure preparing request")
512		return
513	}
514
515	resp, err := client.ListMetricDefinitionSender(req)
516	if err != nil {
517		result.Response = autorest.Response{Response: resp}
518		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListMetricDefinition", resp, "Failure sending request")
519		return
520	}
521
522	result, err = client.ListMetricDefinitionResponder(resp)
523	if err != nil {
524		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListMetricDefinition", resp, "Failure responding to request")
525		return
526	}
527
528	return
529}
530
531// ListMetricDefinitionPreparer prepares the ListMetricDefinition request.
532func (client VolumesClient) ListMetricDefinitionPreparer(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (*http.Request, error) {
533	pathParameters := map[string]interface{}{
534		"deviceName":          deviceName,
535		"managerName":         managerName,
536		"resourceGroupName":   resourceGroupName,
537		"subscriptionId":      client.SubscriptionID,
538		"volumeContainerName": volumeContainerName,
539		"volumeName":          volumeName,
540	}
541
542	const APIVersion = "2017-06-01"
543	queryParameters := map[string]interface{}{
544		"api-version": APIVersion,
545	}
546
547	preparer := autorest.CreatePreparer(
548		autorest.AsGet(),
549		autorest.WithBaseURL(client.BaseURI),
550		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}/metricsDefinitions", pathParameters),
551		autorest.WithQueryParameters(queryParameters))
552	return preparer.Prepare((&http.Request{}).WithContext(ctx))
553}
554
555// ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the
556// http.Response Body if it receives an error.
557func (client VolumesClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) {
558	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
559}
560
561// ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always
562// closes the http.Response Body.
563func (client VolumesClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) {
564	err = autorest.Respond(
565		resp,
566		azure.WithErrorUnlessStatusCode(http.StatusOK),
567		autorest.ByUnmarshallingJSON(&result),
568		autorest.ByClosing())
569	result.Response = autorest.Response{Response: resp}
570	return
571}
572
573// ListMetrics gets the metrics for the specified volume.
574// Parameters:
575// deviceName - the device name
576// volumeContainerName - the volume container name.
577// volumeName - the volume name.
578// resourceGroupName - the resource group name
579// managerName - the manager name
580// filter - oData Filter options
581func (client VolumesClient) ListMetrics(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) {
582	if tracing.IsEnabled() {
583		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.ListMetrics")
584		defer func() {
585			sc := -1
586			if result.Response.Response != nil {
587				sc = result.Response.Response.StatusCode
588			}
589			tracing.EndSpan(ctx, sc, err)
590		}()
591	}
592	if err := validation.Validate([]validation.Validation{
593		{TargetValue: managerName,
594			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
595				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
596		return result, validation.NewError("storsimple.VolumesClient", "ListMetrics", err.Error())
597	}
598
599	req, err := client.ListMetricsPreparer(ctx, deviceName, volumeContainerName, volumeName, resourceGroupName, managerName, filter)
600	if err != nil {
601		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListMetrics", nil, "Failure preparing request")
602		return
603	}
604
605	resp, err := client.ListMetricsSender(req)
606	if err != nil {
607		result.Response = autorest.Response{Response: resp}
608		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListMetrics", resp, "Failure sending request")
609		return
610	}
611
612	result, err = client.ListMetricsResponder(resp)
613	if err != nil {
614		err = autorest.NewErrorWithError(err, "storsimple.VolumesClient", "ListMetrics", resp, "Failure responding to request")
615		return
616	}
617
618	return
619}
620
621// ListMetricsPreparer prepares the ListMetrics request.
622func (client VolumesClient) ListMetricsPreparer(ctx context.Context, deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) {
623	pathParameters := map[string]interface{}{
624		"deviceName":          deviceName,
625		"managerName":         managerName,
626		"resourceGroupName":   resourceGroupName,
627		"subscriptionId":      client.SubscriptionID,
628		"volumeContainerName": volumeContainerName,
629		"volumeName":          volumeName,
630	}
631
632	const APIVersion = "2017-06-01"
633	queryParameters := map[string]interface{}{
634		"$filter":     autorest.Encode("query", filter),
635		"api-version": APIVersion,
636	}
637
638	preparer := autorest.CreatePreparer(
639		autorest.AsGet(),
640		autorest.WithBaseURL(client.BaseURI),
641		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}/metrics", pathParameters),
642		autorest.WithQueryParameters(queryParameters))
643	return preparer.Prepare((&http.Request{}).WithContext(ctx))
644}
645
646// ListMetricsSender sends the ListMetrics request. The method will close the
647// http.Response Body if it receives an error.
648func (client VolumesClient) ListMetricsSender(req *http.Request) (*http.Response, error) {
649	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
650}
651
652// ListMetricsResponder handles the response to the ListMetrics request. The method always
653// closes the http.Response Body.
654func (client VolumesClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) {
655	err = autorest.Respond(
656		resp,
657		azure.WithErrorUnlessStatusCode(http.StatusOK),
658		autorest.ByUnmarshallingJSON(&result),
659		autorest.ByClosing())
660	result.Response = autorest.Response{Response: resp}
661	return
662}
663