...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-01/backup/recoverypoints.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-01/backup

     1  package backup
     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/tracing"
    14  	"net/http"
    15  )
    16  
    17  // RecoveryPointsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type RecoveryPointsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewRecoveryPointsClient creates an instance of the RecoveryPointsClient client.
    23  func NewRecoveryPointsClient(subscriptionID string) RecoveryPointsClient {
    24  	return NewRecoveryPointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewRecoveryPointsClientWithBaseURI creates an instance of the RecoveryPointsClient client using a custom endpoint.
    28  // Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    29  func NewRecoveryPointsClientWithBaseURI(baseURI string, subscriptionID string) RecoveryPointsClient {
    30  	return RecoveryPointsClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // Get provides the backup data for the RecoveryPointID. This is an asynchronous operation. To learn the status of the
    34  // operation, call the GetProtectedItemOperationResult API.
    35  // Parameters:
    36  // vaultName - the name of the Recovery Services vault.
    37  // resourceGroupName - the name of the resource group associated with the Recovery Services vault.
    38  // fabricName - the fabric name associated with backup item.
    39  // containerName - the container name associated with backup item.
    40  // protectedItemName - the name of the backup item used in this GET operation.
    41  // recoveryPointID - the RecoveryPointID associated with this GET operation.
    42  func (client RecoveryPointsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string) (result RecoveryPointResource, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/RecoveryPointsClient.Get")
    45  		defer func() {
    46  			sc := -1
    47  			if result.Response.Response != nil {
    48  				sc = result.Response.Response.StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, recoveryPointID)
    54  	if err != nil {
    55  		err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "Get", nil, "Failure preparing request")
    56  		return
    57  	}
    58  
    59  	resp, err := client.GetSender(req)
    60  	if err != nil {
    61  		result.Response = autorest.Response{Response: resp}
    62  		err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "Get", resp, "Failure sending request")
    63  		return
    64  	}
    65  
    66  	result, err = client.GetResponder(resp)
    67  	if err != nil {
    68  		err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "Get", resp, "Failure responding to request")
    69  		return
    70  	}
    71  
    72  	return
    73  }
    74  
    75  // GetPreparer prepares the Get request.
    76  func (client RecoveryPointsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string) (*http.Request, error) {
    77  	pathParameters := map[string]interface{}{
    78  		"containerName":     autorest.Encode("path", containerName),
    79  		"fabricName":        autorest.Encode("path", fabricName),
    80  		"protectedItemName": autorest.Encode("path", protectedItemName),
    81  		"recoveryPointId":   autorest.Encode("path", recoveryPointID),
    82  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    83  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    84  		"vaultName":         autorest.Encode("path", vaultName),
    85  	}
    86  
    87  	const APIVersion = "2016-06-01"
    88  	queryParameters := map[string]interface{}{
    89  		"api-version": APIVersion,
    90  	}
    91  
    92  	preparer := autorest.CreatePreparer(
    93  		autorest.AsGet(),
    94  		autorest.WithBaseURL(client.BaseURI),
    95  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}", pathParameters),
    96  		autorest.WithQueryParameters(queryParameters))
    97  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    98  }
    99  
   100  // GetSender sends the Get request. The method will close the
   101  // http.Response Body if it receives an error.
   102  func (client RecoveryPointsClient) GetSender(req *http.Request) (*http.Response, error) {
   103  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   104  }
   105  
   106  // GetResponder handles the response to the Get request. The method always
   107  // closes the http.Response Body.
   108  func (client RecoveryPointsClient) GetResponder(resp *http.Response) (result RecoveryPointResource, err error) {
   109  	err = autorest.Respond(
   110  		resp,
   111  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   112  		autorest.ByUnmarshallingJSON(&result),
   113  		autorest.ByClosing())
   114  	result.Response = autorest.Response{Response: resp}
   115  	return
   116  }
   117  
   118  // List lists the recovery points, or backup copies, for the specified backup item.
   119  // Parameters:
   120  // vaultName - the name of the Recovery Services vault.
   121  // resourceGroupName - the name of the resource group associated with the Recovery Services vault.
   122  // fabricName - the fabric name associated with the backup item.
   123  // containerName - the container name associated with the backup item.
   124  // protectedItemName - the name of backup item used in this GET operation.
   125  // filter - startDate eq {yyyy-mm-dd hh:mm:ss PM} and endDate { yyyy-mm-dd hh:mm:ss PM}.
   126  func (client RecoveryPointsClient) List(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, filter string) (result RecoveryPointResourceList, err error) {
   127  	if tracing.IsEnabled() {
   128  		ctx = tracing.StartSpan(ctx, fqdn+"/RecoveryPointsClient.List")
   129  		defer func() {
   130  			sc := -1
   131  			if result.Response.Response != nil {
   132  				sc = result.Response.Response.StatusCode
   133  			}
   134  			tracing.EndSpan(ctx, sc, err)
   135  		}()
   136  	}
   137  	req, err := client.ListPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, filter)
   138  	if err != nil {
   139  		err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "List", nil, "Failure preparing request")
   140  		return
   141  	}
   142  
   143  	resp, err := client.ListSender(req)
   144  	if err != nil {
   145  		result.Response = autorest.Response{Response: resp}
   146  		err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "List", resp, "Failure sending request")
   147  		return
   148  	}
   149  
   150  	result, err = client.ListResponder(resp)
   151  	if err != nil {
   152  		err = autorest.NewErrorWithError(err, "backup.RecoveryPointsClient", "List", resp, "Failure responding to request")
   153  		return
   154  	}
   155  
   156  	return
   157  }
   158  
   159  // ListPreparer prepares the List request.
   160  func (client RecoveryPointsClient) ListPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, filter string) (*http.Request, error) {
   161  	pathParameters := map[string]interface{}{
   162  		"containerName":     autorest.Encode("path", containerName),
   163  		"fabricName":        autorest.Encode("path", fabricName),
   164  		"protectedItemName": autorest.Encode("path", protectedItemName),
   165  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   166  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   167  		"vaultName":         autorest.Encode("path", vaultName),
   168  	}
   169  
   170  	const APIVersion = "2016-06-01"
   171  	queryParameters := map[string]interface{}{
   172  		"api-version": APIVersion,
   173  	}
   174  	if len(filter) > 0 {
   175  		queryParameters["$filter"] = autorest.Encode("query", filter)
   176  	}
   177  
   178  	preparer := autorest.CreatePreparer(
   179  		autorest.AsGet(),
   180  		autorest.WithBaseURL(client.BaseURI),
   181  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints", pathParameters),
   182  		autorest.WithQueryParameters(queryParameters))
   183  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   184  }
   185  
   186  // ListSender sends the List request. The method will close the
   187  // http.Response Body if it receives an error.
   188  func (client RecoveryPointsClient) ListSender(req *http.Request) (*http.Response, error) {
   189  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   190  }
   191  
   192  // ListResponder handles the response to the List request. The method always
   193  // closes the http.Response Body.
   194  func (client RecoveryPointsClient) ListResponder(resp *http.Response) (result RecoveryPointResourceList, err error) {
   195  	err = autorest.Respond(
   196  		resp,
   197  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   198  		autorest.ByUnmarshallingJSON(&result),
   199  		autorest.ByClosing())
   200  	result.Response = autorest.Response{Response: resp}
   201  	return
   202  }
   203  

View as plain text