...

Source file src/github.com/Azure/azure-sdk-for-go/services/storsimple8000series/mgmt/2017-06-01/storsimple/volumes.go

Documentation: github.com/Azure/azure-sdk-for-go/services/storsimple8000series/mgmt/2017-06-01/storsimple

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

View as plain text