...

Source file src/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-05-01/netapp/volumes.go

Documentation: github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-05-01/netapp

     1  package netapp
     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 microsoft NetApp Azure Resource Provider specification
    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 create or update the specified volume within the capacity pool
    35  // Parameters:
    36  // body - volume object supplied in the body of the operation.
    37  // resourceGroupName - the name of the resource group.
    38  // accountName - the name of the NetApp account
    39  // poolName - the name of the capacity pool
    40  // volumeName - the name of the volume
    41  func (client VolumesClient) CreateOrUpdate(ctx context.Context, body Volume, resourceGroupName string, accountName string, poolName string, volumeName string) (result VolumesCreateOrUpdateFuture, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.CreateOrUpdate")
    44  		defer func() {
    45  			sc := -1
    46  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    47  				sc = result.FutureAPI.Response().StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: body,
    54  			Constraints: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil},
    55  				{Target: "body.VolumeProperties", Name: validation.Null, Rule: true,
    56  					Chain: []validation.Constraint{{Target: "body.VolumeProperties.FileSystemID", Name: validation.Null, Rule: false,
    57  						Chain: []validation.Constraint{{Target: "body.VolumeProperties.FileSystemID", Name: validation.MaxLength, Rule: 36, Chain: nil},
    58  							{Target: "body.VolumeProperties.FileSystemID", Name: validation.MinLength, Rule: 36, Chain: nil},
    59  							{Target: "body.VolumeProperties.FileSystemID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil},
    60  						}},
    61  						{Target: "body.VolumeProperties.CreationToken", Name: validation.Null, Rule: true, Chain: nil},
    62  						{Target: "body.VolumeProperties.UsageThreshold", Name: validation.Null, Rule: true,
    63  							Chain: []validation.Constraint{{Target: "body.VolumeProperties.UsageThreshold", Name: validation.InclusiveMaximum, Rule: int64(109951162777600), Chain: nil},
    64  								{Target: "body.VolumeProperties.UsageThreshold", Name: validation.InclusiveMinimum, Rule: int64(107374182400), Chain: nil},
    65  							}},
    66  						{Target: "body.VolumeProperties.SnapshotID", Name: validation.Null, Rule: false,
    67  							Chain: []validation.Constraint{{Target: "body.VolumeProperties.SnapshotID", Name: validation.MaxLength, Rule: 36, Chain: nil},
    68  								{Target: "body.VolumeProperties.SnapshotID", Name: validation.MinLength, Rule: 36, Chain: nil},
    69  								{Target: "body.VolumeProperties.SnapshotID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil},
    70  							}},
    71  						{Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.Null, Rule: false,
    72  							Chain: []validation.Constraint{{Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.MaxLength, Rule: 36, Chain: nil},
    73  								{Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.MinLength, Rule: 36, Chain: nil},
    74  								{Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil},
    75  							}},
    76  						{Target: "body.VolumeProperties.SubnetID", Name: validation.Null, Rule: true, Chain: nil},
    77  					}}}},
    78  		{TargetValue: resourceGroupName,
    79  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    80  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    81  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
    82  		return result, validation.NewError("netapp.VolumesClient", "CreateOrUpdate", err.Error())
    83  	}
    84  
    85  	req, err := client.CreateOrUpdatePreparer(ctx, body, resourceGroupName, accountName, poolName, volumeName)
    86  	if err != nil {
    87  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "CreateOrUpdate", nil, "Failure preparing request")
    88  		return
    89  	}
    90  
    91  	result, err = client.CreateOrUpdateSender(req)
    92  	if err != nil {
    93  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    94  		return
    95  	}
    96  
    97  	return
    98  }
    99  
   100  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   101  func (client VolumesClient) CreateOrUpdatePreparer(ctx context.Context, body Volume, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) {
   102  	pathParameters := map[string]interface{}{
   103  		"accountName":       autorest.Encode("path", accountName),
   104  		"poolName":          autorest.Encode("path", poolName),
   105  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   106  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   107  		"volumeName":        autorest.Encode("path", volumeName),
   108  	}
   109  
   110  	const APIVersion = "2019-05-01"
   111  	queryParameters := map[string]interface{}{
   112  		"api-version": APIVersion,
   113  	}
   114  
   115  	body.ID = nil
   116  	body.Name = nil
   117  	body.Type = nil
   118  	preparer := autorest.CreatePreparer(
   119  		autorest.AsContentType("application/json; charset=utf-8"),
   120  		autorest.AsPut(),
   121  		autorest.WithBaseURL(client.BaseURI),
   122  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}", pathParameters),
   123  		autorest.WithJSON(body),
   124  		autorest.WithQueryParameters(queryParameters))
   125  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   126  }
   127  
   128  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   129  // http.Response Body if it receives an error.
   130  func (client VolumesClient) CreateOrUpdateSender(req *http.Request) (future VolumesCreateOrUpdateFuture, err error) {
   131  	var resp *http.Response
   132  	future.FutureAPI = &azure.Future{}
   133  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   134  	if err != nil {
   135  		return
   136  	}
   137  	var azf azure.Future
   138  	azf, err = azure.NewFutureFromResponse(resp)
   139  	future.FutureAPI = &azf
   140  	future.Result = future.result
   141  	return
   142  }
   143  
   144  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   145  // closes the http.Response Body.
   146  func (client VolumesClient) CreateOrUpdateResponder(resp *http.Response) (result Volume, err error) {
   147  	err = autorest.Respond(
   148  		resp,
   149  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
   150  		autorest.ByUnmarshallingJSON(&result),
   151  		autorest.ByClosing())
   152  	result.Response = autorest.Response{Response: resp}
   153  	return
   154  }
   155  
   156  // Delete delete the specified volume
   157  // Parameters:
   158  // resourceGroupName - the name of the resource group.
   159  // accountName - the name of the NetApp account
   160  // poolName - the name of the capacity pool
   161  // volumeName - the name of the volume
   162  func (client VolumesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result VolumesDeleteFuture, err error) {
   163  	if tracing.IsEnabled() {
   164  		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Delete")
   165  		defer func() {
   166  			sc := -1
   167  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   168  				sc = result.FutureAPI.Response().StatusCode
   169  			}
   170  			tracing.EndSpan(ctx, sc, err)
   171  		}()
   172  	}
   173  	if err := validation.Validate([]validation.Validation{
   174  		{TargetValue: resourceGroupName,
   175  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   176  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   177  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   178  		return result, validation.NewError("netapp.VolumesClient", "Delete", err.Error())
   179  	}
   180  
   181  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, poolName, volumeName)
   182  	if err != nil {
   183  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Delete", nil, "Failure preparing request")
   184  		return
   185  	}
   186  
   187  	result, err = client.DeleteSender(req)
   188  	if err != nil {
   189  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Delete", result.Response(), "Failure sending request")
   190  		return
   191  	}
   192  
   193  	return
   194  }
   195  
   196  // DeletePreparer prepares the Delete request.
   197  func (client VolumesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) {
   198  	pathParameters := map[string]interface{}{
   199  		"accountName":       autorest.Encode("path", accountName),
   200  		"poolName":          autorest.Encode("path", poolName),
   201  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   202  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   203  		"volumeName":        autorest.Encode("path", volumeName),
   204  	}
   205  
   206  	const APIVersion = "2019-05-01"
   207  	queryParameters := map[string]interface{}{
   208  		"api-version": APIVersion,
   209  	}
   210  
   211  	preparer := autorest.CreatePreparer(
   212  		autorest.AsDelete(),
   213  		autorest.WithBaseURL(client.BaseURI),
   214  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}", pathParameters),
   215  		autorest.WithQueryParameters(queryParameters))
   216  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   217  }
   218  
   219  // DeleteSender sends the Delete request. The method will close the
   220  // http.Response Body if it receives an error.
   221  func (client VolumesClient) DeleteSender(req *http.Request) (future VolumesDeleteFuture, err error) {
   222  	var resp *http.Response
   223  	future.FutureAPI = &azure.Future{}
   224  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   225  	if err != nil {
   226  		return
   227  	}
   228  	var azf azure.Future
   229  	azf, err = azure.NewFutureFromResponse(resp)
   230  	future.FutureAPI = &azf
   231  	future.Result = future.result
   232  	return
   233  }
   234  
   235  // DeleteResponder handles the response to the Delete request. The method always
   236  // closes the http.Response Body.
   237  func (client VolumesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   238  	err = autorest.Respond(
   239  		resp,
   240  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   241  		autorest.ByClosing())
   242  	result.Response = resp
   243  	return
   244  }
   245  
   246  // Get get the details of the specified volume
   247  // Parameters:
   248  // resourceGroupName - the name of the resource group.
   249  // accountName - the name of the NetApp account
   250  // poolName - the name of the capacity pool
   251  // volumeName - the name of the volume
   252  func (client VolumesClient) Get(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result Volume, err error) {
   253  	if tracing.IsEnabled() {
   254  		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Get")
   255  		defer func() {
   256  			sc := -1
   257  			if result.Response.Response != nil {
   258  				sc = result.Response.Response.StatusCode
   259  			}
   260  			tracing.EndSpan(ctx, sc, err)
   261  		}()
   262  	}
   263  	if err := validation.Validate([]validation.Validation{
   264  		{TargetValue: resourceGroupName,
   265  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   266  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   267  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   268  		return result, validation.NewError("netapp.VolumesClient", "Get", err.Error())
   269  	}
   270  
   271  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, poolName, volumeName)
   272  	if err != nil {
   273  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Get", nil, "Failure preparing request")
   274  		return
   275  	}
   276  
   277  	resp, err := client.GetSender(req)
   278  	if err != nil {
   279  		result.Response = autorest.Response{Response: resp}
   280  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Get", resp, "Failure sending request")
   281  		return
   282  	}
   283  
   284  	result, err = client.GetResponder(resp)
   285  	if err != nil {
   286  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Get", resp, "Failure responding to request")
   287  		return
   288  	}
   289  
   290  	return
   291  }
   292  
   293  // GetPreparer prepares the Get request.
   294  func (client VolumesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) {
   295  	pathParameters := map[string]interface{}{
   296  		"accountName":       autorest.Encode("path", accountName),
   297  		"poolName":          autorest.Encode("path", poolName),
   298  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   299  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   300  		"volumeName":        autorest.Encode("path", volumeName),
   301  	}
   302  
   303  	const APIVersion = "2019-05-01"
   304  	queryParameters := map[string]interface{}{
   305  		"api-version": APIVersion,
   306  	}
   307  
   308  	preparer := autorest.CreatePreparer(
   309  		autorest.AsGet(),
   310  		autorest.WithBaseURL(client.BaseURI),
   311  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}", pathParameters),
   312  		autorest.WithQueryParameters(queryParameters))
   313  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   314  }
   315  
   316  // GetSender sends the Get request. The method will close the
   317  // http.Response Body if it receives an error.
   318  func (client VolumesClient) GetSender(req *http.Request) (*http.Response, error) {
   319  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   320  }
   321  
   322  // GetResponder handles the response to the Get request. The method always
   323  // closes the http.Response Body.
   324  func (client VolumesClient) GetResponder(resp *http.Response) (result Volume, err error) {
   325  	err = autorest.Respond(
   326  		resp,
   327  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   328  		autorest.ByUnmarshallingJSON(&result),
   329  		autorest.ByClosing())
   330  	result.Response = autorest.Response{Response: resp}
   331  	return
   332  }
   333  
   334  // List list all volumes within the capacity pool
   335  // Parameters:
   336  // resourceGroupName - the name of the resource group.
   337  // accountName - the name of the NetApp account
   338  // poolName - the name of the capacity pool
   339  func (client VolumesClient) List(ctx context.Context, resourceGroupName string, accountName string, poolName string) (result VolumeList, err error) {
   340  	if tracing.IsEnabled() {
   341  		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.List")
   342  		defer func() {
   343  			sc := -1
   344  			if result.Response.Response != nil {
   345  				sc = result.Response.Response.StatusCode
   346  			}
   347  			tracing.EndSpan(ctx, sc, err)
   348  		}()
   349  	}
   350  	if err := validation.Validate([]validation.Validation{
   351  		{TargetValue: resourceGroupName,
   352  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   353  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   354  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   355  		return result, validation.NewError("netapp.VolumesClient", "List", err.Error())
   356  	}
   357  
   358  	req, err := client.ListPreparer(ctx, resourceGroupName, accountName, poolName)
   359  	if err != nil {
   360  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "List", nil, "Failure preparing request")
   361  		return
   362  	}
   363  
   364  	resp, err := client.ListSender(req)
   365  	if err != nil {
   366  		result.Response = autorest.Response{Response: resp}
   367  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "List", resp, "Failure sending request")
   368  		return
   369  	}
   370  
   371  	result, err = client.ListResponder(resp)
   372  	if err != nil {
   373  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "List", resp, "Failure responding to request")
   374  		return
   375  	}
   376  
   377  	return
   378  }
   379  
   380  // ListPreparer prepares the List request.
   381  func (client VolumesClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string) (*http.Request, error) {
   382  	pathParameters := map[string]interface{}{
   383  		"accountName":       autorest.Encode("path", accountName),
   384  		"poolName":          autorest.Encode("path", poolName),
   385  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   386  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   387  	}
   388  
   389  	const APIVersion = "2019-05-01"
   390  	queryParameters := map[string]interface{}{
   391  		"api-version": APIVersion,
   392  	}
   393  
   394  	preparer := autorest.CreatePreparer(
   395  		autorest.AsGet(),
   396  		autorest.WithBaseURL(client.BaseURI),
   397  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes", pathParameters),
   398  		autorest.WithQueryParameters(queryParameters))
   399  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   400  }
   401  
   402  // ListSender sends the List request. The method will close the
   403  // http.Response Body if it receives an error.
   404  func (client VolumesClient) ListSender(req *http.Request) (*http.Response, error) {
   405  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   406  }
   407  
   408  // ListResponder handles the response to the List request. The method always
   409  // closes the http.Response Body.
   410  func (client VolumesClient) ListResponder(resp *http.Response) (result VolumeList, err error) {
   411  	err = autorest.Respond(
   412  		resp,
   413  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   414  		autorest.ByUnmarshallingJSON(&result),
   415  		autorest.ByClosing())
   416  	result.Response = autorest.Response{Response: resp}
   417  	return
   418  }
   419  
   420  // Update patch the specified volume
   421  // Parameters:
   422  // body - volume object supplied in the body of the operation.
   423  // resourceGroupName - the name of the resource group.
   424  // accountName - the name of the NetApp account
   425  // poolName - the name of the capacity pool
   426  // volumeName - the name of the volume
   427  func (client VolumesClient) Update(ctx context.Context, body VolumePatch, resourceGroupName string, accountName string, poolName string, volumeName string) (result Volume, err error) {
   428  	if tracing.IsEnabled() {
   429  		ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Update")
   430  		defer func() {
   431  			sc := -1
   432  			if result.Response.Response != nil {
   433  				sc = result.Response.Response.StatusCode
   434  			}
   435  			tracing.EndSpan(ctx, sc, err)
   436  		}()
   437  	}
   438  	if err := validation.Validate([]validation.Validation{
   439  		{TargetValue: resourceGroupName,
   440  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   441  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   442  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   443  		return result, validation.NewError("netapp.VolumesClient", "Update", err.Error())
   444  	}
   445  
   446  	req, err := client.UpdatePreparer(ctx, body, resourceGroupName, accountName, poolName, volumeName)
   447  	if err != nil {
   448  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Update", nil, "Failure preparing request")
   449  		return
   450  	}
   451  
   452  	resp, err := client.UpdateSender(req)
   453  	if err != nil {
   454  		result.Response = autorest.Response{Response: resp}
   455  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Update", resp, "Failure sending request")
   456  		return
   457  	}
   458  
   459  	result, err = client.UpdateResponder(resp)
   460  	if err != nil {
   461  		err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Update", resp, "Failure responding to request")
   462  		return
   463  	}
   464  
   465  	return
   466  }
   467  
   468  // UpdatePreparer prepares the Update request.
   469  func (client VolumesClient) UpdatePreparer(ctx context.Context, body VolumePatch, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) {
   470  	pathParameters := map[string]interface{}{
   471  		"accountName":       autorest.Encode("path", accountName),
   472  		"poolName":          autorest.Encode("path", poolName),
   473  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   474  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   475  		"volumeName":        autorest.Encode("path", volumeName),
   476  	}
   477  
   478  	const APIVersion = "2019-05-01"
   479  	queryParameters := map[string]interface{}{
   480  		"api-version": APIVersion,
   481  	}
   482  
   483  	body.ID = nil
   484  	body.Name = nil
   485  	body.Type = nil
   486  	preparer := autorest.CreatePreparer(
   487  		autorest.AsContentType("application/json; charset=utf-8"),
   488  		autorest.AsPatch(),
   489  		autorest.WithBaseURL(client.BaseURI),
   490  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}", pathParameters),
   491  		autorest.WithJSON(body),
   492  		autorest.WithQueryParameters(queryParameters))
   493  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   494  }
   495  
   496  // UpdateSender sends the Update request. The method will close the
   497  // http.Response Body if it receives an error.
   498  func (client VolumesClient) UpdateSender(req *http.Request) (*http.Response, error) {
   499  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   500  }
   501  
   502  // UpdateResponder handles the response to the Update request. The method always
   503  // closes the http.Response Body.
   504  func (client VolumesClient) UpdateResponder(resp *http.Response) (result Volume, err error) {
   505  	err = autorest.Respond(
   506  		resp,
   507  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   508  		autorest.ByUnmarshallingJSON(&result),
   509  		autorest.ByClosing())
   510  	result.Response = autorest.Response{Response: resp}
   511  	return
   512  }
   513  

View as plain text