...

Source file src/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-08-01/netapp/accountbackups.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  // AccountBackupsClient is the microsoft NetApp Azure Resource Provider specification
    19  type AccountBackupsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewAccountBackupsClient creates an instance of the AccountBackupsClient client.
    24  func NewAccountBackupsClient(subscriptionID string) AccountBackupsClient {
    25  	return NewAccountBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewAccountBackupsClientWithBaseURI creates an instance of the AccountBackupsClient client using a custom endpoint.
    29  // Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewAccountBackupsClientWithBaseURI(baseURI string, subscriptionID string) AccountBackupsClient {
    31  	return AccountBackupsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Delete delete Backup for a Netapp Account
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group.
    37  // accountName - the name of the NetApp account
    38  // backupName - the name of the backup
    39  func (client AccountBackupsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, backupName string) (result AccountBackupsDeleteFuture, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountBackupsClient.Delete")
    42  		defer func() {
    43  			sc := -1
    44  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    45  				sc = result.FutureAPI.Response().StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	if err := validation.Validate([]validation.Validation{
    51  		{TargetValue: resourceGroupName,
    52  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    53  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    54  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
    55  		return result, validation.NewError("netapp.AccountBackupsClient", "Delete", err.Error())
    56  	}
    57  
    58  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, backupName)
    59  	if err != nil {
    60  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Delete", nil, "Failure preparing request")
    61  		return
    62  	}
    63  
    64  	result, err = client.DeleteSender(req)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Delete", result.Response(), "Failure sending request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // DeletePreparer prepares the Delete request.
    74  func (client AccountBackupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, backupName string) (*http.Request, error) {
    75  	pathParameters := map[string]interface{}{
    76  		"accountName":       autorest.Encode("path", accountName),
    77  		"backupName":        autorest.Encode("path", backupName),
    78  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    79  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    80  	}
    81  
    82  	const APIVersion = "2020-08-01"
    83  	queryParameters := map[string]interface{}{
    84  		"api-version": APIVersion,
    85  	}
    86  
    87  	preparer := autorest.CreatePreparer(
    88  		autorest.AsDelete(),
    89  		autorest.WithBaseURL(client.BaseURI),
    90  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/accountBackups/{backupName}", pathParameters),
    91  		autorest.WithQueryParameters(queryParameters))
    92  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    93  }
    94  
    95  // DeleteSender sends the Delete request. The method will close the
    96  // http.Response Body if it receives an error.
    97  func (client AccountBackupsClient) DeleteSender(req *http.Request) (future AccountBackupsDeleteFuture, err error) {
    98  	var resp *http.Response
    99  	future.FutureAPI = &azure.Future{}
   100  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   101  	if err != nil {
   102  		return
   103  	}
   104  	var azf azure.Future
   105  	azf, err = azure.NewFutureFromResponse(resp)
   106  	future.FutureAPI = &azf
   107  	future.Result = future.result
   108  	return
   109  }
   110  
   111  // DeleteResponder handles the response to the Delete request. The method always
   112  // closes the http.Response Body.
   113  func (client AccountBackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   114  	err = autorest.Respond(
   115  		resp,
   116  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   117  		autorest.ByClosing())
   118  	result.Response = resp
   119  	return
   120  }
   121  
   122  // Get get Backup for a Netapp Account
   123  // Parameters:
   124  // resourceGroupName - the name of the resource group.
   125  // accountName - the name of the NetApp account
   126  // backupName - the name of the backup
   127  func (client AccountBackupsClient) Get(ctx context.Context, resourceGroupName string, accountName string, backupName string) (result Backup, err error) {
   128  	if tracing.IsEnabled() {
   129  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountBackupsClient.Get")
   130  		defer func() {
   131  			sc := -1
   132  			if result.Response.Response != nil {
   133  				sc = result.Response.Response.StatusCode
   134  			}
   135  			tracing.EndSpan(ctx, sc, err)
   136  		}()
   137  	}
   138  	if err := validation.Validate([]validation.Validation{
   139  		{TargetValue: resourceGroupName,
   140  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   141  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   142  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   143  		return result, validation.NewError("netapp.AccountBackupsClient", "Get", err.Error())
   144  	}
   145  
   146  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, backupName)
   147  	if err != nil {
   148  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Get", nil, "Failure preparing request")
   149  		return
   150  	}
   151  
   152  	resp, err := client.GetSender(req)
   153  	if err != nil {
   154  		result.Response = autorest.Response{Response: resp}
   155  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Get", resp, "Failure sending request")
   156  		return
   157  	}
   158  
   159  	result, err = client.GetResponder(resp)
   160  	if err != nil {
   161  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Get", resp, "Failure responding to request")
   162  		return
   163  	}
   164  
   165  	return
   166  }
   167  
   168  // GetPreparer prepares the Get request.
   169  func (client AccountBackupsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, backupName string) (*http.Request, error) {
   170  	pathParameters := map[string]interface{}{
   171  		"accountName":       autorest.Encode("path", accountName),
   172  		"backupName":        autorest.Encode("path", backupName),
   173  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   174  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   175  	}
   176  
   177  	const APIVersion = "2020-08-01"
   178  	queryParameters := map[string]interface{}{
   179  		"api-version": APIVersion,
   180  	}
   181  
   182  	preparer := autorest.CreatePreparer(
   183  		autorest.AsGet(),
   184  		autorest.WithBaseURL(client.BaseURI),
   185  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/accountBackups/{backupName}", pathParameters),
   186  		autorest.WithQueryParameters(queryParameters))
   187  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   188  }
   189  
   190  // GetSender sends the Get request. The method will close the
   191  // http.Response Body if it receives an error.
   192  func (client AccountBackupsClient) GetSender(req *http.Request) (*http.Response, error) {
   193  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   194  }
   195  
   196  // GetResponder handles the response to the Get request. The method always
   197  // closes the http.Response Body.
   198  func (client AccountBackupsClient) GetResponder(resp *http.Response) (result Backup, err error) {
   199  	err = autorest.Respond(
   200  		resp,
   201  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   202  		autorest.ByUnmarshallingJSON(&result),
   203  		autorest.ByClosing())
   204  	result.Response = autorest.Response{Response: resp}
   205  	return
   206  }
   207  
   208  // List list all Backups for a Netapp Account
   209  // Parameters:
   210  // resourceGroupName - the name of the resource group.
   211  // accountName - the name of the NetApp account
   212  func (client AccountBackupsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result BackupsList, err error) {
   213  	if tracing.IsEnabled() {
   214  		ctx = tracing.StartSpan(ctx, fqdn+"/AccountBackupsClient.List")
   215  		defer func() {
   216  			sc := -1
   217  			if result.Response.Response != nil {
   218  				sc = result.Response.Response.StatusCode
   219  			}
   220  			tracing.EndSpan(ctx, sc, err)
   221  		}()
   222  	}
   223  	if err := validation.Validate([]validation.Validation{
   224  		{TargetValue: resourceGroupName,
   225  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   226  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   227  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   228  		return result, validation.NewError("netapp.AccountBackupsClient", "List", err.Error())
   229  	}
   230  
   231  	req, err := client.ListPreparer(ctx, resourceGroupName, accountName)
   232  	if err != nil {
   233  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "List", nil, "Failure preparing request")
   234  		return
   235  	}
   236  
   237  	resp, err := client.ListSender(req)
   238  	if err != nil {
   239  		result.Response = autorest.Response{Response: resp}
   240  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "List", resp, "Failure sending request")
   241  		return
   242  	}
   243  
   244  	result, err = client.ListResponder(resp)
   245  	if err != nil {
   246  		err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "List", resp, "Failure responding to request")
   247  		return
   248  	}
   249  
   250  	return
   251  }
   252  
   253  // ListPreparer prepares the List request.
   254  func (client AccountBackupsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   255  	pathParameters := map[string]interface{}{
   256  		"accountName":       autorest.Encode("path", accountName),
   257  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   258  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   259  	}
   260  
   261  	const APIVersion = "2020-08-01"
   262  	queryParameters := map[string]interface{}{
   263  		"api-version": APIVersion,
   264  	}
   265  
   266  	preparer := autorest.CreatePreparer(
   267  		autorest.AsGet(),
   268  		autorest.WithBaseURL(client.BaseURI),
   269  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/accountBackups", pathParameters),
   270  		autorest.WithQueryParameters(queryParameters))
   271  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   272  }
   273  
   274  // ListSender sends the List request. The method will close the
   275  // http.Response Body if it receives an error.
   276  func (client AccountBackupsClient) ListSender(req *http.Request) (*http.Response, error) {
   277  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   278  }
   279  
   280  // ListResponder handles the response to the List request. The method always
   281  // closes the http.Response Body.
   282  func (client AccountBackupsClient) ListResponder(resp *http.Response) (result BackupsList, err error) {
   283  	err = autorest.Respond(
   284  		resp,
   285  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   286  		autorest.ByUnmarshallingJSON(&result),
   287  		autorest.ByClosing())
   288  	result.Response = autorest.Response{Response: resp}
   289  	return
   290  }
   291  

View as plain text