...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-08-10/siterecovery/replicationrecoveryservicesproviders.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  // ReplicationRecoveryServicesProvidersClient is the client for the ReplicationRecoveryServicesProviders methods of the
    18  // Siterecovery service.
    19  type ReplicationRecoveryServicesProvidersClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewReplicationRecoveryServicesProvidersClient creates an instance of the ReplicationRecoveryServicesProvidersClient
    24  // client.
    25  func NewReplicationRecoveryServicesProvidersClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryServicesProvidersClient {
    26  	return NewReplicationRecoveryServicesProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    27  }
    28  
    29  // NewReplicationRecoveryServicesProvidersClientWithBaseURI creates an instance of the
    30  // ReplicationRecoveryServicesProvidersClient client using a custom endpoint.  Use this when interacting with an Azure
    31  // cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    32  func NewReplicationRecoveryServicesProvidersClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryServicesProvidersClient {
    33  	return ReplicationRecoveryServicesProvidersClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    34  }
    35  
    36  // Delete the operation to removes/delete(unregister) a recovery services provider from the vault
    37  // Parameters:
    38  // fabricName - fabric name.
    39  // providerName - recovery services provider name.
    40  func (client ReplicationRecoveryServicesProvidersClient) Delete(ctx context.Context, fabricName string, providerName string) (result ReplicationRecoveryServicesProvidersDeleteFuture, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.Delete")
    43  		defer func() {
    44  			sc := -1
    45  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    46  				sc = result.FutureAPI.Response().StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	req, err := client.DeletePreparer(ctx, fabricName, providerName)
    52  	if err != nil {
    53  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Delete", nil, "Failure preparing request")
    54  		return
    55  	}
    56  
    57  	result, err = client.DeleteSender(req)
    58  	if err != nil {
    59  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Delete", result.Response(), "Failure sending request")
    60  		return
    61  	}
    62  
    63  	return
    64  }
    65  
    66  // DeletePreparer prepares the Delete request.
    67  func (client ReplicationRecoveryServicesProvidersClient) DeletePreparer(ctx context.Context, fabricName string, providerName string) (*http.Request, error) {
    68  	pathParameters := map[string]interface{}{
    69  		"fabricName":        autorest.Encode("path", fabricName),
    70  		"providerName":      autorest.Encode("path", providerName),
    71  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
    72  		"resourceName":      autorest.Encode("path", client.ResourceName),
    73  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    74  	}
    75  
    76  	const APIVersion = "2016-08-10"
    77  	queryParameters := map[string]interface{}{
    78  		"api-version": APIVersion,
    79  	}
    80  
    81  	preparer := autorest.CreatePreparer(
    82  		autorest.AsPost(),
    83  		autorest.WithBaseURL(client.BaseURI),
    84  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}/remove", pathParameters),
    85  		autorest.WithQueryParameters(queryParameters))
    86  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    87  }
    88  
    89  // DeleteSender sends the Delete request. The method will close the
    90  // http.Response Body if it receives an error.
    91  func (client ReplicationRecoveryServicesProvidersClient) DeleteSender(req *http.Request) (future ReplicationRecoveryServicesProvidersDeleteFuture, err error) {
    92  	var resp *http.Response
    93  	future.FutureAPI = &azure.Future{}
    94  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    95  	if err != nil {
    96  		return
    97  	}
    98  	var azf azure.Future
    99  	azf, err = azure.NewFutureFromResponse(resp)
   100  	future.FutureAPI = &azf
   101  	future.Result = future.result
   102  	return
   103  }
   104  
   105  // DeleteResponder handles the response to the Delete request. The method always
   106  // closes the http.Response Body.
   107  func (client ReplicationRecoveryServicesProvidersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   108  	err = autorest.Respond(
   109  		resp,
   110  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   111  		autorest.ByClosing())
   112  	result.Response = resp
   113  	return
   114  }
   115  
   116  // Get gets the details of registered recovery services provider.
   117  // Parameters:
   118  // fabricName - fabric name.
   119  // providerName - recovery services provider name
   120  func (client ReplicationRecoveryServicesProvidersClient) Get(ctx context.Context, fabricName string, providerName string) (result RecoveryServicesProvider, err error) {
   121  	if tracing.IsEnabled() {
   122  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.Get")
   123  		defer func() {
   124  			sc := -1
   125  			if result.Response.Response != nil {
   126  				sc = result.Response.Response.StatusCode
   127  			}
   128  			tracing.EndSpan(ctx, sc, err)
   129  		}()
   130  	}
   131  	req, err := client.GetPreparer(ctx, fabricName, providerName)
   132  	if err != nil {
   133  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Get", nil, "Failure preparing request")
   134  		return
   135  	}
   136  
   137  	resp, err := client.GetSender(req)
   138  	if err != nil {
   139  		result.Response = autorest.Response{Response: resp}
   140  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Get", resp, "Failure sending request")
   141  		return
   142  	}
   143  
   144  	result, err = client.GetResponder(resp)
   145  	if err != nil {
   146  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Get", resp, "Failure responding to request")
   147  		return
   148  	}
   149  
   150  	return
   151  }
   152  
   153  // GetPreparer prepares the Get request.
   154  func (client ReplicationRecoveryServicesProvidersClient) GetPreparer(ctx context.Context, fabricName string, providerName string) (*http.Request, error) {
   155  	pathParameters := map[string]interface{}{
   156  		"fabricName":        autorest.Encode("path", fabricName),
   157  		"providerName":      autorest.Encode("path", providerName),
   158  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   159  		"resourceName":      autorest.Encode("path", client.ResourceName),
   160  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   161  	}
   162  
   163  	const APIVersion = "2016-08-10"
   164  	queryParameters := map[string]interface{}{
   165  		"api-version": APIVersion,
   166  	}
   167  
   168  	preparer := autorest.CreatePreparer(
   169  		autorest.AsGet(),
   170  		autorest.WithBaseURL(client.BaseURI),
   171  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}", pathParameters),
   172  		autorest.WithQueryParameters(queryParameters))
   173  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   174  }
   175  
   176  // GetSender sends the Get request. The method will close the
   177  // http.Response Body if it receives an error.
   178  func (client ReplicationRecoveryServicesProvidersClient) GetSender(req *http.Request) (*http.Response, error) {
   179  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   180  }
   181  
   182  // GetResponder handles the response to the Get request. The method always
   183  // closes the http.Response Body.
   184  func (client ReplicationRecoveryServicesProvidersClient) GetResponder(resp *http.Response) (result RecoveryServicesProvider, err error) {
   185  	err = autorest.Respond(
   186  		resp,
   187  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   188  		autorest.ByUnmarshallingJSON(&result),
   189  		autorest.ByClosing())
   190  	result.Response = autorest.Response{Response: resp}
   191  	return
   192  }
   193  
   194  // List lists the registered recovery services providers in the vault
   195  func (client ReplicationRecoveryServicesProvidersClient) List(ctx context.Context) (result RecoveryServicesProviderCollectionPage, err error) {
   196  	if tracing.IsEnabled() {
   197  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.List")
   198  		defer func() {
   199  			sc := -1
   200  			if result.rspc.Response.Response != nil {
   201  				sc = result.rspc.Response.Response.StatusCode
   202  			}
   203  			tracing.EndSpan(ctx, sc, err)
   204  		}()
   205  	}
   206  	result.fn = client.listNextResults
   207  	req, err := client.ListPreparer(ctx)
   208  	if err != nil {
   209  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "List", nil, "Failure preparing request")
   210  		return
   211  	}
   212  
   213  	resp, err := client.ListSender(req)
   214  	if err != nil {
   215  		result.rspc.Response = autorest.Response{Response: resp}
   216  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "List", resp, "Failure sending request")
   217  		return
   218  	}
   219  
   220  	result.rspc, err = client.ListResponder(resp)
   221  	if err != nil {
   222  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "List", resp, "Failure responding to request")
   223  		return
   224  	}
   225  	if result.rspc.hasNextLink() && result.rspc.IsEmpty() {
   226  		err = result.NextWithContext(ctx)
   227  		return
   228  	}
   229  
   230  	return
   231  }
   232  
   233  // ListPreparer prepares the List request.
   234  func (client ReplicationRecoveryServicesProvidersClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   235  	pathParameters := map[string]interface{}{
   236  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   237  		"resourceName":      autorest.Encode("path", client.ResourceName),
   238  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   239  	}
   240  
   241  	const APIVersion = "2016-08-10"
   242  	queryParameters := map[string]interface{}{
   243  		"api-version": APIVersion,
   244  	}
   245  
   246  	preparer := autorest.CreatePreparer(
   247  		autorest.AsGet(),
   248  		autorest.WithBaseURL(client.BaseURI),
   249  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryServicesProviders", pathParameters),
   250  		autorest.WithQueryParameters(queryParameters))
   251  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   252  }
   253  
   254  // ListSender sends the List request. The method will close the
   255  // http.Response Body if it receives an error.
   256  func (client ReplicationRecoveryServicesProvidersClient) ListSender(req *http.Request) (*http.Response, error) {
   257  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   258  }
   259  
   260  // ListResponder handles the response to the List request. The method always
   261  // closes the http.Response Body.
   262  func (client ReplicationRecoveryServicesProvidersClient) ListResponder(resp *http.Response) (result RecoveryServicesProviderCollection, err error) {
   263  	err = autorest.Respond(
   264  		resp,
   265  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   266  		autorest.ByUnmarshallingJSON(&result),
   267  		autorest.ByClosing())
   268  	result.Response = autorest.Response{Response: resp}
   269  	return
   270  }
   271  
   272  // listNextResults retrieves the next set of results, if any.
   273  func (client ReplicationRecoveryServicesProvidersClient) listNextResults(ctx context.Context, lastResults RecoveryServicesProviderCollection) (result RecoveryServicesProviderCollection, err error) {
   274  	req, err := lastResults.recoveryServicesProviderCollectionPreparer(ctx)
   275  	if err != nil {
   276  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "listNextResults", nil, "Failure preparing next results request")
   277  	}
   278  	if req == nil {
   279  		return
   280  	}
   281  	resp, err := client.ListSender(req)
   282  	if err != nil {
   283  		result.Response = autorest.Response{Response: resp}
   284  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "listNextResults", resp, "Failure sending next results request")
   285  	}
   286  	result, err = client.ListResponder(resp)
   287  	if err != nil {
   288  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "listNextResults", resp, "Failure responding to next results request")
   289  	}
   290  	return
   291  }
   292  
   293  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   294  func (client ReplicationRecoveryServicesProvidersClient) ListComplete(ctx context.Context) (result RecoveryServicesProviderCollectionIterator, err error) {
   295  	if tracing.IsEnabled() {
   296  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.List")
   297  		defer func() {
   298  			sc := -1
   299  			if result.Response().Response.Response != nil {
   300  				sc = result.page.Response().Response.Response.StatusCode
   301  			}
   302  			tracing.EndSpan(ctx, sc, err)
   303  		}()
   304  	}
   305  	result.page, err = client.List(ctx)
   306  	return
   307  }
   308  
   309  // ListByReplicationFabrics lists the registered recovery services providers for the specified fabric.
   310  // Parameters:
   311  // fabricName - fabric name
   312  func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabrics(ctx context.Context, fabricName string) (result RecoveryServicesProviderCollectionPage, err error) {
   313  	if tracing.IsEnabled() {
   314  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.ListByReplicationFabrics")
   315  		defer func() {
   316  			sc := -1
   317  			if result.rspc.Response.Response != nil {
   318  				sc = result.rspc.Response.Response.StatusCode
   319  			}
   320  			tracing.EndSpan(ctx, sc, err)
   321  		}()
   322  	}
   323  	result.fn = client.listByReplicationFabricsNextResults
   324  	req, err := client.ListByReplicationFabricsPreparer(ctx, fabricName)
   325  	if err != nil {
   326  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", nil, "Failure preparing request")
   327  		return
   328  	}
   329  
   330  	resp, err := client.ListByReplicationFabricsSender(req)
   331  	if err != nil {
   332  		result.rspc.Response = autorest.Response{Response: resp}
   333  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", resp, "Failure sending request")
   334  		return
   335  	}
   336  
   337  	result.rspc, err = client.ListByReplicationFabricsResponder(resp)
   338  	if err != nil {
   339  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", resp, "Failure responding to request")
   340  		return
   341  	}
   342  	if result.rspc.hasNextLink() && result.rspc.IsEmpty() {
   343  		err = result.NextWithContext(ctx)
   344  		return
   345  	}
   346  
   347  	return
   348  }
   349  
   350  // ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request.
   351  func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsPreparer(ctx context.Context, fabricName string) (*http.Request, error) {
   352  	pathParameters := map[string]interface{}{
   353  		"fabricName":        autorest.Encode("path", fabricName),
   354  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   355  		"resourceName":      autorest.Encode("path", client.ResourceName),
   356  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   357  	}
   358  
   359  	const APIVersion = "2016-08-10"
   360  	queryParameters := map[string]interface{}{
   361  		"api-version": APIVersion,
   362  	}
   363  
   364  	preparer := autorest.CreatePreparer(
   365  		autorest.AsGet(),
   366  		autorest.WithBaseURL(client.BaseURI),
   367  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders", pathParameters),
   368  		autorest.WithQueryParameters(queryParameters))
   369  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   370  }
   371  
   372  // ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the
   373  // http.Response Body if it receives an error.
   374  func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) {
   375  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   376  }
   377  
   378  // ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always
   379  // closes the http.Response Body.
   380  func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsResponder(resp *http.Response) (result RecoveryServicesProviderCollection, err error) {
   381  	err = autorest.Respond(
   382  		resp,
   383  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   384  		autorest.ByUnmarshallingJSON(&result),
   385  		autorest.ByClosing())
   386  	result.Response = autorest.Response{Response: resp}
   387  	return
   388  }
   389  
   390  // listByReplicationFabricsNextResults retrieves the next set of results, if any.
   391  func (client ReplicationRecoveryServicesProvidersClient) listByReplicationFabricsNextResults(ctx context.Context, lastResults RecoveryServicesProviderCollection) (result RecoveryServicesProviderCollection, err error) {
   392  	req, err := lastResults.recoveryServicesProviderCollectionPreparer(ctx)
   393  	if err != nil {
   394  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "listByReplicationFabricsNextResults", nil, "Failure preparing next results request")
   395  	}
   396  	if req == nil {
   397  		return
   398  	}
   399  	resp, err := client.ListByReplicationFabricsSender(req)
   400  	if err != nil {
   401  		result.Response = autorest.Response{Response: resp}
   402  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "listByReplicationFabricsNextResults", resp, "Failure sending next results request")
   403  	}
   404  	result, err = client.ListByReplicationFabricsResponder(resp)
   405  	if err != nil {
   406  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "listByReplicationFabricsNextResults", resp, "Failure responding to next results request")
   407  	}
   408  	return
   409  }
   410  
   411  // ListByReplicationFabricsComplete enumerates all values, automatically crossing page boundaries as required.
   412  func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsComplete(ctx context.Context, fabricName string) (result RecoveryServicesProviderCollectionIterator, err error) {
   413  	if tracing.IsEnabled() {
   414  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.ListByReplicationFabrics")
   415  		defer func() {
   416  			sc := -1
   417  			if result.Response().Response.Response != nil {
   418  				sc = result.page.Response().Response.Response.StatusCode
   419  			}
   420  			tracing.EndSpan(ctx, sc, err)
   421  		}()
   422  	}
   423  	result.page, err = client.ListByReplicationFabrics(ctx, fabricName)
   424  	return
   425  }
   426  
   427  // Purge the operation to purge(force delete) a recovery services provider from the vault.
   428  // Parameters:
   429  // fabricName - fabric name.
   430  // providerName - recovery services provider name.
   431  func (client ReplicationRecoveryServicesProvidersClient) Purge(ctx context.Context, fabricName string, providerName string) (result ReplicationRecoveryServicesProvidersPurgeFuture, err error) {
   432  	if tracing.IsEnabled() {
   433  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.Purge")
   434  		defer func() {
   435  			sc := -1
   436  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   437  				sc = result.FutureAPI.Response().StatusCode
   438  			}
   439  			tracing.EndSpan(ctx, sc, err)
   440  		}()
   441  	}
   442  	req, err := client.PurgePreparer(ctx, fabricName, providerName)
   443  	if err != nil {
   444  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Purge", nil, "Failure preparing request")
   445  		return
   446  	}
   447  
   448  	result, err = client.PurgeSender(req)
   449  	if err != nil {
   450  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "Purge", result.Response(), "Failure sending request")
   451  		return
   452  	}
   453  
   454  	return
   455  }
   456  
   457  // PurgePreparer prepares the Purge request.
   458  func (client ReplicationRecoveryServicesProvidersClient) PurgePreparer(ctx context.Context, fabricName string, providerName string) (*http.Request, error) {
   459  	pathParameters := map[string]interface{}{
   460  		"fabricName":        autorest.Encode("path", fabricName),
   461  		"providerName":      autorest.Encode("path", providerName),
   462  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   463  		"resourceName":      autorest.Encode("path", client.ResourceName),
   464  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   465  	}
   466  
   467  	const APIVersion = "2016-08-10"
   468  	queryParameters := map[string]interface{}{
   469  		"api-version": APIVersion,
   470  	}
   471  
   472  	preparer := autorest.CreatePreparer(
   473  		autorest.AsDelete(),
   474  		autorest.WithBaseURL(client.BaseURI),
   475  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}", pathParameters),
   476  		autorest.WithQueryParameters(queryParameters))
   477  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   478  }
   479  
   480  // PurgeSender sends the Purge request. The method will close the
   481  // http.Response Body if it receives an error.
   482  func (client ReplicationRecoveryServicesProvidersClient) PurgeSender(req *http.Request) (future ReplicationRecoveryServicesProvidersPurgeFuture, err error) {
   483  	var resp *http.Response
   484  	future.FutureAPI = &azure.Future{}
   485  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   486  	if err != nil {
   487  		return
   488  	}
   489  	var azf azure.Future
   490  	azf, err = azure.NewFutureFromResponse(resp)
   491  	future.FutureAPI = &azf
   492  	future.Result = future.result
   493  	return
   494  }
   495  
   496  // PurgeResponder handles the response to the Purge request. The method always
   497  // closes the http.Response Body.
   498  func (client ReplicationRecoveryServicesProvidersClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) {
   499  	err = autorest.Respond(
   500  		resp,
   501  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   502  		autorest.ByClosing())
   503  	result.Response = resp
   504  	return
   505  }
   506  
   507  // RefreshProvider the operation to refresh the information from the recovery services provider.
   508  // Parameters:
   509  // fabricName - fabric name.
   510  // providerName - recovery services provider name.
   511  func (client ReplicationRecoveryServicesProvidersClient) RefreshProvider(ctx context.Context, fabricName string, providerName string) (result ReplicationRecoveryServicesProvidersRefreshProviderFuture, err error) {
   512  	if tracing.IsEnabled() {
   513  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryServicesProvidersClient.RefreshProvider")
   514  		defer func() {
   515  			sc := -1
   516  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   517  				sc = result.FutureAPI.Response().StatusCode
   518  			}
   519  			tracing.EndSpan(ctx, sc, err)
   520  		}()
   521  	}
   522  	req, err := client.RefreshProviderPreparer(ctx, fabricName, providerName)
   523  	if err != nil {
   524  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "RefreshProvider", nil, "Failure preparing request")
   525  		return
   526  	}
   527  
   528  	result, err = client.RefreshProviderSender(req)
   529  	if err != nil {
   530  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryServicesProvidersClient", "RefreshProvider", result.Response(), "Failure sending request")
   531  		return
   532  	}
   533  
   534  	return
   535  }
   536  
   537  // RefreshProviderPreparer prepares the RefreshProvider request.
   538  func (client ReplicationRecoveryServicesProvidersClient) RefreshProviderPreparer(ctx context.Context, fabricName string, providerName string) (*http.Request, error) {
   539  	pathParameters := map[string]interface{}{
   540  		"fabricName":        autorest.Encode("path", fabricName),
   541  		"providerName":      autorest.Encode("path", providerName),
   542  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   543  		"resourceName":      autorest.Encode("path", client.ResourceName),
   544  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   545  	}
   546  
   547  	const APIVersion = "2016-08-10"
   548  	queryParameters := map[string]interface{}{
   549  		"api-version": APIVersion,
   550  	}
   551  
   552  	preparer := autorest.CreatePreparer(
   553  		autorest.AsPost(),
   554  		autorest.WithBaseURL(client.BaseURI),
   555  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}/refreshProvider", pathParameters),
   556  		autorest.WithQueryParameters(queryParameters))
   557  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   558  }
   559  
   560  // RefreshProviderSender sends the RefreshProvider request. The method will close the
   561  // http.Response Body if it receives an error.
   562  func (client ReplicationRecoveryServicesProvidersClient) RefreshProviderSender(req *http.Request) (future ReplicationRecoveryServicesProvidersRefreshProviderFuture, err error) {
   563  	var resp *http.Response
   564  	future.FutureAPI = &azure.Future{}
   565  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   566  	if err != nil {
   567  		return
   568  	}
   569  	var azf azure.Future
   570  	azf, err = azure.NewFutureFromResponse(resp)
   571  	future.FutureAPI = &azf
   572  	future.Result = future.result
   573  	return
   574  }
   575  
   576  // RefreshProviderResponder handles the response to the RefreshProvider request. The method always
   577  // closes the http.Response Body.
   578  func (client ReplicationRecoveryServicesProvidersClient) RefreshProviderResponder(resp *http.Response) (result RecoveryServicesProvider, err error) {
   579  	err = autorest.Respond(
   580  		resp,
   581  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   582  		autorest.ByUnmarshallingJSON(&result),
   583  		autorest.ByClosing())
   584  	result.Response = autorest.Response{Response: resp}
   585  	return
   586  }
   587  

View as plain text