...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-01/backup/itemlevelrecoveryconnections.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  // ItemLevelRecoveryConnectionsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type ItemLevelRecoveryConnectionsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewItemLevelRecoveryConnectionsClient creates an instance of the ItemLevelRecoveryConnectionsClient client.
    23  func NewItemLevelRecoveryConnectionsClient(subscriptionID string) ItemLevelRecoveryConnectionsClient {
    24  	return NewItemLevelRecoveryConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewItemLevelRecoveryConnectionsClientWithBaseURI creates an instance of the ItemLevelRecoveryConnectionsClient
    28  // client using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI
    29  // (sovereign clouds, Azure stack).
    30  func NewItemLevelRecoveryConnectionsClientWithBaseURI(baseURI string, subscriptionID string) ItemLevelRecoveryConnectionsClient {
    31  	return ItemLevelRecoveryConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Provision provisions a script which invokes an iSCSI connection to the backup data. Executing this script opens File
    35  // Explorer which displays the recoverable files and folders. This is an asynchronous operation. To get the
    36  // provisioning status, call GetProtectedItemOperationResult API.
    37  // Parameters:
    38  // vaultName - the name of the Recovery Services vault.
    39  // resourceGroupName - the name of the resource group associated with the Recovery Services vault.
    40  // fabricName - the fabric name associated with the backup items.
    41  // containerName - the container name associated with the backup items.
    42  // protectedItemName - the name of the backup item whose files or folders are to be restored.
    43  // recoveryPointID - the recovery point ID for backup data. The iSCSI connection will be provisioned for this
    44  // backup data.
    45  // resourceILRRequest - the resource Item Level Recovery (ILR) request.
    46  func (client ItemLevelRecoveryConnectionsClient) Provision(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string, resourceILRRequest ILRRequestResource) (result autorest.Response, err error) {
    47  	if tracing.IsEnabled() {
    48  		ctx = tracing.StartSpan(ctx, fqdn+"/ItemLevelRecoveryConnectionsClient.Provision")
    49  		defer func() {
    50  			sc := -1
    51  			if result.Response != nil {
    52  				sc = result.Response.StatusCode
    53  			}
    54  			tracing.EndSpan(ctx, sc, err)
    55  		}()
    56  	}
    57  	req, err := client.ProvisionPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, recoveryPointID, resourceILRRequest)
    58  	if err != nil {
    59  		err = autorest.NewErrorWithError(err, "backup.ItemLevelRecoveryConnectionsClient", "Provision", nil, "Failure preparing request")
    60  		return
    61  	}
    62  
    63  	resp, err := client.ProvisionSender(req)
    64  	if err != nil {
    65  		result.Response = resp
    66  		err = autorest.NewErrorWithError(err, "backup.ItemLevelRecoveryConnectionsClient", "Provision", resp, "Failure sending request")
    67  		return
    68  	}
    69  
    70  	result, err = client.ProvisionResponder(resp)
    71  	if err != nil {
    72  		err = autorest.NewErrorWithError(err, "backup.ItemLevelRecoveryConnectionsClient", "Provision", resp, "Failure responding to request")
    73  		return
    74  	}
    75  
    76  	return
    77  }
    78  
    79  // ProvisionPreparer prepares the Provision request.
    80  func (client ItemLevelRecoveryConnectionsClient) ProvisionPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string, resourceILRRequest ILRRequestResource) (*http.Request, error) {
    81  	pathParameters := map[string]interface{}{
    82  		"containerName":     autorest.Encode("path", containerName),
    83  		"fabricName":        autorest.Encode("path", fabricName),
    84  		"protectedItemName": autorest.Encode("path", protectedItemName),
    85  		"recoveryPointId":   autorest.Encode("path", recoveryPointID),
    86  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    87  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    88  		"vaultName":         autorest.Encode("path", vaultName),
    89  	}
    90  
    91  	const APIVersion = "2016-06-01"
    92  	queryParameters := map[string]interface{}{
    93  		"api-version": APIVersion,
    94  	}
    95  
    96  	preparer := autorest.CreatePreparer(
    97  		autorest.AsContentType("application/json; charset=utf-8"),
    98  		autorest.AsPost(),
    99  		autorest.WithBaseURL(client.BaseURI),
   100  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}/provisionInstantItemRecovery", pathParameters),
   101  		autorest.WithJSON(resourceILRRequest),
   102  		autorest.WithQueryParameters(queryParameters))
   103  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   104  }
   105  
   106  // ProvisionSender sends the Provision request. The method will close the
   107  // http.Response Body if it receives an error.
   108  func (client ItemLevelRecoveryConnectionsClient) ProvisionSender(req *http.Request) (*http.Response, error) {
   109  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   110  }
   111  
   112  // ProvisionResponder handles the response to the Provision request. The method always
   113  // closes the http.Response Body.
   114  func (client ItemLevelRecoveryConnectionsClient) ProvisionResponder(resp *http.Response) (result autorest.Response, err error) {
   115  	err = autorest.Respond(
   116  		resp,
   117  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   118  		autorest.ByClosing())
   119  	result.Response = resp
   120  	return
   121  }
   122  
   123  // Revoke revokes an iSCSI connection which can be used to download a script. Executing this script opens a file
   124  // explorer displaying all recoverable files and folders. This is an asynchronous operation.
   125  // Parameters:
   126  // vaultName - the name of the Recovery Services vault.
   127  // resourceGroupName - the name of the resource group associated with the Recovery Services vault.
   128  // fabricName - the fabric name associated with the backup items. The value allowed is Azure.
   129  // containerName - the container name associated with the backup items.
   130  // protectedItemName - the name of the backup items whose files or folders will be restored.
   131  // recoveryPointID - the string that identifies the recovery point. The iSCSI connection will be revoked for
   132  // this protected data.
   133  func (client ItemLevelRecoveryConnectionsClient) Revoke(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string) (result autorest.Response, err error) {
   134  	if tracing.IsEnabled() {
   135  		ctx = tracing.StartSpan(ctx, fqdn+"/ItemLevelRecoveryConnectionsClient.Revoke")
   136  		defer func() {
   137  			sc := -1
   138  			if result.Response != nil {
   139  				sc = result.Response.StatusCode
   140  			}
   141  			tracing.EndSpan(ctx, sc, err)
   142  		}()
   143  	}
   144  	req, err := client.RevokePreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, recoveryPointID)
   145  	if err != nil {
   146  		err = autorest.NewErrorWithError(err, "backup.ItemLevelRecoveryConnectionsClient", "Revoke", nil, "Failure preparing request")
   147  		return
   148  	}
   149  
   150  	resp, err := client.RevokeSender(req)
   151  	if err != nil {
   152  		result.Response = resp
   153  		err = autorest.NewErrorWithError(err, "backup.ItemLevelRecoveryConnectionsClient", "Revoke", resp, "Failure sending request")
   154  		return
   155  	}
   156  
   157  	result, err = client.RevokeResponder(resp)
   158  	if err != nil {
   159  		err = autorest.NewErrorWithError(err, "backup.ItemLevelRecoveryConnectionsClient", "Revoke", resp, "Failure responding to request")
   160  		return
   161  	}
   162  
   163  	return
   164  }
   165  
   166  // RevokePreparer prepares the Revoke request.
   167  func (client ItemLevelRecoveryConnectionsClient) RevokePreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, recoveryPointID string) (*http.Request, error) {
   168  	pathParameters := map[string]interface{}{
   169  		"containerName":     autorest.Encode("path", containerName),
   170  		"fabricName":        autorest.Encode("path", fabricName),
   171  		"protectedItemName": autorest.Encode("path", protectedItemName),
   172  		"recoveryPointId":   autorest.Encode("path", recoveryPointID),
   173  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   174  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   175  		"vaultName":         autorest.Encode("path", vaultName),
   176  	}
   177  
   178  	const APIVersion = "2016-06-01"
   179  	queryParameters := map[string]interface{}{
   180  		"api-version": APIVersion,
   181  	}
   182  
   183  	preparer := autorest.CreatePreparer(
   184  		autorest.AsPost(),
   185  		autorest.WithBaseURL(client.BaseURI),
   186  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}/revokeInstantItemRecovery", pathParameters),
   187  		autorest.WithQueryParameters(queryParameters))
   188  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   189  }
   190  
   191  // RevokeSender sends the Revoke request. The method will close the
   192  // http.Response Body if it receives an error.
   193  func (client ItemLevelRecoveryConnectionsClient) RevokeSender(req *http.Request) (*http.Response, error) {
   194  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   195  }
   196  
   197  // RevokeResponder handles the response to the Revoke request. The method always
   198  // closes the http.Response Body.
   199  func (client ItemLevelRecoveryConnectionsClient) RevokeResponder(resp *http.Response) (result autorest.Response, err error) {
   200  	err = autorest.Respond(
   201  		resp,
   202  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   203  		autorest.ByClosing())
   204  	result.Response = resp
   205  	return
   206  }
   207  

View as plain text