...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-08-10/siterecovery/replicationfabrics.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-08-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/tracing"
    14  	"net/http"
    15  )
    16  
    17  // ReplicationFabricsClient is the client for the ReplicationFabrics methods of the Siterecovery service.
    18  type ReplicationFabricsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewReplicationFabricsClient creates an instance of the ReplicationFabricsClient client.
    23  func NewReplicationFabricsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationFabricsClient {
    24  	return NewReplicationFabricsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    25  }
    26  
    27  // NewReplicationFabricsClientWithBaseURI creates an instance of the ReplicationFabricsClient client using a custom
    28  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    29  // stack).
    30  func NewReplicationFabricsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationFabricsClient {
    31  	return ReplicationFabricsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    32  }
    33  
    34  // CheckConsistency the operation to perform a consistency check on the fabric.
    35  // Parameters:
    36  // fabricName - fabric name.
    37  func (client ReplicationFabricsClient) CheckConsistency(ctx context.Context, fabricName string) (result ReplicationFabricsCheckConsistencyFuture, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.CheckConsistency")
    40  		defer func() {
    41  			sc := -1
    42  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    43  				sc = result.FutureAPI.Response().StatusCode
    44  			}
    45  			tracing.EndSpan(ctx, sc, err)
    46  		}()
    47  	}
    48  	req, err := client.CheckConsistencyPreparer(ctx, fabricName)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "CheckConsistency", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	result, err = client.CheckConsistencySender(req)
    55  	if err != nil {
    56  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "CheckConsistency", result.Response(), "Failure sending request")
    57  		return
    58  	}
    59  
    60  	return
    61  }
    62  
    63  // CheckConsistencyPreparer prepares the CheckConsistency request.
    64  func (client ReplicationFabricsClient) CheckConsistencyPreparer(ctx context.Context, fabricName string) (*http.Request, error) {
    65  	pathParameters := map[string]interface{}{
    66  		"fabricName":        autorest.Encode("path", fabricName),
    67  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
    68  		"resourceName":      autorest.Encode("path", client.ResourceName),
    69  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    70  	}
    71  
    72  	const APIVersion = "2016-08-10"
    73  	queryParameters := map[string]interface{}{
    74  		"api-version": APIVersion,
    75  	}
    76  
    77  	preparer := autorest.CreatePreparer(
    78  		autorest.AsPost(),
    79  		autorest.WithBaseURL(client.BaseURI),
    80  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/checkConsistency", pathParameters),
    81  		autorest.WithQueryParameters(queryParameters))
    82  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    83  }
    84  
    85  // CheckConsistencySender sends the CheckConsistency request. The method will close the
    86  // http.Response Body if it receives an error.
    87  func (client ReplicationFabricsClient) CheckConsistencySender(req *http.Request) (future ReplicationFabricsCheckConsistencyFuture, err error) {
    88  	var resp *http.Response
    89  	future.FutureAPI = &azure.Future{}
    90  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    91  	if err != nil {
    92  		return
    93  	}
    94  	var azf azure.Future
    95  	azf, err = azure.NewFutureFromResponse(resp)
    96  	future.FutureAPI = &azf
    97  	future.Result = future.result
    98  	return
    99  }
   100  
   101  // CheckConsistencyResponder handles the response to the CheckConsistency request. The method always
   102  // closes the http.Response Body.
   103  func (client ReplicationFabricsClient) CheckConsistencyResponder(resp *http.Response) (result Fabric, err error) {
   104  	err = autorest.Respond(
   105  		resp,
   106  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   107  		autorest.ByUnmarshallingJSON(&result),
   108  		autorest.ByClosing())
   109  	result.Response = autorest.Response{Response: resp}
   110  	return
   111  }
   112  
   113  // Create the operation to create an Azure Site Recovery fabric (for e.g. Hyper-V site)
   114  // Parameters:
   115  // fabricName - name of the ASR fabric.
   116  // input - fabric creation input.
   117  func (client ReplicationFabricsClient) Create(ctx context.Context, fabricName string, input FabricCreationInput) (result ReplicationFabricsCreateFuture, err error) {
   118  	if tracing.IsEnabled() {
   119  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Create")
   120  		defer func() {
   121  			sc := -1
   122  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   123  				sc = result.FutureAPI.Response().StatusCode
   124  			}
   125  			tracing.EndSpan(ctx, sc, err)
   126  		}()
   127  	}
   128  	req, err := client.CreatePreparer(ctx, fabricName, input)
   129  	if err != nil {
   130  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Create", nil, "Failure preparing request")
   131  		return
   132  	}
   133  
   134  	result, err = client.CreateSender(req)
   135  	if err != nil {
   136  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Create", result.Response(), "Failure sending request")
   137  		return
   138  	}
   139  
   140  	return
   141  }
   142  
   143  // CreatePreparer prepares the Create request.
   144  func (client ReplicationFabricsClient) CreatePreparer(ctx context.Context, fabricName string, input FabricCreationInput) (*http.Request, error) {
   145  	pathParameters := map[string]interface{}{
   146  		"fabricName":        autorest.Encode("path", fabricName),
   147  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   148  		"resourceName":      autorest.Encode("path", client.ResourceName),
   149  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   150  	}
   151  
   152  	const APIVersion = "2016-08-10"
   153  	queryParameters := map[string]interface{}{
   154  		"api-version": APIVersion,
   155  	}
   156  
   157  	preparer := autorest.CreatePreparer(
   158  		autorest.AsContentType("application/json; charset=utf-8"),
   159  		autorest.AsPut(),
   160  		autorest.WithBaseURL(client.BaseURI),
   161  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters),
   162  		autorest.WithJSON(input),
   163  		autorest.WithQueryParameters(queryParameters))
   164  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   165  }
   166  
   167  // CreateSender sends the Create request. The method will close the
   168  // http.Response Body if it receives an error.
   169  func (client ReplicationFabricsClient) CreateSender(req *http.Request) (future ReplicationFabricsCreateFuture, err error) {
   170  	var resp *http.Response
   171  	future.FutureAPI = &azure.Future{}
   172  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   173  	if err != nil {
   174  		return
   175  	}
   176  	var azf azure.Future
   177  	azf, err = azure.NewFutureFromResponse(resp)
   178  	future.FutureAPI = &azf
   179  	future.Result = future.result
   180  	return
   181  }
   182  
   183  // CreateResponder handles the response to the Create request. The method always
   184  // closes the http.Response Body.
   185  func (client ReplicationFabricsClient) CreateResponder(resp *http.Response) (result Fabric, err error) {
   186  	err = autorest.Respond(
   187  		resp,
   188  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   189  		autorest.ByUnmarshallingJSON(&result),
   190  		autorest.ByClosing())
   191  	result.Response = autorest.Response{Response: resp}
   192  	return
   193  }
   194  
   195  // Delete the operation to delete or remove an Azure Site Recovery fabric.
   196  // Parameters:
   197  // fabricName - ASR fabric to delete
   198  func (client ReplicationFabricsClient) Delete(ctx context.Context, fabricName string) (result ReplicationFabricsDeleteFuture, err error) {
   199  	if tracing.IsEnabled() {
   200  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Delete")
   201  		defer func() {
   202  			sc := -1
   203  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   204  				sc = result.FutureAPI.Response().StatusCode
   205  			}
   206  			tracing.EndSpan(ctx, sc, err)
   207  		}()
   208  	}
   209  	req, err := client.DeletePreparer(ctx, fabricName)
   210  	if err != nil {
   211  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Delete", nil, "Failure preparing request")
   212  		return
   213  	}
   214  
   215  	result, err = client.DeleteSender(req)
   216  	if err != nil {
   217  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Delete", result.Response(), "Failure sending request")
   218  		return
   219  	}
   220  
   221  	return
   222  }
   223  
   224  // DeletePreparer prepares the Delete request.
   225  func (client ReplicationFabricsClient) DeletePreparer(ctx context.Context, fabricName string) (*http.Request, error) {
   226  	pathParameters := map[string]interface{}{
   227  		"fabricName":        autorest.Encode("path", fabricName),
   228  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   229  		"resourceName":      autorest.Encode("path", client.ResourceName),
   230  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   231  	}
   232  
   233  	const APIVersion = "2016-08-10"
   234  	queryParameters := map[string]interface{}{
   235  		"api-version": APIVersion,
   236  	}
   237  
   238  	preparer := autorest.CreatePreparer(
   239  		autorest.AsPost(),
   240  		autorest.WithBaseURL(client.BaseURI),
   241  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/remove", pathParameters),
   242  		autorest.WithQueryParameters(queryParameters))
   243  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   244  }
   245  
   246  // DeleteSender sends the Delete request. The method will close the
   247  // http.Response Body if it receives an error.
   248  func (client ReplicationFabricsClient) DeleteSender(req *http.Request) (future ReplicationFabricsDeleteFuture, err error) {
   249  	var resp *http.Response
   250  	future.FutureAPI = &azure.Future{}
   251  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   252  	if err != nil {
   253  		return
   254  	}
   255  	var azf azure.Future
   256  	azf, err = azure.NewFutureFromResponse(resp)
   257  	future.FutureAPI = &azf
   258  	future.Result = future.result
   259  	return
   260  }
   261  
   262  // DeleteResponder handles the response to the Delete request. The method always
   263  // closes the http.Response Body.
   264  func (client ReplicationFabricsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   265  	err = autorest.Respond(
   266  		resp,
   267  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   268  		autorest.ByClosing())
   269  	result.Response = resp
   270  	return
   271  }
   272  
   273  // Get gets the details of an Azure Site Recovery fabric.
   274  // Parameters:
   275  // fabricName - fabric name.
   276  func (client ReplicationFabricsClient) Get(ctx context.Context, fabricName string) (result Fabric, err error) {
   277  	if tracing.IsEnabled() {
   278  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Get")
   279  		defer func() {
   280  			sc := -1
   281  			if result.Response.Response != nil {
   282  				sc = result.Response.Response.StatusCode
   283  			}
   284  			tracing.EndSpan(ctx, sc, err)
   285  		}()
   286  	}
   287  	req, err := client.GetPreparer(ctx, fabricName)
   288  	if err != nil {
   289  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Get", nil, "Failure preparing request")
   290  		return
   291  	}
   292  
   293  	resp, err := client.GetSender(req)
   294  	if err != nil {
   295  		result.Response = autorest.Response{Response: resp}
   296  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Get", resp, "Failure sending request")
   297  		return
   298  	}
   299  
   300  	result, err = client.GetResponder(resp)
   301  	if err != nil {
   302  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Get", resp, "Failure responding to request")
   303  		return
   304  	}
   305  
   306  	return
   307  }
   308  
   309  // GetPreparer prepares the Get request.
   310  func (client ReplicationFabricsClient) GetPreparer(ctx context.Context, fabricName string) (*http.Request, error) {
   311  	pathParameters := map[string]interface{}{
   312  		"fabricName":        autorest.Encode("path", fabricName),
   313  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   314  		"resourceName":      autorest.Encode("path", client.ResourceName),
   315  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   316  	}
   317  
   318  	const APIVersion = "2016-08-10"
   319  	queryParameters := map[string]interface{}{
   320  		"api-version": APIVersion,
   321  	}
   322  
   323  	preparer := autorest.CreatePreparer(
   324  		autorest.AsGet(),
   325  		autorest.WithBaseURL(client.BaseURI),
   326  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters),
   327  		autorest.WithQueryParameters(queryParameters))
   328  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   329  }
   330  
   331  // GetSender sends the Get request. The method will close the
   332  // http.Response Body if it receives an error.
   333  func (client ReplicationFabricsClient) GetSender(req *http.Request) (*http.Response, error) {
   334  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   335  }
   336  
   337  // GetResponder handles the response to the Get request. The method always
   338  // closes the http.Response Body.
   339  func (client ReplicationFabricsClient) GetResponder(resp *http.Response) (result Fabric, err error) {
   340  	err = autorest.Respond(
   341  		resp,
   342  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   343  		autorest.ByUnmarshallingJSON(&result),
   344  		autorest.ByClosing())
   345  	result.Response = autorest.Response{Response: resp}
   346  	return
   347  }
   348  
   349  // List gets a list of the Azure Site Recovery fabrics in the vault.
   350  func (client ReplicationFabricsClient) List(ctx context.Context) (result FabricCollectionPage, err error) {
   351  	if tracing.IsEnabled() {
   352  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.List")
   353  		defer func() {
   354  			sc := -1
   355  			if result.fc.Response.Response != nil {
   356  				sc = result.fc.Response.Response.StatusCode
   357  			}
   358  			tracing.EndSpan(ctx, sc, err)
   359  		}()
   360  	}
   361  	result.fn = client.listNextResults
   362  	req, err := client.ListPreparer(ctx)
   363  	if err != nil {
   364  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "List", nil, "Failure preparing request")
   365  		return
   366  	}
   367  
   368  	resp, err := client.ListSender(req)
   369  	if err != nil {
   370  		result.fc.Response = autorest.Response{Response: resp}
   371  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "List", resp, "Failure sending request")
   372  		return
   373  	}
   374  
   375  	result.fc, err = client.ListResponder(resp)
   376  	if err != nil {
   377  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "List", resp, "Failure responding to request")
   378  		return
   379  	}
   380  	if result.fc.hasNextLink() && result.fc.IsEmpty() {
   381  		err = result.NextWithContext(ctx)
   382  		return
   383  	}
   384  
   385  	return
   386  }
   387  
   388  // ListPreparer prepares the List request.
   389  func (client ReplicationFabricsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   390  	pathParameters := map[string]interface{}{
   391  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   392  		"resourceName":      autorest.Encode("path", client.ResourceName),
   393  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   394  	}
   395  
   396  	const APIVersion = "2016-08-10"
   397  	queryParameters := map[string]interface{}{
   398  		"api-version": APIVersion,
   399  	}
   400  
   401  	preparer := autorest.CreatePreparer(
   402  		autorest.AsGet(),
   403  		autorest.WithBaseURL(client.BaseURI),
   404  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics", pathParameters),
   405  		autorest.WithQueryParameters(queryParameters))
   406  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   407  }
   408  
   409  // ListSender sends the List request. The method will close the
   410  // http.Response Body if it receives an error.
   411  func (client ReplicationFabricsClient) ListSender(req *http.Request) (*http.Response, error) {
   412  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   413  }
   414  
   415  // ListResponder handles the response to the List request. The method always
   416  // closes the http.Response Body.
   417  func (client ReplicationFabricsClient) ListResponder(resp *http.Response) (result FabricCollection, err error) {
   418  	err = autorest.Respond(
   419  		resp,
   420  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   421  		autorest.ByUnmarshallingJSON(&result),
   422  		autorest.ByClosing())
   423  	result.Response = autorest.Response{Response: resp}
   424  	return
   425  }
   426  
   427  // listNextResults retrieves the next set of results, if any.
   428  func (client ReplicationFabricsClient) listNextResults(ctx context.Context, lastResults FabricCollection) (result FabricCollection, err error) {
   429  	req, err := lastResults.fabricCollectionPreparer(ctx)
   430  	if err != nil {
   431  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "listNextResults", nil, "Failure preparing next results request")
   432  	}
   433  	if req == nil {
   434  		return
   435  	}
   436  	resp, err := client.ListSender(req)
   437  	if err != nil {
   438  		result.Response = autorest.Response{Response: resp}
   439  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "listNextResults", resp, "Failure sending next results request")
   440  	}
   441  	result, err = client.ListResponder(resp)
   442  	if err != nil {
   443  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "listNextResults", resp, "Failure responding to next results request")
   444  	}
   445  	return
   446  }
   447  
   448  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   449  func (client ReplicationFabricsClient) ListComplete(ctx context.Context) (result FabricCollectionIterator, err error) {
   450  	if tracing.IsEnabled() {
   451  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.List")
   452  		defer func() {
   453  			sc := -1
   454  			if result.Response().Response.Response != nil {
   455  				sc = result.page.Response().Response.Response.StatusCode
   456  			}
   457  			tracing.EndSpan(ctx, sc, err)
   458  		}()
   459  	}
   460  	result.page, err = client.List(ctx)
   461  	return
   462  }
   463  
   464  // MigrateToAad the operation to migrate an Azure Site Recovery fabric to AAD.
   465  // Parameters:
   466  // fabricName - ASR fabric to migrate.
   467  func (client ReplicationFabricsClient) MigrateToAad(ctx context.Context, fabricName string) (result ReplicationFabricsMigrateToAadFuture, err error) {
   468  	if tracing.IsEnabled() {
   469  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.MigrateToAad")
   470  		defer func() {
   471  			sc := -1
   472  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   473  				sc = result.FutureAPI.Response().StatusCode
   474  			}
   475  			tracing.EndSpan(ctx, sc, err)
   476  		}()
   477  	}
   478  	req, err := client.MigrateToAadPreparer(ctx, fabricName)
   479  	if err != nil {
   480  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "MigrateToAad", nil, "Failure preparing request")
   481  		return
   482  	}
   483  
   484  	result, err = client.MigrateToAadSender(req)
   485  	if err != nil {
   486  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "MigrateToAad", result.Response(), "Failure sending request")
   487  		return
   488  	}
   489  
   490  	return
   491  }
   492  
   493  // MigrateToAadPreparer prepares the MigrateToAad request.
   494  func (client ReplicationFabricsClient) MigrateToAadPreparer(ctx context.Context, fabricName string) (*http.Request, error) {
   495  	pathParameters := map[string]interface{}{
   496  		"fabricName":        autorest.Encode("path", fabricName),
   497  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   498  		"resourceName":      autorest.Encode("path", client.ResourceName),
   499  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   500  	}
   501  
   502  	const APIVersion = "2016-08-10"
   503  	queryParameters := map[string]interface{}{
   504  		"api-version": APIVersion,
   505  	}
   506  
   507  	preparer := autorest.CreatePreparer(
   508  		autorest.AsPost(),
   509  		autorest.WithBaseURL(client.BaseURI),
   510  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/migratetoaad", pathParameters),
   511  		autorest.WithQueryParameters(queryParameters))
   512  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   513  }
   514  
   515  // MigrateToAadSender sends the MigrateToAad request. The method will close the
   516  // http.Response Body if it receives an error.
   517  func (client ReplicationFabricsClient) MigrateToAadSender(req *http.Request) (future ReplicationFabricsMigrateToAadFuture, err error) {
   518  	var resp *http.Response
   519  	future.FutureAPI = &azure.Future{}
   520  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   521  	if err != nil {
   522  		return
   523  	}
   524  	var azf azure.Future
   525  	azf, err = azure.NewFutureFromResponse(resp)
   526  	future.FutureAPI = &azf
   527  	future.Result = future.result
   528  	return
   529  }
   530  
   531  // MigrateToAadResponder handles the response to the MigrateToAad request. The method always
   532  // closes the http.Response Body.
   533  func (client ReplicationFabricsClient) MigrateToAadResponder(resp *http.Response) (result autorest.Response, err error) {
   534  	err = autorest.Respond(
   535  		resp,
   536  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   537  		autorest.ByClosing())
   538  	result.Response = resp
   539  	return
   540  }
   541  
   542  // Purge the operation to purge(force delete) an Azure Site Recovery fabric.
   543  // Parameters:
   544  // fabricName - ASR fabric to purge.
   545  func (client ReplicationFabricsClient) Purge(ctx context.Context, fabricName string) (result ReplicationFabricsPurgeFuture, err error) {
   546  	if tracing.IsEnabled() {
   547  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Purge")
   548  		defer func() {
   549  			sc := -1
   550  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   551  				sc = result.FutureAPI.Response().StatusCode
   552  			}
   553  			tracing.EndSpan(ctx, sc, err)
   554  		}()
   555  	}
   556  	req, err := client.PurgePreparer(ctx, fabricName)
   557  	if err != nil {
   558  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Purge", nil, "Failure preparing request")
   559  		return
   560  	}
   561  
   562  	result, err = client.PurgeSender(req)
   563  	if err != nil {
   564  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Purge", result.Response(), "Failure sending request")
   565  		return
   566  	}
   567  
   568  	return
   569  }
   570  
   571  // PurgePreparer prepares the Purge request.
   572  func (client ReplicationFabricsClient) PurgePreparer(ctx context.Context, fabricName string) (*http.Request, error) {
   573  	pathParameters := map[string]interface{}{
   574  		"fabricName":        autorest.Encode("path", fabricName),
   575  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   576  		"resourceName":      autorest.Encode("path", client.ResourceName),
   577  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   578  	}
   579  
   580  	const APIVersion = "2016-08-10"
   581  	queryParameters := map[string]interface{}{
   582  		"api-version": APIVersion,
   583  	}
   584  
   585  	preparer := autorest.CreatePreparer(
   586  		autorest.AsDelete(),
   587  		autorest.WithBaseURL(client.BaseURI),
   588  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters),
   589  		autorest.WithQueryParameters(queryParameters))
   590  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   591  }
   592  
   593  // PurgeSender sends the Purge request. The method will close the
   594  // http.Response Body if it receives an error.
   595  func (client ReplicationFabricsClient) PurgeSender(req *http.Request) (future ReplicationFabricsPurgeFuture, err error) {
   596  	var resp *http.Response
   597  	future.FutureAPI = &azure.Future{}
   598  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   599  	if err != nil {
   600  		return
   601  	}
   602  	var azf azure.Future
   603  	azf, err = azure.NewFutureFromResponse(resp)
   604  	future.FutureAPI = &azf
   605  	future.Result = future.result
   606  	return
   607  }
   608  
   609  // PurgeResponder handles the response to the Purge request. The method always
   610  // closes the http.Response Body.
   611  func (client ReplicationFabricsClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) {
   612  	err = autorest.Respond(
   613  		resp,
   614  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   615  		autorest.ByClosing())
   616  	result.Response = resp
   617  	return
   618  }
   619  
   620  // ReassociateGateway the operation to move replications from a process server to another process server.
   621  // Parameters:
   622  // fabricName - the name of the fabric containing the process server.
   623  // failoverProcessServerRequest - the input to the failover process server operation.
   624  func (client ReplicationFabricsClient) ReassociateGateway(ctx context.Context, fabricName string, failoverProcessServerRequest FailoverProcessServerRequest) (result ReplicationFabricsReassociateGatewayFuture, err error) {
   625  	if tracing.IsEnabled() {
   626  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.ReassociateGateway")
   627  		defer func() {
   628  			sc := -1
   629  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   630  				sc = result.FutureAPI.Response().StatusCode
   631  			}
   632  			tracing.EndSpan(ctx, sc, err)
   633  		}()
   634  	}
   635  	req, err := client.ReassociateGatewayPreparer(ctx, fabricName, failoverProcessServerRequest)
   636  	if err != nil {
   637  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "ReassociateGateway", nil, "Failure preparing request")
   638  		return
   639  	}
   640  
   641  	result, err = client.ReassociateGatewaySender(req)
   642  	if err != nil {
   643  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "ReassociateGateway", result.Response(), "Failure sending request")
   644  		return
   645  	}
   646  
   647  	return
   648  }
   649  
   650  // ReassociateGatewayPreparer prepares the ReassociateGateway request.
   651  func (client ReplicationFabricsClient) ReassociateGatewayPreparer(ctx context.Context, fabricName string, failoverProcessServerRequest FailoverProcessServerRequest) (*http.Request, error) {
   652  	pathParameters := map[string]interface{}{
   653  		"fabricName":        autorest.Encode("path", fabricName),
   654  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   655  		"resourceName":      autorest.Encode("path", client.ResourceName),
   656  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   657  	}
   658  
   659  	const APIVersion = "2016-08-10"
   660  	queryParameters := map[string]interface{}{
   661  		"api-version": APIVersion,
   662  	}
   663  
   664  	preparer := autorest.CreatePreparer(
   665  		autorest.AsContentType("application/json; charset=utf-8"),
   666  		autorest.AsPost(),
   667  		autorest.WithBaseURL(client.BaseURI),
   668  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/reassociateGateway", pathParameters),
   669  		autorest.WithJSON(failoverProcessServerRequest),
   670  		autorest.WithQueryParameters(queryParameters))
   671  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   672  }
   673  
   674  // ReassociateGatewaySender sends the ReassociateGateway request. The method will close the
   675  // http.Response Body if it receives an error.
   676  func (client ReplicationFabricsClient) ReassociateGatewaySender(req *http.Request) (future ReplicationFabricsReassociateGatewayFuture, err error) {
   677  	var resp *http.Response
   678  	future.FutureAPI = &azure.Future{}
   679  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   680  	if err != nil {
   681  		return
   682  	}
   683  	var azf azure.Future
   684  	azf, err = azure.NewFutureFromResponse(resp)
   685  	future.FutureAPI = &azf
   686  	future.Result = future.result
   687  	return
   688  }
   689  
   690  // ReassociateGatewayResponder handles the response to the ReassociateGateway request. The method always
   691  // closes the http.Response Body.
   692  func (client ReplicationFabricsClient) ReassociateGatewayResponder(resp *http.Response) (result Fabric, err error) {
   693  	err = autorest.Respond(
   694  		resp,
   695  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   696  		autorest.ByUnmarshallingJSON(&result),
   697  		autorest.ByClosing())
   698  	result.Response = autorest.Response{Response: resp}
   699  	return
   700  }
   701  
   702  // RenewCertificate renews the connection certificate for the ASR replication fabric.
   703  // Parameters:
   704  // fabricName - fabric name to renew certs for.
   705  // renewCertificate - renew certificate input.
   706  func (client ReplicationFabricsClient) RenewCertificate(ctx context.Context, fabricName string, renewCertificate RenewCertificateInput) (result ReplicationFabricsRenewCertificateFuture, err error) {
   707  	if tracing.IsEnabled() {
   708  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.RenewCertificate")
   709  		defer func() {
   710  			sc := -1
   711  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   712  				sc = result.FutureAPI.Response().StatusCode
   713  			}
   714  			tracing.EndSpan(ctx, sc, err)
   715  		}()
   716  	}
   717  	req, err := client.RenewCertificatePreparer(ctx, fabricName, renewCertificate)
   718  	if err != nil {
   719  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "RenewCertificate", nil, "Failure preparing request")
   720  		return
   721  	}
   722  
   723  	result, err = client.RenewCertificateSender(req)
   724  	if err != nil {
   725  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "RenewCertificate", result.Response(), "Failure sending request")
   726  		return
   727  	}
   728  
   729  	return
   730  }
   731  
   732  // RenewCertificatePreparer prepares the RenewCertificate request.
   733  func (client ReplicationFabricsClient) RenewCertificatePreparer(ctx context.Context, fabricName string, renewCertificate RenewCertificateInput) (*http.Request, error) {
   734  	pathParameters := map[string]interface{}{
   735  		"fabricName":        autorest.Encode("path", fabricName),
   736  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   737  		"resourceName":      autorest.Encode("path", client.ResourceName),
   738  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   739  	}
   740  
   741  	const APIVersion = "2016-08-10"
   742  	queryParameters := map[string]interface{}{
   743  		"api-version": APIVersion,
   744  	}
   745  
   746  	preparer := autorest.CreatePreparer(
   747  		autorest.AsContentType("application/json; charset=utf-8"),
   748  		autorest.AsPost(),
   749  		autorest.WithBaseURL(client.BaseURI),
   750  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/renewCertificate", pathParameters),
   751  		autorest.WithJSON(renewCertificate),
   752  		autorest.WithQueryParameters(queryParameters))
   753  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   754  }
   755  
   756  // RenewCertificateSender sends the RenewCertificate request. The method will close the
   757  // http.Response Body if it receives an error.
   758  func (client ReplicationFabricsClient) RenewCertificateSender(req *http.Request) (future ReplicationFabricsRenewCertificateFuture, err error) {
   759  	var resp *http.Response
   760  	future.FutureAPI = &azure.Future{}
   761  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   762  	if err != nil {
   763  		return
   764  	}
   765  	var azf azure.Future
   766  	azf, err = azure.NewFutureFromResponse(resp)
   767  	future.FutureAPI = &azf
   768  	future.Result = future.result
   769  	return
   770  }
   771  
   772  // RenewCertificateResponder handles the response to the RenewCertificate request. The method always
   773  // closes the http.Response Body.
   774  func (client ReplicationFabricsClient) RenewCertificateResponder(resp *http.Response) (result Fabric, err error) {
   775  	err = autorest.Respond(
   776  		resp,
   777  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   778  		autorest.ByUnmarshallingJSON(&result),
   779  		autorest.ByClosing())
   780  	result.Response = autorest.Response{Response: resp}
   781  	return
   782  }
   783  

View as plain text