...

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

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

View as plain text