...

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

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

View as plain text