...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery/replicationprotecteditems.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery

     1  package siterecovery
     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  // ReplicationProtectedItemsClient is the client for the ReplicationProtectedItems methods of the Siterecovery service.
    19  type ReplicationProtectedItemsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewReplicationProtectedItemsClient creates an instance of the ReplicationProtectedItemsClient client.
    24  func NewReplicationProtectedItemsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectedItemsClient {
    25  	return NewReplicationProtectedItemsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    26  }
    27  
    28  // NewReplicationProtectedItemsClientWithBaseURI creates an instance of the ReplicationProtectedItemsClient client
    29  // using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
    30  // clouds, Azure stack).
    31  func NewReplicationProtectedItemsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectedItemsClient {
    32  	return ReplicationProtectedItemsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    33  }
    34  
    35  // ApplyRecoveryPoint the operation to change the recovery point of a failed over replication protected item.
    36  // Parameters:
    37  // fabricName - the ARM fabric name.
    38  // protectionContainerName - the protection container name.
    39  // replicatedProtectedItemName - the replicated protected item's name.
    40  // applyRecoveryPointInput - the ApplyRecoveryPointInput.
    41  func (client ReplicationProtectedItemsClient) ApplyRecoveryPoint(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, applyRecoveryPointInput ApplyRecoveryPointInput) (result ReplicationProtectedItemsApplyRecoveryPointFuture, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.ApplyRecoveryPoint")
    44  		defer func() {
    45  			sc := -1
    46  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    47  				sc = result.FutureAPI.Response().StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.ApplyRecoveryPointPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "ApplyRecoveryPoint", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	result, err = client.ApplyRecoveryPointSender(req)
    59  	if err != nil {
    60  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "ApplyRecoveryPoint", result.Response(), "Failure sending request")
    61  		return
    62  	}
    63  
    64  	return
    65  }
    66  
    67  // ApplyRecoveryPointPreparer prepares the ApplyRecoveryPoint request.
    68  func (client ReplicationProtectedItemsClient) ApplyRecoveryPointPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, applyRecoveryPointInput ApplyRecoveryPointInput) (*http.Request, error) {
    69  	pathParameters := map[string]interface{}{
    70  		"fabricName":                  autorest.Encode("path", fabricName),
    71  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
    72  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
    73  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
    74  		"resourceName":                autorest.Encode("path", client.ResourceName),
    75  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
    76  	}
    77  
    78  	const APIVersion = "2018-01-10"
    79  	queryParameters := map[string]interface{}{
    80  		"api-version": APIVersion,
    81  	}
    82  
    83  	preparer := autorest.CreatePreparer(
    84  		autorest.AsContentType("application/json; charset=utf-8"),
    85  		autorest.AsPost(),
    86  		autorest.WithBaseURL(client.BaseURI),
    87  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/applyRecoveryPoint", pathParameters),
    88  		autorest.WithJSON(applyRecoveryPointInput),
    89  		autorest.WithQueryParameters(queryParameters))
    90  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    91  }
    92  
    93  // ApplyRecoveryPointSender sends the ApplyRecoveryPoint request. The method will close the
    94  // http.Response Body if it receives an error.
    95  func (client ReplicationProtectedItemsClient) ApplyRecoveryPointSender(req *http.Request) (future ReplicationProtectedItemsApplyRecoveryPointFuture, err error) {
    96  	var resp *http.Response
    97  	future.FutureAPI = &azure.Future{}
    98  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    99  	if err != nil {
   100  		return
   101  	}
   102  	var azf azure.Future
   103  	azf, err = azure.NewFutureFromResponse(resp)
   104  	future.FutureAPI = &azf
   105  	future.Result = future.result
   106  	return
   107  }
   108  
   109  // ApplyRecoveryPointResponder handles the response to the ApplyRecoveryPoint request. The method always
   110  // closes the http.Response Body.
   111  func (client ReplicationProtectedItemsClient) ApplyRecoveryPointResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
   112  	err = autorest.Respond(
   113  		resp,
   114  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   115  		autorest.ByUnmarshallingJSON(&result),
   116  		autorest.ByClosing())
   117  	result.Response = autorest.Response{Response: resp}
   118  	return
   119  }
   120  
   121  // Create the operation to create an ASR replication protected item (Enable replication).
   122  // Parameters:
   123  // fabricName - name of the fabric.
   124  // protectionContainerName - protection container name.
   125  // replicatedProtectedItemName - a name for the replication protected item.
   126  // input - enable Protection Input.
   127  func (client ReplicationProtectedItemsClient) Create(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, input EnableProtectionInput) (result ReplicationProtectedItemsCreateFuture, err error) {
   128  	if tracing.IsEnabled() {
   129  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.Create")
   130  		defer func() {
   131  			sc := -1
   132  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   133  				sc = result.FutureAPI.Response().StatusCode
   134  			}
   135  			tracing.EndSpan(ctx, sc, err)
   136  		}()
   137  	}
   138  	req, err := client.CreatePreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, input)
   139  	if err != nil {
   140  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Create", nil, "Failure preparing request")
   141  		return
   142  	}
   143  
   144  	result, err = client.CreateSender(req)
   145  	if err != nil {
   146  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Create", result.Response(), "Failure sending request")
   147  		return
   148  	}
   149  
   150  	return
   151  }
   152  
   153  // CreatePreparer prepares the Create request.
   154  func (client ReplicationProtectedItemsClient) CreatePreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, input EnableProtectionInput) (*http.Request, error) {
   155  	pathParameters := map[string]interface{}{
   156  		"fabricName":                  autorest.Encode("path", fabricName),
   157  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   158  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   159  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   160  		"resourceName":                autorest.Encode("path", client.ResourceName),
   161  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   162  	}
   163  
   164  	const APIVersion = "2018-01-10"
   165  	queryParameters := map[string]interface{}{
   166  		"api-version": APIVersion,
   167  	}
   168  
   169  	preparer := autorest.CreatePreparer(
   170  		autorest.AsContentType("application/json; charset=utf-8"),
   171  		autorest.AsPut(),
   172  		autorest.WithBaseURL(client.BaseURI),
   173  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters),
   174  		autorest.WithJSON(input),
   175  		autorest.WithQueryParameters(queryParameters))
   176  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   177  }
   178  
   179  // CreateSender sends the Create request. The method will close the
   180  // http.Response Body if it receives an error.
   181  func (client ReplicationProtectedItemsClient) CreateSender(req *http.Request) (future ReplicationProtectedItemsCreateFuture, err error) {
   182  	var resp *http.Response
   183  	future.FutureAPI = &azure.Future{}
   184  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   185  	if err != nil {
   186  		return
   187  	}
   188  	var azf azure.Future
   189  	azf, err = azure.NewFutureFromResponse(resp)
   190  	future.FutureAPI = &azf
   191  	future.Result = future.result
   192  	return
   193  }
   194  
   195  // CreateResponder handles the response to the Create request. The method always
   196  // closes the http.Response Body.
   197  func (client ReplicationProtectedItemsClient) CreateResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
   198  	err = autorest.Respond(
   199  		resp,
   200  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   201  		autorest.ByUnmarshallingJSON(&result),
   202  		autorest.ByClosing())
   203  	result.Response = autorest.Response{Response: resp}
   204  	return
   205  }
   206  
   207  // Delete the operation to disable replication on a replication protected item. This will also remove the item.
   208  // Parameters:
   209  // fabricName - fabric name.
   210  // protectionContainerName - protection container name.
   211  // replicatedProtectedItemName - replication protected item name.
   212  // disableProtectionInput - disable protection input.
   213  func (client ReplicationProtectedItemsClient) Delete(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, disableProtectionInput DisableProtectionInput) (result ReplicationProtectedItemsDeleteFuture, err error) {
   214  	if tracing.IsEnabled() {
   215  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.Delete")
   216  		defer func() {
   217  			sc := -1
   218  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   219  				sc = result.FutureAPI.Response().StatusCode
   220  			}
   221  			tracing.EndSpan(ctx, sc, err)
   222  		}()
   223  	}
   224  	req, err := client.DeletePreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput)
   225  	if err != nil {
   226  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Delete", nil, "Failure preparing request")
   227  		return
   228  	}
   229  
   230  	result, err = client.DeleteSender(req)
   231  	if err != nil {
   232  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Delete", result.Response(), "Failure sending request")
   233  		return
   234  	}
   235  
   236  	return
   237  }
   238  
   239  // DeletePreparer prepares the Delete request.
   240  func (client ReplicationProtectedItemsClient) DeletePreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, disableProtectionInput DisableProtectionInput) (*http.Request, error) {
   241  	pathParameters := map[string]interface{}{
   242  		"fabricName":                  autorest.Encode("path", fabricName),
   243  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   244  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   245  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   246  		"resourceName":                autorest.Encode("path", client.ResourceName),
   247  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   248  	}
   249  
   250  	const APIVersion = "2018-01-10"
   251  	queryParameters := map[string]interface{}{
   252  		"api-version": APIVersion,
   253  	}
   254  
   255  	preparer := autorest.CreatePreparer(
   256  		autorest.AsContentType("application/json; charset=utf-8"),
   257  		autorest.AsPost(),
   258  		autorest.WithBaseURL(client.BaseURI),
   259  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/remove", pathParameters),
   260  		autorest.WithJSON(disableProtectionInput),
   261  		autorest.WithQueryParameters(queryParameters))
   262  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   263  }
   264  
   265  // DeleteSender sends the Delete request. The method will close the
   266  // http.Response Body if it receives an error.
   267  func (client ReplicationProtectedItemsClient) DeleteSender(req *http.Request) (future ReplicationProtectedItemsDeleteFuture, err error) {
   268  	var resp *http.Response
   269  	future.FutureAPI = &azure.Future{}
   270  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   271  	if err != nil {
   272  		return
   273  	}
   274  	var azf azure.Future
   275  	azf, err = azure.NewFutureFromResponse(resp)
   276  	future.FutureAPI = &azf
   277  	future.Result = future.result
   278  	return
   279  }
   280  
   281  // DeleteResponder handles the response to the Delete request. The method always
   282  // closes the http.Response Body.
   283  func (client ReplicationProtectedItemsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   284  	err = autorest.Respond(
   285  		resp,
   286  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   287  		autorest.ByClosing())
   288  	result.Response = resp
   289  	return
   290  }
   291  
   292  // FailoverCommit operation to commit the failover of the replication protected item.
   293  // Parameters:
   294  // fabricName - unique fabric name.
   295  // protectionContainerName - protection container name.
   296  // replicatedProtectedItemName - replication protected item name.
   297  func (client ReplicationProtectedItemsClient) FailoverCommit(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result ReplicationProtectedItemsFailoverCommitFuture, err error) {
   298  	if tracing.IsEnabled() {
   299  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.FailoverCommit")
   300  		defer func() {
   301  			sc := -1
   302  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   303  				sc = result.FutureAPI.Response().StatusCode
   304  			}
   305  			tracing.EndSpan(ctx, sc, err)
   306  		}()
   307  	}
   308  	req, err := client.FailoverCommitPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName)
   309  	if err != nil {
   310  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "FailoverCommit", nil, "Failure preparing request")
   311  		return
   312  	}
   313  
   314  	result, err = client.FailoverCommitSender(req)
   315  	if err != nil {
   316  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "FailoverCommit", result.Response(), "Failure sending request")
   317  		return
   318  	}
   319  
   320  	return
   321  }
   322  
   323  // FailoverCommitPreparer prepares the FailoverCommit request.
   324  func (client ReplicationProtectedItemsClient) FailoverCommitPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) {
   325  	pathParameters := map[string]interface{}{
   326  		"fabricName":                  autorest.Encode("path", fabricName),
   327  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   328  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   329  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   330  		"resourceName":                autorest.Encode("path", client.ResourceName),
   331  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   332  	}
   333  
   334  	const APIVersion = "2018-01-10"
   335  	queryParameters := map[string]interface{}{
   336  		"api-version": APIVersion,
   337  	}
   338  
   339  	preparer := autorest.CreatePreparer(
   340  		autorest.AsPost(),
   341  		autorest.WithBaseURL(client.BaseURI),
   342  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/failoverCommit", pathParameters),
   343  		autorest.WithQueryParameters(queryParameters))
   344  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   345  }
   346  
   347  // FailoverCommitSender sends the FailoverCommit request. The method will close the
   348  // http.Response Body if it receives an error.
   349  func (client ReplicationProtectedItemsClient) FailoverCommitSender(req *http.Request) (future ReplicationProtectedItemsFailoverCommitFuture, err error) {
   350  	var resp *http.Response
   351  	future.FutureAPI = &azure.Future{}
   352  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   353  	if err != nil {
   354  		return
   355  	}
   356  	var azf azure.Future
   357  	azf, err = azure.NewFutureFromResponse(resp)
   358  	future.FutureAPI = &azf
   359  	future.Result = future.result
   360  	return
   361  }
   362  
   363  // FailoverCommitResponder handles the response to the FailoverCommit request. The method always
   364  // closes the http.Response Body.
   365  func (client ReplicationProtectedItemsClient) FailoverCommitResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
   366  	err = autorest.Respond(
   367  		resp,
   368  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   369  		autorest.ByUnmarshallingJSON(&result),
   370  		autorest.ByClosing())
   371  	result.Response = autorest.Response{Response: resp}
   372  	return
   373  }
   374  
   375  // Get gets the details of an ASR replication protected item.
   376  // Parameters:
   377  // fabricName - fabric unique name.
   378  // protectionContainerName - protection container name.
   379  // replicatedProtectedItemName - replication protected item name.
   380  func (client ReplicationProtectedItemsClient) Get(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result ReplicationProtectedItem, err error) {
   381  	if tracing.IsEnabled() {
   382  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.Get")
   383  		defer func() {
   384  			sc := -1
   385  			if result.Response.Response != nil {
   386  				sc = result.Response.Response.StatusCode
   387  			}
   388  			tracing.EndSpan(ctx, sc, err)
   389  		}()
   390  	}
   391  	req, err := client.GetPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName)
   392  	if err != nil {
   393  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Get", nil, "Failure preparing request")
   394  		return
   395  	}
   396  
   397  	resp, err := client.GetSender(req)
   398  	if err != nil {
   399  		result.Response = autorest.Response{Response: resp}
   400  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Get", resp, "Failure sending request")
   401  		return
   402  	}
   403  
   404  	result, err = client.GetResponder(resp)
   405  	if err != nil {
   406  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Get", resp, "Failure responding to request")
   407  		return
   408  	}
   409  
   410  	return
   411  }
   412  
   413  // GetPreparer prepares the Get request.
   414  func (client ReplicationProtectedItemsClient) GetPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) {
   415  	pathParameters := map[string]interface{}{
   416  		"fabricName":                  autorest.Encode("path", fabricName),
   417  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   418  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   419  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   420  		"resourceName":                autorest.Encode("path", client.ResourceName),
   421  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   422  	}
   423  
   424  	const APIVersion = "2018-01-10"
   425  	queryParameters := map[string]interface{}{
   426  		"api-version": APIVersion,
   427  	}
   428  
   429  	preparer := autorest.CreatePreparer(
   430  		autorest.AsGet(),
   431  		autorest.WithBaseURL(client.BaseURI),
   432  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters),
   433  		autorest.WithQueryParameters(queryParameters))
   434  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   435  }
   436  
   437  // GetSender sends the Get request. The method will close the
   438  // http.Response Body if it receives an error.
   439  func (client ReplicationProtectedItemsClient) GetSender(req *http.Request) (*http.Response, error) {
   440  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   441  }
   442  
   443  // GetResponder handles the response to the Get request. The method always
   444  // closes the http.Response Body.
   445  func (client ReplicationProtectedItemsClient) GetResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
   446  	err = autorest.Respond(
   447  		resp,
   448  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   449  		autorest.ByUnmarshallingJSON(&result),
   450  		autorest.ByClosing())
   451  	result.Response = autorest.Response{Response: resp}
   452  	return
   453  }
   454  
   455  // List gets the list of ASR replication protected items in the vault.
   456  // Parameters:
   457  // skipToken - the pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null
   458  // filter - oData filter options.
   459  func (client ReplicationProtectedItemsClient) List(ctx context.Context, skipToken string, filter string) (result ReplicationProtectedItemCollectionPage, err error) {
   460  	if tracing.IsEnabled() {
   461  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.List")
   462  		defer func() {
   463  			sc := -1
   464  			if result.rpic.Response.Response != nil {
   465  				sc = result.rpic.Response.Response.StatusCode
   466  			}
   467  			tracing.EndSpan(ctx, sc, err)
   468  		}()
   469  	}
   470  	result.fn = client.listNextResults
   471  	req, err := client.ListPreparer(ctx, skipToken, filter)
   472  	if err != nil {
   473  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "List", nil, "Failure preparing request")
   474  		return
   475  	}
   476  
   477  	resp, err := client.ListSender(req)
   478  	if err != nil {
   479  		result.rpic.Response = autorest.Response{Response: resp}
   480  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "List", resp, "Failure sending request")
   481  		return
   482  	}
   483  
   484  	result.rpic, err = client.ListResponder(resp)
   485  	if err != nil {
   486  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "List", resp, "Failure responding to request")
   487  		return
   488  	}
   489  	if result.rpic.hasNextLink() && result.rpic.IsEmpty() {
   490  		err = result.NextWithContext(ctx)
   491  		return
   492  	}
   493  
   494  	return
   495  }
   496  
   497  // ListPreparer prepares the List request.
   498  func (client ReplicationProtectedItemsClient) ListPreparer(ctx context.Context, skipToken string, filter string) (*http.Request, error) {
   499  	pathParameters := map[string]interface{}{
   500  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   501  		"resourceName":      autorest.Encode("path", client.ResourceName),
   502  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   503  	}
   504  
   505  	const APIVersion = "2018-01-10"
   506  	queryParameters := map[string]interface{}{
   507  		"api-version": APIVersion,
   508  	}
   509  	if len(skipToken) > 0 {
   510  		queryParameters["skipToken"] = autorest.Encode("query", skipToken)
   511  	}
   512  	if len(filter) > 0 {
   513  		queryParameters["$filter"] = autorest.Encode("query", filter)
   514  	}
   515  
   516  	preparer := autorest.CreatePreparer(
   517  		autorest.AsGet(),
   518  		autorest.WithBaseURL(client.BaseURI),
   519  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationProtectedItems", pathParameters),
   520  		autorest.WithQueryParameters(queryParameters))
   521  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   522  }
   523  
   524  // ListSender sends the List request. The method will close the
   525  // http.Response Body if it receives an error.
   526  func (client ReplicationProtectedItemsClient) ListSender(req *http.Request) (*http.Response, error) {
   527  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   528  }
   529  
   530  // ListResponder handles the response to the List request. The method always
   531  // closes the http.Response Body.
   532  func (client ReplicationProtectedItemsClient) ListResponder(resp *http.Response) (result ReplicationProtectedItemCollection, err error) {
   533  	err = autorest.Respond(
   534  		resp,
   535  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   536  		autorest.ByUnmarshallingJSON(&result),
   537  		autorest.ByClosing())
   538  	result.Response = autorest.Response{Response: resp}
   539  	return
   540  }
   541  
   542  // listNextResults retrieves the next set of results, if any.
   543  func (client ReplicationProtectedItemsClient) listNextResults(ctx context.Context, lastResults ReplicationProtectedItemCollection) (result ReplicationProtectedItemCollection, err error) {
   544  	req, err := lastResults.replicationProtectedItemCollectionPreparer(ctx)
   545  	if err != nil {
   546  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "listNextResults", nil, "Failure preparing next results request")
   547  	}
   548  	if req == nil {
   549  		return
   550  	}
   551  	resp, err := client.ListSender(req)
   552  	if err != nil {
   553  		result.Response = autorest.Response{Response: resp}
   554  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "listNextResults", resp, "Failure sending next results request")
   555  	}
   556  	result, err = client.ListResponder(resp)
   557  	if err != nil {
   558  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "listNextResults", resp, "Failure responding to next results request")
   559  	}
   560  	return
   561  }
   562  
   563  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   564  func (client ReplicationProtectedItemsClient) ListComplete(ctx context.Context, skipToken string, filter string) (result ReplicationProtectedItemCollectionIterator, err error) {
   565  	if tracing.IsEnabled() {
   566  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.List")
   567  		defer func() {
   568  			sc := -1
   569  			if result.Response().Response.Response != nil {
   570  				sc = result.page.Response().Response.Response.StatusCode
   571  			}
   572  			tracing.EndSpan(ctx, sc, err)
   573  		}()
   574  	}
   575  	result.page, err = client.List(ctx, skipToken, filter)
   576  	return
   577  }
   578  
   579  // ListByReplicationProtectionContainers gets the list of ASR replication protected items in the protection container.
   580  // Parameters:
   581  // fabricName - fabric name.
   582  // protectionContainerName - protection container name.
   583  func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainers(ctx context.Context, fabricName string, protectionContainerName string) (result ReplicationProtectedItemCollectionPage, err error) {
   584  	if tracing.IsEnabled() {
   585  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.ListByReplicationProtectionContainers")
   586  		defer func() {
   587  			sc := -1
   588  			if result.rpic.Response.Response != nil {
   589  				sc = result.rpic.Response.Response.StatusCode
   590  			}
   591  			tracing.EndSpan(ctx, sc, err)
   592  		}()
   593  	}
   594  	result.fn = client.listByReplicationProtectionContainersNextResults
   595  	req, err := client.ListByReplicationProtectionContainersPreparer(ctx, fabricName, protectionContainerName)
   596  	if err != nil {
   597  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing request")
   598  		return
   599  	}
   600  
   601  	resp, err := client.ListByReplicationProtectionContainersSender(req)
   602  	if err != nil {
   603  		result.rpic.Response = autorest.Response{Response: resp}
   604  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", resp, "Failure sending request")
   605  		return
   606  	}
   607  
   608  	result.rpic, err = client.ListByReplicationProtectionContainersResponder(resp)
   609  	if err != nil {
   610  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to request")
   611  		return
   612  	}
   613  	if result.rpic.hasNextLink() && result.rpic.IsEmpty() {
   614  		err = result.NextWithContext(ctx)
   615  		return
   616  	}
   617  
   618  	return
   619  }
   620  
   621  // ListByReplicationProtectionContainersPreparer prepares the ListByReplicationProtectionContainers request.
   622  func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersPreparer(ctx context.Context, fabricName string, protectionContainerName string) (*http.Request, error) {
   623  	pathParameters := map[string]interface{}{
   624  		"fabricName":              autorest.Encode("path", fabricName),
   625  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   626  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   627  		"resourceName":            autorest.Encode("path", client.ResourceName),
   628  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   629  	}
   630  
   631  	const APIVersion = "2018-01-10"
   632  	queryParameters := map[string]interface{}{
   633  		"api-version": APIVersion,
   634  	}
   635  
   636  	preparer := autorest.CreatePreparer(
   637  		autorest.AsGet(),
   638  		autorest.WithBaseURL(client.BaseURI),
   639  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems", pathParameters),
   640  		autorest.WithQueryParameters(queryParameters))
   641  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   642  }
   643  
   644  // ListByReplicationProtectionContainersSender sends the ListByReplicationProtectionContainers request. The method will close the
   645  // http.Response Body if it receives an error.
   646  func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersSender(req *http.Request) (*http.Response, error) {
   647  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   648  }
   649  
   650  // ListByReplicationProtectionContainersResponder handles the response to the ListByReplicationProtectionContainers request. The method always
   651  // closes the http.Response Body.
   652  func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersResponder(resp *http.Response) (result ReplicationProtectedItemCollection, err error) {
   653  	err = autorest.Respond(
   654  		resp,
   655  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   656  		autorest.ByUnmarshallingJSON(&result),
   657  		autorest.ByClosing())
   658  	result.Response = autorest.Response{Response: resp}
   659  	return
   660  }
   661  
   662  // listByReplicationProtectionContainersNextResults retrieves the next set of results, if any.
   663  func (client ReplicationProtectedItemsClient) listByReplicationProtectionContainersNextResults(ctx context.Context, lastResults ReplicationProtectedItemCollection) (result ReplicationProtectedItemCollection, err error) {
   664  	req, err := lastResults.replicationProtectedItemCollectionPreparer(ctx)
   665  	if err != nil {
   666  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "listByReplicationProtectionContainersNextResults", nil, "Failure preparing next results request")
   667  	}
   668  	if req == nil {
   669  		return
   670  	}
   671  	resp, err := client.ListByReplicationProtectionContainersSender(req)
   672  	if err != nil {
   673  		result.Response = autorest.Response{Response: resp}
   674  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "listByReplicationProtectionContainersNextResults", resp, "Failure sending next results request")
   675  	}
   676  	result, err = client.ListByReplicationProtectionContainersResponder(resp)
   677  	if err != nil {
   678  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "listByReplicationProtectionContainersNextResults", resp, "Failure responding to next results request")
   679  	}
   680  	return
   681  }
   682  
   683  // ListByReplicationProtectionContainersComplete enumerates all values, automatically crossing page boundaries as required.
   684  func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, fabricName string, protectionContainerName string) (result ReplicationProtectedItemCollectionIterator, err error) {
   685  	if tracing.IsEnabled() {
   686  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.ListByReplicationProtectionContainers")
   687  		defer func() {
   688  			sc := -1
   689  			if result.Response().Response.Response != nil {
   690  				sc = result.page.Response().Response.Response.StatusCode
   691  			}
   692  			tracing.EndSpan(ctx, sc, err)
   693  		}()
   694  	}
   695  	result.page, err = client.ListByReplicationProtectionContainers(ctx, fabricName, protectionContainerName)
   696  	return
   697  }
   698  
   699  // PlannedFailover operation to initiate a planned failover of the replication protected item.
   700  // Parameters:
   701  // fabricName - unique fabric name.
   702  // protectionContainerName - protection container name.
   703  // replicatedProtectedItemName - replication protected item name.
   704  // failoverInput - disable protection input.
   705  func (client ReplicationProtectedItemsClient) PlannedFailover(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput PlannedFailoverInput) (result ReplicationProtectedItemsPlannedFailoverFuture, err error) {
   706  	if tracing.IsEnabled() {
   707  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.PlannedFailover")
   708  		defer func() {
   709  			sc := -1
   710  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   711  				sc = result.FutureAPI.Response().StatusCode
   712  			}
   713  			tracing.EndSpan(ctx, sc, err)
   714  		}()
   715  	}
   716  	req, err := client.PlannedFailoverPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput)
   717  	if err != nil {
   718  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "PlannedFailover", nil, "Failure preparing request")
   719  		return
   720  	}
   721  
   722  	result, err = client.PlannedFailoverSender(req)
   723  	if err != nil {
   724  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "PlannedFailover", result.Response(), "Failure sending request")
   725  		return
   726  	}
   727  
   728  	return
   729  }
   730  
   731  // PlannedFailoverPreparer prepares the PlannedFailover request.
   732  func (client ReplicationProtectedItemsClient) PlannedFailoverPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput PlannedFailoverInput) (*http.Request, error) {
   733  	pathParameters := map[string]interface{}{
   734  		"fabricName":                  autorest.Encode("path", fabricName),
   735  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   736  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   737  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   738  		"resourceName":                autorest.Encode("path", client.ResourceName),
   739  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   740  	}
   741  
   742  	const APIVersion = "2018-01-10"
   743  	queryParameters := map[string]interface{}{
   744  		"api-version": APIVersion,
   745  	}
   746  
   747  	preparer := autorest.CreatePreparer(
   748  		autorest.AsContentType("application/json; charset=utf-8"),
   749  		autorest.AsPost(),
   750  		autorest.WithBaseURL(client.BaseURI),
   751  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/plannedFailover", pathParameters),
   752  		autorest.WithJSON(failoverInput),
   753  		autorest.WithQueryParameters(queryParameters))
   754  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   755  }
   756  
   757  // PlannedFailoverSender sends the PlannedFailover request. The method will close the
   758  // http.Response Body if it receives an error.
   759  func (client ReplicationProtectedItemsClient) PlannedFailoverSender(req *http.Request) (future ReplicationProtectedItemsPlannedFailoverFuture, err error) {
   760  	var resp *http.Response
   761  	future.FutureAPI = &azure.Future{}
   762  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   763  	if err != nil {
   764  		return
   765  	}
   766  	var azf azure.Future
   767  	azf, err = azure.NewFutureFromResponse(resp)
   768  	future.FutureAPI = &azf
   769  	future.Result = future.result
   770  	return
   771  }
   772  
   773  // PlannedFailoverResponder handles the response to the PlannedFailover request. The method always
   774  // closes the http.Response Body.
   775  func (client ReplicationProtectedItemsClient) PlannedFailoverResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
   776  	err = autorest.Respond(
   777  		resp,
   778  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   779  		autorest.ByUnmarshallingJSON(&result),
   780  		autorest.ByClosing())
   781  	result.Response = autorest.Response{Response: resp}
   782  	return
   783  }
   784  
   785  // Purge the operation to delete or purge a replication protected item. This operation will force delete the
   786  // replication protected item. Use the remove operation on replication protected item to perform a clean disable
   787  // replication for the item.
   788  // Parameters:
   789  // fabricName - fabric name.
   790  // protectionContainerName - protection container name.
   791  // replicatedProtectedItemName - replication protected item name.
   792  func (client ReplicationProtectedItemsClient) Purge(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result ReplicationProtectedItemsPurgeFuture, err error) {
   793  	if tracing.IsEnabled() {
   794  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.Purge")
   795  		defer func() {
   796  			sc := -1
   797  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   798  				sc = result.FutureAPI.Response().StatusCode
   799  			}
   800  			tracing.EndSpan(ctx, sc, err)
   801  		}()
   802  	}
   803  	req, err := client.PurgePreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName)
   804  	if err != nil {
   805  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Purge", nil, "Failure preparing request")
   806  		return
   807  	}
   808  
   809  	result, err = client.PurgeSender(req)
   810  	if err != nil {
   811  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Purge", result.Response(), "Failure sending request")
   812  		return
   813  	}
   814  
   815  	return
   816  }
   817  
   818  // PurgePreparer prepares the Purge request.
   819  func (client ReplicationProtectedItemsClient) PurgePreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) {
   820  	pathParameters := map[string]interface{}{
   821  		"fabricName":                  autorest.Encode("path", fabricName),
   822  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   823  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   824  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   825  		"resourceName":                autorest.Encode("path", client.ResourceName),
   826  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   827  	}
   828  
   829  	const APIVersion = "2018-01-10"
   830  	queryParameters := map[string]interface{}{
   831  		"api-version": APIVersion,
   832  	}
   833  
   834  	preparer := autorest.CreatePreparer(
   835  		autorest.AsDelete(),
   836  		autorest.WithBaseURL(client.BaseURI),
   837  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters),
   838  		autorest.WithQueryParameters(queryParameters))
   839  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   840  }
   841  
   842  // PurgeSender sends the Purge request. The method will close the
   843  // http.Response Body if it receives an error.
   844  func (client ReplicationProtectedItemsClient) PurgeSender(req *http.Request) (future ReplicationProtectedItemsPurgeFuture, err error) {
   845  	var resp *http.Response
   846  	future.FutureAPI = &azure.Future{}
   847  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   848  	if err != nil {
   849  		return
   850  	}
   851  	var azf azure.Future
   852  	azf, err = azure.NewFutureFromResponse(resp)
   853  	future.FutureAPI = &azf
   854  	future.Result = future.result
   855  	return
   856  }
   857  
   858  // PurgeResponder handles the response to the Purge request. The method always
   859  // closes the http.Response Body.
   860  func (client ReplicationProtectedItemsClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) {
   861  	err = autorest.Respond(
   862  		resp,
   863  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   864  		autorest.ByClosing())
   865  	result.Response = resp
   866  	return
   867  }
   868  
   869  // RepairReplication the operation to start resynchronize/repair replication for a replication protected item requiring
   870  // resynchronization.
   871  // Parameters:
   872  // fabricName - the name of the fabric.
   873  // protectionContainerName - the name of the container.
   874  // replicatedProtectedItemName - the name of the replication protected item.
   875  func (client ReplicationProtectedItemsClient) RepairReplication(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result ReplicationProtectedItemsRepairReplicationFuture, err error) {
   876  	if tracing.IsEnabled() {
   877  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.RepairReplication")
   878  		defer func() {
   879  			sc := -1
   880  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   881  				sc = result.FutureAPI.Response().StatusCode
   882  			}
   883  			tracing.EndSpan(ctx, sc, err)
   884  		}()
   885  	}
   886  	req, err := client.RepairReplicationPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName)
   887  	if err != nil {
   888  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "RepairReplication", nil, "Failure preparing request")
   889  		return
   890  	}
   891  
   892  	result, err = client.RepairReplicationSender(req)
   893  	if err != nil {
   894  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "RepairReplication", result.Response(), "Failure sending request")
   895  		return
   896  	}
   897  
   898  	return
   899  }
   900  
   901  // RepairReplicationPreparer prepares the RepairReplication request.
   902  func (client ReplicationProtectedItemsClient) RepairReplicationPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) {
   903  	pathParameters := map[string]interface{}{
   904  		"fabricName":                  autorest.Encode("path", fabricName),
   905  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   906  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   907  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   908  		"resourceName":                autorest.Encode("path", client.ResourceName),
   909  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   910  	}
   911  
   912  	const APIVersion = "2018-01-10"
   913  	queryParameters := map[string]interface{}{
   914  		"api-version": APIVersion,
   915  	}
   916  
   917  	preparer := autorest.CreatePreparer(
   918  		autorest.AsPost(),
   919  		autorest.WithBaseURL(client.BaseURI),
   920  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/repairReplication", pathParameters),
   921  		autorest.WithQueryParameters(queryParameters))
   922  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   923  }
   924  
   925  // RepairReplicationSender sends the RepairReplication request. The method will close the
   926  // http.Response Body if it receives an error.
   927  func (client ReplicationProtectedItemsClient) RepairReplicationSender(req *http.Request) (future ReplicationProtectedItemsRepairReplicationFuture, err error) {
   928  	var resp *http.Response
   929  	future.FutureAPI = &azure.Future{}
   930  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   931  	if err != nil {
   932  		return
   933  	}
   934  	var azf azure.Future
   935  	azf, err = azure.NewFutureFromResponse(resp)
   936  	future.FutureAPI = &azf
   937  	future.Result = future.result
   938  	return
   939  }
   940  
   941  // RepairReplicationResponder handles the response to the RepairReplication request. The method always
   942  // closes the http.Response Body.
   943  func (client ReplicationProtectedItemsClient) RepairReplicationResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
   944  	err = autorest.Respond(
   945  		resp,
   946  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   947  		autorest.ByUnmarshallingJSON(&result),
   948  		autorest.ByClosing())
   949  	result.Response = autorest.Response{Response: resp}
   950  	return
   951  }
   952  
   953  // Reprotect operation to reprotect or reverse replicate a failed over replication protected item.
   954  // Parameters:
   955  // fabricName - unique fabric name.
   956  // protectionContainerName - protection container name.
   957  // replicatedProtectedItemName - replication protected item name.
   958  // rrInput - disable protection input.
   959  func (client ReplicationProtectedItemsClient) Reprotect(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, rrInput ReverseReplicationInput) (result ReplicationProtectedItemsReprotectFuture, err error) {
   960  	if tracing.IsEnabled() {
   961  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.Reprotect")
   962  		defer func() {
   963  			sc := -1
   964  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   965  				sc = result.FutureAPI.Response().StatusCode
   966  			}
   967  			tracing.EndSpan(ctx, sc, err)
   968  		}()
   969  	}
   970  	req, err := client.ReprotectPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, rrInput)
   971  	if err != nil {
   972  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Reprotect", nil, "Failure preparing request")
   973  		return
   974  	}
   975  
   976  	result, err = client.ReprotectSender(req)
   977  	if err != nil {
   978  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Reprotect", result.Response(), "Failure sending request")
   979  		return
   980  	}
   981  
   982  	return
   983  }
   984  
   985  // ReprotectPreparer prepares the Reprotect request.
   986  func (client ReplicationProtectedItemsClient) ReprotectPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, rrInput ReverseReplicationInput) (*http.Request, error) {
   987  	pathParameters := map[string]interface{}{
   988  		"fabricName":                  autorest.Encode("path", fabricName),
   989  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
   990  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
   991  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
   992  		"resourceName":                autorest.Encode("path", client.ResourceName),
   993  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
   994  	}
   995  
   996  	const APIVersion = "2018-01-10"
   997  	queryParameters := map[string]interface{}{
   998  		"api-version": APIVersion,
   999  	}
  1000  
  1001  	preparer := autorest.CreatePreparer(
  1002  		autorest.AsContentType("application/json; charset=utf-8"),
  1003  		autorest.AsPost(),
  1004  		autorest.WithBaseURL(client.BaseURI),
  1005  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/reProtect", pathParameters),
  1006  		autorest.WithJSON(rrInput),
  1007  		autorest.WithQueryParameters(queryParameters))
  1008  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1009  }
  1010  
  1011  // ReprotectSender sends the Reprotect request. The method will close the
  1012  // http.Response Body if it receives an error.
  1013  func (client ReplicationProtectedItemsClient) ReprotectSender(req *http.Request) (future ReplicationProtectedItemsReprotectFuture, err error) {
  1014  	var resp *http.Response
  1015  	future.FutureAPI = &azure.Future{}
  1016  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1017  	if err != nil {
  1018  		return
  1019  	}
  1020  	var azf azure.Future
  1021  	azf, err = azure.NewFutureFromResponse(resp)
  1022  	future.FutureAPI = &azf
  1023  	future.Result = future.result
  1024  	return
  1025  }
  1026  
  1027  // ReprotectResponder handles the response to the Reprotect request. The method always
  1028  // closes the http.Response Body.
  1029  func (client ReplicationProtectedItemsClient) ReprotectResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
  1030  	err = autorest.Respond(
  1031  		resp,
  1032  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1033  		autorest.ByUnmarshallingJSON(&result),
  1034  		autorest.ByClosing())
  1035  	result.Response = autorest.Response{Response: resp}
  1036  	return
  1037  }
  1038  
  1039  // TestFailover operation to perform a test failover of the replication protected item.
  1040  // Parameters:
  1041  // fabricName - unique fabric name.
  1042  // protectionContainerName - protection container name.
  1043  // replicatedProtectedItemName - replication protected item name.
  1044  // failoverInput - test failover input.
  1045  func (client ReplicationProtectedItemsClient) TestFailover(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput TestFailoverInput) (result ReplicationProtectedItemsTestFailoverFuture, err error) {
  1046  	if tracing.IsEnabled() {
  1047  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.TestFailover")
  1048  		defer func() {
  1049  			sc := -1
  1050  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1051  				sc = result.FutureAPI.Response().StatusCode
  1052  			}
  1053  			tracing.EndSpan(ctx, sc, err)
  1054  		}()
  1055  	}
  1056  	req, err := client.TestFailoverPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput)
  1057  	if err != nil {
  1058  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "TestFailover", nil, "Failure preparing request")
  1059  		return
  1060  	}
  1061  
  1062  	result, err = client.TestFailoverSender(req)
  1063  	if err != nil {
  1064  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "TestFailover", result.Response(), "Failure sending request")
  1065  		return
  1066  	}
  1067  
  1068  	return
  1069  }
  1070  
  1071  // TestFailoverPreparer prepares the TestFailover request.
  1072  func (client ReplicationProtectedItemsClient) TestFailoverPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput TestFailoverInput) (*http.Request, error) {
  1073  	pathParameters := map[string]interface{}{
  1074  		"fabricName":                  autorest.Encode("path", fabricName),
  1075  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
  1076  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
  1077  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
  1078  		"resourceName":                autorest.Encode("path", client.ResourceName),
  1079  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
  1080  	}
  1081  
  1082  	const APIVersion = "2018-01-10"
  1083  	queryParameters := map[string]interface{}{
  1084  		"api-version": APIVersion,
  1085  	}
  1086  
  1087  	preparer := autorest.CreatePreparer(
  1088  		autorest.AsContentType("application/json; charset=utf-8"),
  1089  		autorest.AsPost(),
  1090  		autorest.WithBaseURL(client.BaseURI),
  1091  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailover", pathParameters),
  1092  		autorest.WithJSON(failoverInput),
  1093  		autorest.WithQueryParameters(queryParameters))
  1094  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1095  }
  1096  
  1097  // TestFailoverSender sends the TestFailover request. The method will close the
  1098  // http.Response Body if it receives an error.
  1099  func (client ReplicationProtectedItemsClient) TestFailoverSender(req *http.Request) (future ReplicationProtectedItemsTestFailoverFuture, err error) {
  1100  	var resp *http.Response
  1101  	future.FutureAPI = &azure.Future{}
  1102  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1103  	if err != nil {
  1104  		return
  1105  	}
  1106  	var azf azure.Future
  1107  	azf, err = azure.NewFutureFromResponse(resp)
  1108  	future.FutureAPI = &azf
  1109  	future.Result = future.result
  1110  	return
  1111  }
  1112  
  1113  // TestFailoverResponder handles the response to the TestFailover request. The method always
  1114  // closes the http.Response Body.
  1115  func (client ReplicationProtectedItemsClient) TestFailoverResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
  1116  	err = autorest.Respond(
  1117  		resp,
  1118  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1119  		autorest.ByUnmarshallingJSON(&result),
  1120  		autorest.ByClosing())
  1121  	result.Response = autorest.Response{Response: resp}
  1122  	return
  1123  }
  1124  
  1125  // TestFailoverCleanup operation to clean up the test failover of a replication protected item.
  1126  // Parameters:
  1127  // fabricName - unique fabric name.
  1128  // protectionContainerName - protection container name.
  1129  // replicatedProtectedItemName - replication protected item name.
  1130  // cleanupInput - test failover cleanup input.
  1131  func (client ReplicationProtectedItemsClient) TestFailoverCleanup(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, cleanupInput TestFailoverCleanupInput) (result ReplicationProtectedItemsTestFailoverCleanupFuture, err error) {
  1132  	if tracing.IsEnabled() {
  1133  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.TestFailoverCleanup")
  1134  		defer func() {
  1135  			sc := -1
  1136  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1137  				sc = result.FutureAPI.Response().StatusCode
  1138  			}
  1139  			tracing.EndSpan(ctx, sc, err)
  1140  		}()
  1141  	}
  1142  	if err := validation.Validate([]validation.Validation{
  1143  		{TargetValue: cleanupInput,
  1144  			Constraints: []validation.Constraint{{Target: "cleanupInput.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
  1145  		return result, validation.NewError("siterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup", err.Error())
  1146  	}
  1147  
  1148  	req, err := client.TestFailoverCleanupPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput)
  1149  	if err != nil {
  1150  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup", nil, "Failure preparing request")
  1151  		return
  1152  	}
  1153  
  1154  	result, err = client.TestFailoverCleanupSender(req)
  1155  	if err != nil {
  1156  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup", result.Response(), "Failure sending request")
  1157  		return
  1158  	}
  1159  
  1160  	return
  1161  }
  1162  
  1163  // TestFailoverCleanupPreparer prepares the TestFailoverCleanup request.
  1164  func (client ReplicationProtectedItemsClient) TestFailoverCleanupPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, cleanupInput TestFailoverCleanupInput) (*http.Request, error) {
  1165  	pathParameters := map[string]interface{}{
  1166  		"fabricName":                  autorest.Encode("path", fabricName),
  1167  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
  1168  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
  1169  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
  1170  		"resourceName":                autorest.Encode("path", client.ResourceName),
  1171  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
  1172  	}
  1173  
  1174  	const APIVersion = "2018-01-10"
  1175  	queryParameters := map[string]interface{}{
  1176  		"api-version": APIVersion,
  1177  	}
  1178  
  1179  	preparer := autorest.CreatePreparer(
  1180  		autorest.AsContentType("application/json; charset=utf-8"),
  1181  		autorest.AsPost(),
  1182  		autorest.WithBaseURL(client.BaseURI),
  1183  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailoverCleanup", pathParameters),
  1184  		autorest.WithJSON(cleanupInput),
  1185  		autorest.WithQueryParameters(queryParameters))
  1186  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1187  }
  1188  
  1189  // TestFailoverCleanupSender sends the TestFailoverCleanup request. The method will close the
  1190  // http.Response Body if it receives an error.
  1191  func (client ReplicationProtectedItemsClient) TestFailoverCleanupSender(req *http.Request) (future ReplicationProtectedItemsTestFailoverCleanupFuture, err error) {
  1192  	var resp *http.Response
  1193  	future.FutureAPI = &azure.Future{}
  1194  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1195  	if err != nil {
  1196  		return
  1197  	}
  1198  	var azf azure.Future
  1199  	azf, err = azure.NewFutureFromResponse(resp)
  1200  	future.FutureAPI = &azf
  1201  	future.Result = future.result
  1202  	return
  1203  }
  1204  
  1205  // TestFailoverCleanupResponder handles the response to the TestFailoverCleanup request. The method always
  1206  // closes the http.Response Body.
  1207  func (client ReplicationProtectedItemsClient) TestFailoverCleanupResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
  1208  	err = autorest.Respond(
  1209  		resp,
  1210  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1211  		autorest.ByUnmarshallingJSON(&result),
  1212  		autorest.ByClosing())
  1213  	result.Response = autorest.Response{Response: resp}
  1214  	return
  1215  }
  1216  
  1217  // UnplannedFailover operation to initiate a failover of the replication protected item.
  1218  // Parameters:
  1219  // fabricName - unique fabric name.
  1220  // protectionContainerName - protection container name.
  1221  // replicatedProtectedItemName - replication protected item name.
  1222  // failoverInput - disable protection input.
  1223  func (client ReplicationProtectedItemsClient) UnplannedFailover(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput UnplannedFailoverInput) (result ReplicationProtectedItemsUnplannedFailoverFuture, err error) {
  1224  	if tracing.IsEnabled() {
  1225  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.UnplannedFailover")
  1226  		defer func() {
  1227  			sc := -1
  1228  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1229  				sc = result.FutureAPI.Response().StatusCode
  1230  			}
  1231  			tracing.EndSpan(ctx, sc, err)
  1232  		}()
  1233  	}
  1234  	req, err := client.UnplannedFailoverPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput)
  1235  	if err != nil {
  1236  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "UnplannedFailover", nil, "Failure preparing request")
  1237  		return
  1238  	}
  1239  
  1240  	result, err = client.UnplannedFailoverSender(req)
  1241  	if err != nil {
  1242  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "UnplannedFailover", result.Response(), "Failure sending request")
  1243  		return
  1244  	}
  1245  
  1246  	return
  1247  }
  1248  
  1249  // UnplannedFailoverPreparer prepares the UnplannedFailover request.
  1250  func (client ReplicationProtectedItemsClient) UnplannedFailoverPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput UnplannedFailoverInput) (*http.Request, error) {
  1251  	pathParameters := map[string]interface{}{
  1252  		"fabricName":                  autorest.Encode("path", fabricName),
  1253  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
  1254  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
  1255  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
  1256  		"resourceName":                autorest.Encode("path", client.ResourceName),
  1257  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
  1258  	}
  1259  
  1260  	const APIVersion = "2018-01-10"
  1261  	queryParameters := map[string]interface{}{
  1262  		"api-version": APIVersion,
  1263  	}
  1264  
  1265  	preparer := autorest.CreatePreparer(
  1266  		autorest.AsContentType("application/json; charset=utf-8"),
  1267  		autorest.AsPost(),
  1268  		autorest.WithBaseURL(client.BaseURI),
  1269  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/unplannedFailover", pathParameters),
  1270  		autorest.WithJSON(failoverInput),
  1271  		autorest.WithQueryParameters(queryParameters))
  1272  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1273  }
  1274  
  1275  // UnplannedFailoverSender sends the UnplannedFailover request. The method will close the
  1276  // http.Response Body if it receives an error.
  1277  func (client ReplicationProtectedItemsClient) UnplannedFailoverSender(req *http.Request) (future ReplicationProtectedItemsUnplannedFailoverFuture, err error) {
  1278  	var resp *http.Response
  1279  	future.FutureAPI = &azure.Future{}
  1280  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1281  	if err != nil {
  1282  		return
  1283  	}
  1284  	var azf azure.Future
  1285  	azf, err = azure.NewFutureFromResponse(resp)
  1286  	future.FutureAPI = &azf
  1287  	future.Result = future.result
  1288  	return
  1289  }
  1290  
  1291  // UnplannedFailoverResponder handles the response to the UnplannedFailover request. The method always
  1292  // closes the http.Response Body.
  1293  func (client ReplicationProtectedItemsClient) UnplannedFailoverResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
  1294  	err = autorest.Respond(
  1295  		resp,
  1296  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1297  		autorest.ByUnmarshallingJSON(&result),
  1298  		autorest.ByClosing())
  1299  	result.Response = autorest.Response{Response: resp}
  1300  	return
  1301  }
  1302  
  1303  // Update the operation to update the recovery settings of an ASR replication protected item.
  1304  // Parameters:
  1305  // fabricName - fabric name.
  1306  // protectionContainerName - protection container name.
  1307  // replicatedProtectedItemName - replication protected item name.
  1308  // updateProtectionInput - update protection input.
  1309  func (client ReplicationProtectedItemsClient) Update(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, updateProtectionInput UpdateReplicationProtectedItemInput) (result ReplicationProtectedItemsUpdateFuture, err error) {
  1310  	if tracing.IsEnabled() {
  1311  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.Update")
  1312  		defer func() {
  1313  			sc := -1
  1314  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1315  				sc = result.FutureAPI.Response().StatusCode
  1316  			}
  1317  			tracing.EndSpan(ctx, sc, err)
  1318  		}()
  1319  	}
  1320  	req, err := client.UpdatePreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput)
  1321  	if err != nil {
  1322  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Update", nil, "Failure preparing request")
  1323  		return
  1324  	}
  1325  
  1326  	result, err = client.UpdateSender(req)
  1327  	if err != nil {
  1328  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "Update", result.Response(), "Failure sending request")
  1329  		return
  1330  	}
  1331  
  1332  	return
  1333  }
  1334  
  1335  // UpdatePreparer prepares the Update request.
  1336  func (client ReplicationProtectedItemsClient) UpdatePreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string, updateProtectionInput UpdateReplicationProtectedItemInput) (*http.Request, error) {
  1337  	pathParameters := map[string]interface{}{
  1338  		"fabricName":                  autorest.Encode("path", fabricName),
  1339  		"protectionContainerName":     autorest.Encode("path", protectionContainerName),
  1340  		"replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
  1341  		"resourceGroupName":           autorest.Encode("path", client.ResourceGroupName),
  1342  		"resourceName":                autorest.Encode("path", client.ResourceName),
  1343  		"subscriptionId":              autorest.Encode("path", client.SubscriptionID),
  1344  	}
  1345  
  1346  	const APIVersion = "2018-01-10"
  1347  	queryParameters := map[string]interface{}{
  1348  		"api-version": APIVersion,
  1349  	}
  1350  
  1351  	preparer := autorest.CreatePreparer(
  1352  		autorest.AsContentType("application/json; charset=utf-8"),
  1353  		autorest.AsPatch(),
  1354  		autorest.WithBaseURL(client.BaseURI),
  1355  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters),
  1356  		autorest.WithJSON(updateProtectionInput),
  1357  		autorest.WithQueryParameters(queryParameters))
  1358  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1359  }
  1360  
  1361  // UpdateSender sends the Update request. The method will close the
  1362  // http.Response Body if it receives an error.
  1363  func (client ReplicationProtectedItemsClient) UpdateSender(req *http.Request) (future ReplicationProtectedItemsUpdateFuture, err error) {
  1364  	var resp *http.Response
  1365  	future.FutureAPI = &azure.Future{}
  1366  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1367  	if err != nil {
  1368  		return
  1369  	}
  1370  	var azf azure.Future
  1371  	azf, err = azure.NewFutureFromResponse(resp)
  1372  	future.FutureAPI = &azf
  1373  	future.Result = future.result
  1374  	return
  1375  }
  1376  
  1377  // UpdateResponder handles the response to the Update request. The method always
  1378  // closes the http.Response Body.
  1379  func (client ReplicationProtectedItemsClient) UpdateResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
  1380  	err = autorest.Respond(
  1381  		resp,
  1382  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1383  		autorest.ByUnmarshallingJSON(&result),
  1384  		autorest.ByClosing())
  1385  	result.Response = autorest.Response{Response: resp}
  1386  	return
  1387  }
  1388  
  1389  // UpdateMobilityService the operation to update(push update) the installed mobility service software on a replication
  1390  // protected item to the latest available version.
  1391  // Parameters:
  1392  // fabricName - the name of the fabric containing the protected item.
  1393  // protectionContainerName - the name of the container containing the protected item.
  1394  // replicationProtectedItemName - the name of the protected item on which the agent is to be updated.
  1395  // updateMobilityServiceRequest - request to update the mobility service on the protected item.
  1396  func (client ReplicationProtectedItemsClient) UpdateMobilityService(ctx context.Context, fabricName string, protectionContainerName string, replicationProtectedItemName string, updateMobilityServiceRequest UpdateMobilityServiceRequest) (result ReplicationProtectedItemsUpdateMobilityServiceFuture, err error) {
  1397  	if tracing.IsEnabled() {
  1398  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationProtectedItemsClient.UpdateMobilityService")
  1399  		defer func() {
  1400  			sc := -1
  1401  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1402  				sc = result.FutureAPI.Response().StatusCode
  1403  			}
  1404  			tracing.EndSpan(ctx, sc, err)
  1405  		}()
  1406  	}
  1407  	req, err := client.UpdateMobilityServicePreparer(ctx, fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest)
  1408  	if err != nil {
  1409  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "UpdateMobilityService", nil, "Failure preparing request")
  1410  		return
  1411  	}
  1412  
  1413  	result, err = client.UpdateMobilityServiceSender(req)
  1414  	if err != nil {
  1415  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationProtectedItemsClient", "UpdateMobilityService", result.Response(), "Failure sending request")
  1416  		return
  1417  	}
  1418  
  1419  	return
  1420  }
  1421  
  1422  // UpdateMobilityServicePreparer prepares the UpdateMobilityService request.
  1423  func (client ReplicationProtectedItemsClient) UpdateMobilityServicePreparer(ctx context.Context, fabricName string, protectionContainerName string, replicationProtectedItemName string, updateMobilityServiceRequest UpdateMobilityServiceRequest) (*http.Request, error) {
  1424  	pathParameters := map[string]interface{}{
  1425  		"fabricName":                   autorest.Encode("path", fabricName),
  1426  		"protectionContainerName":      autorest.Encode("path", protectionContainerName),
  1427  		"replicationProtectedItemName": autorest.Encode("path", replicationProtectedItemName),
  1428  		"resourceGroupName":            autorest.Encode("path", client.ResourceGroupName),
  1429  		"resourceName":                 autorest.Encode("path", client.ResourceName),
  1430  		"subscriptionId":               autorest.Encode("path", client.SubscriptionID),
  1431  	}
  1432  
  1433  	const APIVersion = "2018-01-10"
  1434  	queryParameters := map[string]interface{}{
  1435  		"api-version": APIVersion,
  1436  	}
  1437  
  1438  	preparer := autorest.CreatePreparer(
  1439  		autorest.AsContentType("application/json; charset=utf-8"),
  1440  		autorest.AsPost(),
  1441  		autorest.WithBaseURL(client.BaseURI),
  1442  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicationProtectedItemName}/updateMobilityService", pathParameters),
  1443  		autorest.WithJSON(updateMobilityServiceRequest),
  1444  		autorest.WithQueryParameters(queryParameters))
  1445  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1446  }
  1447  
  1448  // UpdateMobilityServiceSender sends the UpdateMobilityService request. The method will close the
  1449  // http.Response Body if it receives an error.
  1450  func (client ReplicationProtectedItemsClient) UpdateMobilityServiceSender(req *http.Request) (future ReplicationProtectedItemsUpdateMobilityServiceFuture, err error) {
  1451  	var resp *http.Response
  1452  	future.FutureAPI = &azure.Future{}
  1453  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1454  	if err != nil {
  1455  		return
  1456  	}
  1457  	var azf azure.Future
  1458  	azf, err = azure.NewFutureFromResponse(resp)
  1459  	future.FutureAPI = &azf
  1460  	future.Result = future.result
  1461  	return
  1462  }
  1463  
  1464  // UpdateMobilityServiceResponder handles the response to the UpdateMobilityService request. The method always
  1465  // closes the http.Response Body.
  1466  func (client ReplicationProtectedItemsClient) UpdateMobilityServiceResponder(resp *http.Response) (result ReplicationProtectedItem, err error) {
  1467  	err = autorest.Respond(
  1468  		resp,
  1469  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1470  		autorest.ByUnmarshallingJSON(&result),
  1471  		autorest.ByClosing())
  1472  	result.Response = autorest.Response{Response: resp}
  1473  	return
  1474  }
  1475  

View as plain text