...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery/replicationmigrationitems.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  // ReplicationMigrationItemsClient is the client for the ReplicationMigrationItems methods of the Siterecovery service.
    19  type ReplicationMigrationItemsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewReplicationMigrationItemsClient creates an instance of the ReplicationMigrationItemsClient client.
    24  func NewReplicationMigrationItemsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationMigrationItemsClient {
    25  	return NewReplicationMigrationItemsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    26  }
    27  
    28  // NewReplicationMigrationItemsClientWithBaseURI creates an instance of the ReplicationMigrationItemsClient 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 NewReplicationMigrationItemsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationMigrationItemsClient {
    32  	return ReplicationMigrationItemsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    33  }
    34  
    35  // Create the operation to create an ASR migration item (enable migration).
    36  // Parameters:
    37  // fabricName - fabric name.
    38  // protectionContainerName - protection container name.
    39  // migrationItemName - migration item name.
    40  // input - enable migration input.
    41  func (client ReplicationMigrationItemsClient) Create(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, input EnableMigrationInput) (result ReplicationMigrationItemsCreateFuture, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.Create")
    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  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: input,
    54  			Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true,
    55  				Chain: []validation.Constraint{{Target: "input.Properties.PolicyID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
    56  		return result, validation.NewError("siterecovery.ReplicationMigrationItemsClient", "Create", err.Error())
    57  	}
    58  
    59  	req, err := client.CreatePreparer(ctx, fabricName, protectionContainerName, migrationItemName, input)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Create", nil, "Failure preparing request")
    62  		return
    63  	}
    64  
    65  	result, err = client.CreateSender(req)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Create", result.Response(), "Failure sending request")
    68  		return
    69  	}
    70  
    71  	return
    72  }
    73  
    74  // CreatePreparer prepares the Create request.
    75  func (client ReplicationMigrationItemsClient) CreatePreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, input EnableMigrationInput) (*http.Request, error) {
    76  	pathParameters := map[string]interface{}{
    77  		"fabricName":              autorest.Encode("path", fabricName),
    78  		"migrationItemName":       autorest.Encode("path", migrationItemName),
    79  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
    80  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
    81  		"resourceName":            autorest.Encode("path", client.ResourceName),
    82  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
    83  	}
    84  
    85  	const APIVersion = "2018-01-10"
    86  	queryParameters := map[string]interface{}{
    87  		"api-version": APIVersion,
    88  	}
    89  
    90  	preparer := autorest.CreatePreparer(
    91  		autorest.AsContentType("application/json; charset=utf-8"),
    92  		autorest.AsPut(),
    93  		autorest.WithBaseURL(client.BaseURI),
    94  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}", pathParameters),
    95  		autorest.WithJSON(input),
    96  		autorest.WithQueryParameters(queryParameters))
    97  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    98  }
    99  
   100  // CreateSender sends the Create request. The method will close the
   101  // http.Response Body if it receives an error.
   102  func (client ReplicationMigrationItemsClient) CreateSender(req *http.Request) (future ReplicationMigrationItemsCreateFuture, err error) {
   103  	var resp *http.Response
   104  	future.FutureAPI = &azure.Future{}
   105  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   106  	if err != nil {
   107  		return
   108  	}
   109  	var azf azure.Future
   110  	azf, err = azure.NewFutureFromResponse(resp)
   111  	future.FutureAPI = &azf
   112  	future.Result = future.result
   113  	return
   114  }
   115  
   116  // CreateResponder handles the response to the Create request. The method always
   117  // closes the http.Response Body.
   118  func (client ReplicationMigrationItemsClient) CreateResponder(resp *http.Response) (result MigrationItem, err error) {
   119  	err = autorest.Respond(
   120  		resp,
   121  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   122  		autorest.ByUnmarshallingJSON(&result),
   123  		autorest.ByClosing())
   124  	result.Response = autorest.Response{Response: resp}
   125  	return
   126  }
   127  
   128  // Delete the operation to delete an ASR migration item.
   129  // Parameters:
   130  // fabricName - fabric name.
   131  // protectionContainerName - protection container name.
   132  // migrationItemName - migration item name.
   133  // deleteOption - the delete option.
   134  func (client ReplicationMigrationItemsClient) Delete(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, deleteOption string) (result ReplicationMigrationItemsDeleteFuture, err error) {
   135  	if tracing.IsEnabled() {
   136  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.Delete")
   137  		defer func() {
   138  			sc := -1
   139  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   140  				sc = result.FutureAPI.Response().StatusCode
   141  			}
   142  			tracing.EndSpan(ctx, sc, err)
   143  		}()
   144  	}
   145  	req, err := client.DeletePreparer(ctx, fabricName, protectionContainerName, migrationItemName, deleteOption)
   146  	if err != nil {
   147  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Delete", nil, "Failure preparing request")
   148  		return
   149  	}
   150  
   151  	result, err = client.DeleteSender(req)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Delete", result.Response(), "Failure sending request")
   154  		return
   155  	}
   156  
   157  	return
   158  }
   159  
   160  // DeletePreparer prepares the Delete request.
   161  func (client ReplicationMigrationItemsClient) DeletePreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, deleteOption string) (*http.Request, error) {
   162  	pathParameters := map[string]interface{}{
   163  		"fabricName":              autorest.Encode("path", fabricName),
   164  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   165  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   166  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   167  		"resourceName":            autorest.Encode("path", client.ResourceName),
   168  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   169  	}
   170  
   171  	const APIVersion = "2018-01-10"
   172  	queryParameters := map[string]interface{}{
   173  		"api-version": APIVersion,
   174  	}
   175  	if len(deleteOption) > 0 {
   176  		queryParameters["deleteOption"] = autorest.Encode("query", deleteOption)
   177  	}
   178  
   179  	preparer := autorest.CreatePreparer(
   180  		autorest.AsDelete(),
   181  		autorest.WithBaseURL(client.BaseURI),
   182  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}", pathParameters),
   183  		autorest.WithQueryParameters(queryParameters))
   184  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   185  }
   186  
   187  // DeleteSender sends the Delete request. The method will close the
   188  // http.Response Body if it receives an error.
   189  func (client ReplicationMigrationItemsClient) DeleteSender(req *http.Request) (future ReplicationMigrationItemsDeleteFuture, err error) {
   190  	var resp *http.Response
   191  	future.FutureAPI = &azure.Future{}
   192  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   193  	if err != nil {
   194  		return
   195  	}
   196  	var azf azure.Future
   197  	azf, err = azure.NewFutureFromResponse(resp)
   198  	future.FutureAPI = &azf
   199  	future.Result = future.result
   200  	return
   201  }
   202  
   203  // DeleteResponder handles the response to the Delete request. The method always
   204  // closes the http.Response Body.
   205  func (client ReplicationMigrationItemsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   206  	err = autorest.Respond(
   207  		resp,
   208  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   209  		autorest.ByClosing())
   210  	result.Response = resp
   211  	return
   212  }
   213  
   214  // Get sends the get request.
   215  // Parameters:
   216  // fabricName - fabric unique name.
   217  // protectionContainerName - protection container name.
   218  // migrationItemName - migration item name.
   219  func (client ReplicationMigrationItemsClient) Get(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string) (result MigrationItem, err error) {
   220  	if tracing.IsEnabled() {
   221  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.Get")
   222  		defer func() {
   223  			sc := -1
   224  			if result.Response.Response != nil {
   225  				sc = result.Response.Response.StatusCode
   226  			}
   227  			tracing.EndSpan(ctx, sc, err)
   228  		}()
   229  	}
   230  	req, err := client.GetPreparer(ctx, fabricName, protectionContainerName, migrationItemName)
   231  	if err != nil {
   232  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Get", nil, "Failure preparing request")
   233  		return
   234  	}
   235  
   236  	resp, err := client.GetSender(req)
   237  	if err != nil {
   238  		result.Response = autorest.Response{Response: resp}
   239  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Get", resp, "Failure sending request")
   240  		return
   241  	}
   242  
   243  	result, err = client.GetResponder(resp)
   244  	if err != nil {
   245  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Get", resp, "Failure responding to request")
   246  		return
   247  	}
   248  
   249  	return
   250  }
   251  
   252  // GetPreparer prepares the Get request.
   253  func (client ReplicationMigrationItemsClient) GetPreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string) (*http.Request, error) {
   254  	pathParameters := map[string]interface{}{
   255  		"fabricName":              autorest.Encode("path", fabricName),
   256  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   257  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   258  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   259  		"resourceName":            autorest.Encode("path", client.ResourceName),
   260  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   261  	}
   262  
   263  	const APIVersion = "2018-01-10"
   264  	queryParameters := map[string]interface{}{
   265  		"api-version": APIVersion,
   266  	}
   267  
   268  	preparer := autorest.CreatePreparer(
   269  		autorest.AsGet(),
   270  		autorest.WithBaseURL(client.BaseURI),
   271  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}", pathParameters),
   272  		autorest.WithQueryParameters(queryParameters))
   273  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   274  }
   275  
   276  // GetSender sends the Get request. The method will close the
   277  // http.Response Body if it receives an error.
   278  func (client ReplicationMigrationItemsClient) GetSender(req *http.Request) (*http.Response, error) {
   279  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   280  }
   281  
   282  // GetResponder handles the response to the Get request. The method always
   283  // closes the http.Response Body.
   284  func (client ReplicationMigrationItemsClient) GetResponder(resp *http.Response) (result MigrationItem, err error) {
   285  	err = autorest.Respond(
   286  		resp,
   287  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   288  		autorest.ByUnmarshallingJSON(&result),
   289  		autorest.ByClosing())
   290  	result.Response = autorest.Response{Response: resp}
   291  	return
   292  }
   293  
   294  // List sends the list request.
   295  // Parameters:
   296  // skipToken - the pagination token.
   297  // filter - oData filter options.
   298  func (client ReplicationMigrationItemsClient) List(ctx context.Context, skipToken string, filter string) (result MigrationItemCollectionPage, err error) {
   299  	if tracing.IsEnabled() {
   300  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.List")
   301  		defer func() {
   302  			sc := -1
   303  			if result.mic.Response.Response != nil {
   304  				sc = result.mic.Response.Response.StatusCode
   305  			}
   306  			tracing.EndSpan(ctx, sc, err)
   307  		}()
   308  	}
   309  	result.fn = client.listNextResults
   310  	req, err := client.ListPreparer(ctx, skipToken, filter)
   311  	if err != nil {
   312  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "List", nil, "Failure preparing request")
   313  		return
   314  	}
   315  
   316  	resp, err := client.ListSender(req)
   317  	if err != nil {
   318  		result.mic.Response = autorest.Response{Response: resp}
   319  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "List", resp, "Failure sending request")
   320  		return
   321  	}
   322  
   323  	result.mic, err = client.ListResponder(resp)
   324  	if err != nil {
   325  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "List", resp, "Failure responding to request")
   326  		return
   327  	}
   328  	if result.mic.hasNextLink() && result.mic.IsEmpty() {
   329  		err = result.NextWithContext(ctx)
   330  		return
   331  	}
   332  
   333  	return
   334  }
   335  
   336  // ListPreparer prepares the List request.
   337  func (client ReplicationMigrationItemsClient) ListPreparer(ctx context.Context, skipToken string, filter string) (*http.Request, error) {
   338  	pathParameters := map[string]interface{}{
   339  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   340  		"resourceName":      autorest.Encode("path", client.ResourceName),
   341  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   342  	}
   343  
   344  	const APIVersion = "2018-01-10"
   345  	queryParameters := map[string]interface{}{
   346  		"api-version": APIVersion,
   347  	}
   348  	if len(skipToken) > 0 {
   349  		queryParameters["skipToken"] = autorest.Encode("query", skipToken)
   350  	}
   351  	if len(filter) > 0 {
   352  		queryParameters["$filter"] = autorest.Encode("query", filter)
   353  	}
   354  
   355  	preparer := autorest.CreatePreparer(
   356  		autorest.AsGet(),
   357  		autorest.WithBaseURL(client.BaseURI),
   358  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationMigrationItems", pathParameters),
   359  		autorest.WithQueryParameters(queryParameters))
   360  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   361  }
   362  
   363  // ListSender sends the List request. The method will close the
   364  // http.Response Body if it receives an error.
   365  func (client ReplicationMigrationItemsClient) ListSender(req *http.Request) (*http.Response, error) {
   366  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   367  }
   368  
   369  // ListResponder handles the response to the List request. The method always
   370  // closes the http.Response Body.
   371  func (client ReplicationMigrationItemsClient) ListResponder(resp *http.Response) (result MigrationItemCollection, err error) {
   372  	err = autorest.Respond(
   373  		resp,
   374  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   375  		autorest.ByUnmarshallingJSON(&result),
   376  		autorest.ByClosing())
   377  	result.Response = autorest.Response{Response: resp}
   378  	return
   379  }
   380  
   381  // listNextResults retrieves the next set of results, if any.
   382  func (client ReplicationMigrationItemsClient) listNextResults(ctx context.Context, lastResults MigrationItemCollection) (result MigrationItemCollection, err error) {
   383  	req, err := lastResults.migrationItemCollectionPreparer(ctx)
   384  	if err != nil {
   385  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "listNextResults", nil, "Failure preparing next results request")
   386  	}
   387  	if req == nil {
   388  		return
   389  	}
   390  	resp, err := client.ListSender(req)
   391  	if err != nil {
   392  		result.Response = autorest.Response{Response: resp}
   393  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "listNextResults", resp, "Failure sending next results request")
   394  	}
   395  	result, err = client.ListResponder(resp)
   396  	if err != nil {
   397  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "listNextResults", resp, "Failure responding to next results request")
   398  	}
   399  	return
   400  }
   401  
   402  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   403  func (client ReplicationMigrationItemsClient) ListComplete(ctx context.Context, skipToken string, filter string) (result MigrationItemCollectionIterator, err error) {
   404  	if tracing.IsEnabled() {
   405  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.List")
   406  		defer func() {
   407  			sc := -1
   408  			if result.Response().Response.Response != nil {
   409  				sc = result.page.Response().Response.Response.StatusCode
   410  			}
   411  			tracing.EndSpan(ctx, sc, err)
   412  		}()
   413  	}
   414  	result.page, err = client.List(ctx, skipToken, filter)
   415  	return
   416  }
   417  
   418  // ListByReplicationProtectionContainers gets the list of ASR migration items in the protection container.
   419  // Parameters:
   420  // fabricName - fabric name.
   421  // protectionContainerName - protection container name.
   422  func (client ReplicationMigrationItemsClient) ListByReplicationProtectionContainers(ctx context.Context, fabricName string, protectionContainerName string) (result MigrationItemCollectionPage, err error) {
   423  	if tracing.IsEnabled() {
   424  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.ListByReplicationProtectionContainers")
   425  		defer func() {
   426  			sc := -1
   427  			if result.mic.Response.Response != nil {
   428  				sc = result.mic.Response.Response.StatusCode
   429  			}
   430  			tracing.EndSpan(ctx, sc, err)
   431  		}()
   432  	}
   433  	result.fn = client.listByReplicationProtectionContainersNextResults
   434  	req, err := client.ListByReplicationProtectionContainersPreparer(ctx, fabricName, protectionContainerName)
   435  	if err != nil {
   436  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing request")
   437  		return
   438  	}
   439  
   440  	resp, err := client.ListByReplicationProtectionContainersSender(req)
   441  	if err != nil {
   442  		result.mic.Response = autorest.Response{Response: resp}
   443  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "ListByReplicationProtectionContainers", resp, "Failure sending request")
   444  		return
   445  	}
   446  
   447  	result.mic, err = client.ListByReplicationProtectionContainersResponder(resp)
   448  	if err != nil {
   449  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to request")
   450  		return
   451  	}
   452  	if result.mic.hasNextLink() && result.mic.IsEmpty() {
   453  		err = result.NextWithContext(ctx)
   454  		return
   455  	}
   456  
   457  	return
   458  }
   459  
   460  // ListByReplicationProtectionContainersPreparer prepares the ListByReplicationProtectionContainers request.
   461  func (client ReplicationMigrationItemsClient) ListByReplicationProtectionContainersPreparer(ctx context.Context, fabricName string, protectionContainerName string) (*http.Request, error) {
   462  	pathParameters := map[string]interface{}{
   463  		"fabricName":              autorest.Encode("path", fabricName),
   464  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   465  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   466  		"resourceName":            autorest.Encode("path", client.ResourceName),
   467  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   468  	}
   469  
   470  	const APIVersion = "2018-01-10"
   471  	queryParameters := map[string]interface{}{
   472  		"api-version": APIVersion,
   473  	}
   474  
   475  	preparer := autorest.CreatePreparer(
   476  		autorest.AsGet(),
   477  		autorest.WithBaseURL(client.BaseURI),
   478  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems", pathParameters),
   479  		autorest.WithQueryParameters(queryParameters))
   480  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   481  }
   482  
   483  // ListByReplicationProtectionContainersSender sends the ListByReplicationProtectionContainers request. The method will close the
   484  // http.Response Body if it receives an error.
   485  func (client ReplicationMigrationItemsClient) ListByReplicationProtectionContainersSender(req *http.Request) (*http.Response, error) {
   486  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   487  }
   488  
   489  // ListByReplicationProtectionContainersResponder handles the response to the ListByReplicationProtectionContainers request. The method always
   490  // closes the http.Response Body.
   491  func (client ReplicationMigrationItemsClient) ListByReplicationProtectionContainersResponder(resp *http.Response) (result MigrationItemCollection, err error) {
   492  	err = autorest.Respond(
   493  		resp,
   494  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   495  		autorest.ByUnmarshallingJSON(&result),
   496  		autorest.ByClosing())
   497  	result.Response = autorest.Response{Response: resp}
   498  	return
   499  }
   500  
   501  // listByReplicationProtectionContainersNextResults retrieves the next set of results, if any.
   502  func (client ReplicationMigrationItemsClient) listByReplicationProtectionContainersNextResults(ctx context.Context, lastResults MigrationItemCollection) (result MigrationItemCollection, err error) {
   503  	req, err := lastResults.migrationItemCollectionPreparer(ctx)
   504  	if err != nil {
   505  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "listByReplicationProtectionContainersNextResults", nil, "Failure preparing next results request")
   506  	}
   507  	if req == nil {
   508  		return
   509  	}
   510  	resp, err := client.ListByReplicationProtectionContainersSender(req)
   511  	if err != nil {
   512  		result.Response = autorest.Response{Response: resp}
   513  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "listByReplicationProtectionContainersNextResults", resp, "Failure sending next results request")
   514  	}
   515  	result, err = client.ListByReplicationProtectionContainersResponder(resp)
   516  	if err != nil {
   517  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "listByReplicationProtectionContainersNextResults", resp, "Failure responding to next results request")
   518  	}
   519  	return
   520  }
   521  
   522  // ListByReplicationProtectionContainersComplete enumerates all values, automatically crossing page boundaries as required.
   523  func (client ReplicationMigrationItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, fabricName string, protectionContainerName string) (result MigrationItemCollectionIterator, err error) {
   524  	if tracing.IsEnabled() {
   525  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.ListByReplicationProtectionContainers")
   526  		defer func() {
   527  			sc := -1
   528  			if result.Response().Response.Response != nil {
   529  				sc = result.page.Response().Response.Response.StatusCode
   530  			}
   531  			tracing.EndSpan(ctx, sc, err)
   532  		}()
   533  	}
   534  	result.page, err = client.ListByReplicationProtectionContainers(ctx, fabricName, protectionContainerName)
   535  	return
   536  }
   537  
   538  // Migrate the operation to initiate migration of the item.
   539  // Parameters:
   540  // fabricName - fabric name.
   541  // protectionContainerName - protection container name.
   542  // migrationItemName - migration item name.
   543  // migrateInput - migrate input.
   544  func (client ReplicationMigrationItemsClient) Migrate(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, migrateInput MigrateInput) (result ReplicationMigrationItemsMigrateFuture, err error) {
   545  	if tracing.IsEnabled() {
   546  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.Migrate")
   547  		defer func() {
   548  			sc := -1
   549  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   550  				sc = result.FutureAPI.Response().StatusCode
   551  			}
   552  			tracing.EndSpan(ctx, sc, err)
   553  		}()
   554  	}
   555  	if err := validation.Validate([]validation.Validation{
   556  		{TargetValue: migrateInput,
   557  			Constraints: []validation.Constraint{{Target: "migrateInput.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   558  		return result, validation.NewError("siterecovery.ReplicationMigrationItemsClient", "Migrate", err.Error())
   559  	}
   560  
   561  	req, err := client.MigratePreparer(ctx, fabricName, protectionContainerName, migrationItemName, migrateInput)
   562  	if err != nil {
   563  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Migrate", nil, "Failure preparing request")
   564  		return
   565  	}
   566  
   567  	result, err = client.MigrateSender(req)
   568  	if err != nil {
   569  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Migrate", result.Response(), "Failure sending request")
   570  		return
   571  	}
   572  
   573  	return
   574  }
   575  
   576  // MigratePreparer prepares the Migrate request.
   577  func (client ReplicationMigrationItemsClient) MigratePreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, migrateInput MigrateInput) (*http.Request, error) {
   578  	pathParameters := map[string]interface{}{
   579  		"fabricName":              autorest.Encode("path", fabricName),
   580  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   581  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   582  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   583  		"resourceName":            autorest.Encode("path", client.ResourceName),
   584  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   585  	}
   586  
   587  	const APIVersion = "2018-01-10"
   588  	queryParameters := map[string]interface{}{
   589  		"api-version": APIVersion,
   590  	}
   591  
   592  	preparer := autorest.CreatePreparer(
   593  		autorest.AsContentType("application/json; charset=utf-8"),
   594  		autorest.AsPost(),
   595  		autorest.WithBaseURL(client.BaseURI),
   596  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}/migrate", pathParameters),
   597  		autorest.WithJSON(migrateInput),
   598  		autorest.WithQueryParameters(queryParameters))
   599  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   600  }
   601  
   602  // MigrateSender sends the Migrate request. The method will close the
   603  // http.Response Body if it receives an error.
   604  func (client ReplicationMigrationItemsClient) MigrateSender(req *http.Request) (future ReplicationMigrationItemsMigrateFuture, err error) {
   605  	var resp *http.Response
   606  	future.FutureAPI = &azure.Future{}
   607  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   608  	if err != nil {
   609  		return
   610  	}
   611  	var azf azure.Future
   612  	azf, err = azure.NewFutureFromResponse(resp)
   613  	future.FutureAPI = &azf
   614  	future.Result = future.result
   615  	return
   616  }
   617  
   618  // MigrateResponder handles the response to the Migrate request. The method always
   619  // closes the http.Response Body.
   620  func (client ReplicationMigrationItemsClient) MigrateResponder(resp *http.Response) (result MigrationItem, err error) {
   621  	err = autorest.Respond(
   622  		resp,
   623  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   624  		autorest.ByUnmarshallingJSON(&result),
   625  		autorest.ByClosing())
   626  	result.Response = autorest.Response{Response: resp}
   627  	return
   628  }
   629  
   630  // Resync the operation to resynchronize replication of an ASR migration item.
   631  // Parameters:
   632  // fabricName - fabric name.
   633  // protectionContainerName - protection container name.
   634  // migrationItemName - migration item name.
   635  // input - resync input.
   636  func (client ReplicationMigrationItemsClient) Resync(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, input ResyncInput) (result ReplicationMigrationItemsResyncFuture, err error) {
   637  	if tracing.IsEnabled() {
   638  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.Resync")
   639  		defer func() {
   640  			sc := -1
   641  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   642  				sc = result.FutureAPI.Response().StatusCode
   643  			}
   644  			tracing.EndSpan(ctx, sc, err)
   645  		}()
   646  	}
   647  	if err := validation.Validate([]validation.Validation{
   648  		{TargetValue: input,
   649  			Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   650  		return result, validation.NewError("siterecovery.ReplicationMigrationItemsClient", "Resync", err.Error())
   651  	}
   652  
   653  	req, err := client.ResyncPreparer(ctx, fabricName, protectionContainerName, migrationItemName, input)
   654  	if err != nil {
   655  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Resync", nil, "Failure preparing request")
   656  		return
   657  	}
   658  
   659  	result, err = client.ResyncSender(req)
   660  	if err != nil {
   661  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Resync", result.Response(), "Failure sending request")
   662  		return
   663  	}
   664  
   665  	return
   666  }
   667  
   668  // ResyncPreparer prepares the Resync request.
   669  func (client ReplicationMigrationItemsClient) ResyncPreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, input ResyncInput) (*http.Request, error) {
   670  	pathParameters := map[string]interface{}{
   671  		"fabricName":              autorest.Encode("path", fabricName),
   672  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   673  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   674  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   675  		"resourceName":            autorest.Encode("path", client.ResourceName),
   676  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   677  	}
   678  
   679  	const APIVersion = "2018-01-10"
   680  	queryParameters := map[string]interface{}{
   681  		"api-version": APIVersion,
   682  	}
   683  
   684  	preparer := autorest.CreatePreparer(
   685  		autorest.AsContentType("application/json; charset=utf-8"),
   686  		autorest.AsPost(),
   687  		autorest.WithBaseURL(client.BaseURI),
   688  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}/resync", pathParameters),
   689  		autorest.WithJSON(input),
   690  		autorest.WithQueryParameters(queryParameters))
   691  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   692  }
   693  
   694  // ResyncSender sends the Resync request. The method will close the
   695  // http.Response Body if it receives an error.
   696  func (client ReplicationMigrationItemsClient) ResyncSender(req *http.Request) (future ReplicationMigrationItemsResyncFuture, err error) {
   697  	var resp *http.Response
   698  	future.FutureAPI = &azure.Future{}
   699  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   700  	if err != nil {
   701  		return
   702  	}
   703  	var azf azure.Future
   704  	azf, err = azure.NewFutureFromResponse(resp)
   705  	future.FutureAPI = &azf
   706  	future.Result = future.result
   707  	return
   708  }
   709  
   710  // ResyncResponder handles the response to the Resync request. The method always
   711  // closes the http.Response Body.
   712  func (client ReplicationMigrationItemsClient) ResyncResponder(resp *http.Response) (result MigrationItem, err error) {
   713  	err = autorest.Respond(
   714  		resp,
   715  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   716  		autorest.ByUnmarshallingJSON(&result),
   717  		autorest.ByClosing())
   718  	result.Response = autorest.Response{Response: resp}
   719  	return
   720  }
   721  
   722  // TestMigrate the operation to initiate test migration of the item.
   723  // Parameters:
   724  // fabricName - fabric name.
   725  // protectionContainerName - protection container name.
   726  // migrationItemName - migration item name.
   727  // testMigrateInput - test migrate input.
   728  func (client ReplicationMigrationItemsClient) TestMigrate(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, testMigrateInput TestMigrateInput) (result ReplicationMigrationItemsTestMigrateFuture, err error) {
   729  	if tracing.IsEnabled() {
   730  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.TestMigrate")
   731  		defer func() {
   732  			sc := -1
   733  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   734  				sc = result.FutureAPI.Response().StatusCode
   735  			}
   736  			tracing.EndSpan(ctx, sc, err)
   737  		}()
   738  	}
   739  	if err := validation.Validate([]validation.Validation{
   740  		{TargetValue: testMigrateInput,
   741  			Constraints: []validation.Constraint{{Target: "testMigrateInput.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   742  		return result, validation.NewError("siterecovery.ReplicationMigrationItemsClient", "TestMigrate", err.Error())
   743  	}
   744  
   745  	req, err := client.TestMigratePreparer(ctx, fabricName, protectionContainerName, migrationItemName, testMigrateInput)
   746  	if err != nil {
   747  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "TestMigrate", nil, "Failure preparing request")
   748  		return
   749  	}
   750  
   751  	result, err = client.TestMigrateSender(req)
   752  	if err != nil {
   753  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "TestMigrate", result.Response(), "Failure sending request")
   754  		return
   755  	}
   756  
   757  	return
   758  }
   759  
   760  // TestMigratePreparer prepares the TestMigrate request.
   761  func (client ReplicationMigrationItemsClient) TestMigratePreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, testMigrateInput TestMigrateInput) (*http.Request, error) {
   762  	pathParameters := map[string]interface{}{
   763  		"fabricName":              autorest.Encode("path", fabricName),
   764  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   765  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   766  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   767  		"resourceName":            autorest.Encode("path", client.ResourceName),
   768  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   769  	}
   770  
   771  	const APIVersion = "2018-01-10"
   772  	queryParameters := map[string]interface{}{
   773  		"api-version": APIVersion,
   774  	}
   775  
   776  	preparer := autorest.CreatePreparer(
   777  		autorest.AsContentType("application/json; charset=utf-8"),
   778  		autorest.AsPost(),
   779  		autorest.WithBaseURL(client.BaseURI),
   780  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}/testMigrate", pathParameters),
   781  		autorest.WithJSON(testMigrateInput),
   782  		autorest.WithQueryParameters(queryParameters))
   783  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   784  }
   785  
   786  // TestMigrateSender sends the TestMigrate request. The method will close the
   787  // http.Response Body if it receives an error.
   788  func (client ReplicationMigrationItemsClient) TestMigrateSender(req *http.Request) (future ReplicationMigrationItemsTestMigrateFuture, err error) {
   789  	var resp *http.Response
   790  	future.FutureAPI = &azure.Future{}
   791  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   792  	if err != nil {
   793  		return
   794  	}
   795  	var azf azure.Future
   796  	azf, err = azure.NewFutureFromResponse(resp)
   797  	future.FutureAPI = &azf
   798  	future.Result = future.result
   799  	return
   800  }
   801  
   802  // TestMigrateResponder handles the response to the TestMigrate request. The method always
   803  // closes the http.Response Body.
   804  func (client ReplicationMigrationItemsClient) TestMigrateResponder(resp *http.Response) (result MigrationItem, err error) {
   805  	err = autorest.Respond(
   806  		resp,
   807  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   808  		autorest.ByUnmarshallingJSON(&result),
   809  		autorest.ByClosing())
   810  	result.Response = autorest.Response{Response: resp}
   811  	return
   812  }
   813  
   814  // TestMigrateCleanup the operation to initiate test migrate cleanup.
   815  // Parameters:
   816  // fabricName - fabric name.
   817  // protectionContainerName - protection container name.
   818  // migrationItemName - migration item name.
   819  // testMigrateCleanupInput - test migrate cleanup input.
   820  func (client ReplicationMigrationItemsClient) TestMigrateCleanup(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, testMigrateCleanupInput TestMigrateCleanupInput) (result ReplicationMigrationItemsTestMigrateCleanupFuture, err error) {
   821  	if tracing.IsEnabled() {
   822  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.TestMigrateCleanup")
   823  		defer func() {
   824  			sc := -1
   825  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   826  				sc = result.FutureAPI.Response().StatusCode
   827  			}
   828  			tracing.EndSpan(ctx, sc, err)
   829  		}()
   830  	}
   831  	if err := validation.Validate([]validation.Validation{
   832  		{TargetValue: testMigrateCleanupInput,
   833  			Constraints: []validation.Constraint{{Target: "testMigrateCleanupInput.Properties", Name: validation.Null, Rule: true,
   834  				Chain: []validation.Constraint{{Target: "testMigrateCleanupInput.Properties.Comments", Name: validation.Null, Rule: false,
   835  					Chain: []validation.Constraint{{Target: "testMigrateCleanupInput.Properties.Comments", Name: validation.MaxLength, Rule: 1024, Chain: nil}}},
   836  				}}}}}); err != nil {
   837  		return result, validation.NewError("siterecovery.ReplicationMigrationItemsClient", "TestMigrateCleanup", err.Error())
   838  	}
   839  
   840  	req, err := client.TestMigrateCleanupPreparer(ctx, fabricName, protectionContainerName, migrationItemName, testMigrateCleanupInput)
   841  	if err != nil {
   842  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "TestMigrateCleanup", nil, "Failure preparing request")
   843  		return
   844  	}
   845  
   846  	result, err = client.TestMigrateCleanupSender(req)
   847  	if err != nil {
   848  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "TestMigrateCleanup", result.Response(), "Failure sending request")
   849  		return
   850  	}
   851  
   852  	return
   853  }
   854  
   855  // TestMigrateCleanupPreparer prepares the TestMigrateCleanup request.
   856  func (client ReplicationMigrationItemsClient) TestMigrateCleanupPreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, testMigrateCleanupInput TestMigrateCleanupInput) (*http.Request, error) {
   857  	pathParameters := map[string]interface{}{
   858  		"fabricName":              autorest.Encode("path", fabricName),
   859  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   860  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   861  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   862  		"resourceName":            autorest.Encode("path", client.ResourceName),
   863  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   864  	}
   865  
   866  	const APIVersion = "2018-01-10"
   867  	queryParameters := map[string]interface{}{
   868  		"api-version": APIVersion,
   869  	}
   870  
   871  	preparer := autorest.CreatePreparer(
   872  		autorest.AsContentType("application/json; charset=utf-8"),
   873  		autorest.AsPost(),
   874  		autorest.WithBaseURL(client.BaseURI),
   875  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}/testMigrateCleanup", pathParameters),
   876  		autorest.WithJSON(testMigrateCleanupInput),
   877  		autorest.WithQueryParameters(queryParameters))
   878  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   879  }
   880  
   881  // TestMigrateCleanupSender sends the TestMigrateCleanup request. The method will close the
   882  // http.Response Body if it receives an error.
   883  func (client ReplicationMigrationItemsClient) TestMigrateCleanupSender(req *http.Request) (future ReplicationMigrationItemsTestMigrateCleanupFuture, err error) {
   884  	var resp *http.Response
   885  	future.FutureAPI = &azure.Future{}
   886  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   887  	if err != nil {
   888  		return
   889  	}
   890  	var azf azure.Future
   891  	azf, err = azure.NewFutureFromResponse(resp)
   892  	future.FutureAPI = &azf
   893  	future.Result = future.result
   894  	return
   895  }
   896  
   897  // TestMigrateCleanupResponder handles the response to the TestMigrateCleanup request. The method always
   898  // closes the http.Response Body.
   899  func (client ReplicationMigrationItemsClient) TestMigrateCleanupResponder(resp *http.Response) (result MigrationItem, err error) {
   900  	err = autorest.Respond(
   901  		resp,
   902  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   903  		autorest.ByUnmarshallingJSON(&result),
   904  		autorest.ByClosing())
   905  	result.Response = autorest.Response{Response: resp}
   906  	return
   907  }
   908  
   909  // Update the operation to update the recovery settings of an ASR migration item.
   910  // Parameters:
   911  // fabricName - fabric name.
   912  // protectionContainerName - protection container name.
   913  // migrationItemName - migration item name.
   914  // input - update migration item input.
   915  func (client ReplicationMigrationItemsClient) Update(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, input UpdateMigrationItemInput) (result ReplicationMigrationItemsUpdateFuture, err error) {
   916  	if tracing.IsEnabled() {
   917  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationMigrationItemsClient.Update")
   918  		defer func() {
   919  			sc := -1
   920  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   921  				sc = result.FutureAPI.Response().StatusCode
   922  			}
   923  			tracing.EndSpan(ctx, sc, err)
   924  		}()
   925  	}
   926  	req, err := client.UpdatePreparer(ctx, fabricName, protectionContainerName, migrationItemName, input)
   927  	if err != nil {
   928  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Update", nil, "Failure preparing request")
   929  		return
   930  	}
   931  
   932  	result, err = client.UpdateSender(req)
   933  	if err != nil {
   934  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationMigrationItemsClient", "Update", result.Response(), "Failure sending request")
   935  		return
   936  	}
   937  
   938  	return
   939  }
   940  
   941  // UpdatePreparer prepares the Update request.
   942  func (client ReplicationMigrationItemsClient) UpdatePreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, input UpdateMigrationItemInput) (*http.Request, error) {
   943  	pathParameters := map[string]interface{}{
   944  		"fabricName":              autorest.Encode("path", fabricName),
   945  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   946  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   947  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   948  		"resourceName":            autorest.Encode("path", client.ResourceName),
   949  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   950  	}
   951  
   952  	const APIVersion = "2018-01-10"
   953  	queryParameters := map[string]interface{}{
   954  		"api-version": APIVersion,
   955  	}
   956  
   957  	preparer := autorest.CreatePreparer(
   958  		autorest.AsContentType("application/json; charset=utf-8"),
   959  		autorest.AsPatch(),
   960  		autorest.WithBaseURL(client.BaseURI),
   961  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}", pathParameters),
   962  		autorest.WithJSON(input),
   963  		autorest.WithQueryParameters(queryParameters))
   964  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   965  }
   966  
   967  // UpdateSender sends the Update request. The method will close the
   968  // http.Response Body if it receives an error.
   969  func (client ReplicationMigrationItemsClient) UpdateSender(req *http.Request) (future ReplicationMigrationItemsUpdateFuture, err error) {
   970  	var resp *http.Response
   971  	future.FutureAPI = &azure.Future{}
   972  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   973  	if err != nil {
   974  		return
   975  	}
   976  	var azf azure.Future
   977  	azf, err = azure.NewFutureFromResponse(resp)
   978  	future.FutureAPI = &azf
   979  	future.Result = future.result
   980  	return
   981  }
   982  
   983  // UpdateResponder handles the response to the Update request. The method always
   984  // closes the http.Response Body.
   985  func (client ReplicationMigrationItemsClient) UpdateResponder(resp *http.Response) (result MigrationItem, err error) {
   986  	err = autorest.Respond(
   987  		resp,
   988  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   989  		autorest.ByUnmarshallingJSON(&result),
   990  		autorest.ByClosing())
   991  	result.Response = autorest.Response{Response: resp}
   992  	return
   993  }
   994  

View as plain text