...

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

View as plain text