...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-07-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  // MigrationRecoveryPointsClient is the client for the MigrationRecoveryPoints methods of the Siterecovery service.
    18  type MigrationRecoveryPointsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewMigrationRecoveryPointsClient creates an instance of the MigrationRecoveryPointsClient client.
    23  func NewMigrationRecoveryPointsClient(subscriptionID string, resourceGroupName string, resourceName string) MigrationRecoveryPointsClient {
    24  	return NewMigrationRecoveryPointsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    25  }
    26  
    27  // NewMigrationRecoveryPointsClientWithBaseURI creates an instance of the MigrationRecoveryPointsClient client using a
    28  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    29  // Azure stack).
    30  func NewMigrationRecoveryPointsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) MigrationRecoveryPointsClient {
    31  	return MigrationRecoveryPointsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    32  }
    33  
    34  // Get sends the get request.
    35  // Parameters:
    36  // fabricName - fabric unique name.
    37  // protectionContainerName - protection container name.
    38  // migrationItemName - migration item name.
    39  // migrationRecoveryPointName - the migration recovery point name.
    40  func (client MigrationRecoveryPointsClient) Get(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, migrationRecoveryPointName string) (result MigrationRecoveryPoint, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/MigrationRecoveryPointsClient.Get")
    43  		defer func() {
    44  			sc := -1
    45  			if result.Response.Response != nil {
    46  				sc = result.Response.Response.StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	req, err := client.GetPreparer(ctx, fabricName, protectionContainerName, migrationItemName, migrationRecoveryPointName)
    52  	if err != nil {
    53  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "Get", nil, "Failure preparing request")
    54  		return
    55  	}
    56  
    57  	resp, err := client.GetSender(req)
    58  	if err != nil {
    59  		result.Response = autorest.Response{Response: resp}
    60  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "Get", resp, "Failure sending request")
    61  		return
    62  	}
    63  
    64  	result, err = client.GetResponder(resp)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "Get", resp, "Failure responding to request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // GetPreparer prepares the Get request.
    74  func (client MigrationRecoveryPointsClient) GetPreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string, migrationRecoveryPointName string) (*http.Request, error) {
    75  	pathParameters := map[string]interface{}{
    76  		"fabricName":                 autorest.Encode("path", fabricName),
    77  		"migrationItemName":          autorest.Encode("path", migrationItemName),
    78  		"migrationRecoveryPointName": autorest.Encode("path", migrationRecoveryPointName),
    79  		"protectionContainerName":    autorest.Encode("path", protectionContainerName),
    80  		"resourceGroupName":          autorest.Encode("path", client.ResourceGroupName),
    81  		"resourceName":               autorest.Encode("path", client.ResourceName),
    82  		"subscriptionId":             autorest.Encode("path", client.SubscriptionID),
    83  	}
    84  
    85  	const APIVersion = "2018-07-10"
    86  	queryParameters := map[string]interface{}{
    87  		"api-version": APIVersion,
    88  	}
    89  
    90  	preparer := autorest.CreatePreparer(
    91  		autorest.AsGet(),
    92  		autorest.WithBaseURL(client.BaseURI),
    93  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}/migrationRecoveryPoints/{migrationRecoveryPointName}", pathParameters),
    94  		autorest.WithQueryParameters(queryParameters))
    95  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    96  }
    97  
    98  // GetSender sends the Get request. The method will close the
    99  // http.Response Body if it receives an error.
   100  func (client MigrationRecoveryPointsClient) GetSender(req *http.Request) (*http.Response, error) {
   101  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   102  }
   103  
   104  // GetResponder handles the response to the Get request. The method always
   105  // closes the http.Response Body.
   106  func (client MigrationRecoveryPointsClient) GetResponder(resp *http.Response) (result MigrationRecoveryPoint, err error) {
   107  	err = autorest.Respond(
   108  		resp,
   109  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   110  		autorest.ByUnmarshallingJSON(&result),
   111  		autorest.ByClosing())
   112  	result.Response = autorest.Response{Response: resp}
   113  	return
   114  }
   115  
   116  // ListByReplicationMigrationItems sends the list by replication migration items request.
   117  // Parameters:
   118  // fabricName - fabric unique name.
   119  // protectionContainerName - protection container name.
   120  // migrationItemName - migration item name.
   121  func (client MigrationRecoveryPointsClient) ListByReplicationMigrationItems(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string) (result MigrationRecoveryPointCollectionPage, err error) {
   122  	if tracing.IsEnabled() {
   123  		ctx = tracing.StartSpan(ctx, fqdn+"/MigrationRecoveryPointsClient.ListByReplicationMigrationItems")
   124  		defer func() {
   125  			sc := -1
   126  			if result.mrpc.Response.Response != nil {
   127  				sc = result.mrpc.Response.Response.StatusCode
   128  			}
   129  			tracing.EndSpan(ctx, sc, err)
   130  		}()
   131  	}
   132  	result.fn = client.listByReplicationMigrationItemsNextResults
   133  	req, err := client.ListByReplicationMigrationItemsPreparer(ctx, fabricName, protectionContainerName, migrationItemName)
   134  	if err != nil {
   135  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "ListByReplicationMigrationItems", nil, "Failure preparing request")
   136  		return
   137  	}
   138  
   139  	resp, err := client.ListByReplicationMigrationItemsSender(req)
   140  	if err != nil {
   141  		result.mrpc.Response = autorest.Response{Response: resp}
   142  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "ListByReplicationMigrationItems", resp, "Failure sending request")
   143  		return
   144  	}
   145  
   146  	result.mrpc, err = client.ListByReplicationMigrationItemsResponder(resp)
   147  	if err != nil {
   148  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "ListByReplicationMigrationItems", resp, "Failure responding to request")
   149  		return
   150  	}
   151  	if result.mrpc.hasNextLink() && result.mrpc.IsEmpty() {
   152  		err = result.NextWithContext(ctx)
   153  		return
   154  	}
   155  
   156  	return
   157  }
   158  
   159  // ListByReplicationMigrationItemsPreparer prepares the ListByReplicationMigrationItems request.
   160  func (client MigrationRecoveryPointsClient) ListByReplicationMigrationItemsPreparer(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string) (*http.Request, error) {
   161  	pathParameters := map[string]interface{}{
   162  		"fabricName":              autorest.Encode("path", fabricName),
   163  		"migrationItemName":       autorest.Encode("path", migrationItemName),
   164  		"protectionContainerName": autorest.Encode("path", protectionContainerName),
   165  		"resourceGroupName":       autorest.Encode("path", client.ResourceGroupName),
   166  		"resourceName":            autorest.Encode("path", client.ResourceName),
   167  		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
   168  	}
   169  
   170  	const APIVersion = "2018-07-10"
   171  	queryParameters := map[string]interface{}{
   172  		"api-version": APIVersion,
   173  	}
   174  
   175  	preparer := autorest.CreatePreparer(
   176  		autorest.AsGet(),
   177  		autorest.WithBaseURL(client.BaseURI),
   178  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationMigrationItems/{migrationItemName}/migrationRecoveryPoints", pathParameters),
   179  		autorest.WithQueryParameters(queryParameters))
   180  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   181  }
   182  
   183  // ListByReplicationMigrationItemsSender sends the ListByReplicationMigrationItems request. The method will close the
   184  // http.Response Body if it receives an error.
   185  func (client MigrationRecoveryPointsClient) ListByReplicationMigrationItemsSender(req *http.Request) (*http.Response, error) {
   186  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   187  }
   188  
   189  // ListByReplicationMigrationItemsResponder handles the response to the ListByReplicationMigrationItems request. The method always
   190  // closes the http.Response Body.
   191  func (client MigrationRecoveryPointsClient) ListByReplicationMigrationItemsResponder(resp *http.Response) (result MigrationRecoveryPointCollection, err error) {
   192  	err = autorest.Respond(
   193  		resp,
   194  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   195  		autorest.ByUnmarshallingJSON(&result),
   196  		autorest.ByClosing())
   197  	result.Response = autorest.Response{Response: resp}
   198  	return
   199  }
   200  
   201  // listByReplicationMigrationItemsNextResults retrieves the next set of results, if any.
   202  func (client MigrationRecoveryPointsClient) listByReplicationMigrationItemsNextResults(ctx context.Context, lastResults MigrationRecoveryPointCollection) (result MigrationRecoveryPointCollection, err error) {
   203  	req, err := lastResults.migrationRecoveryPointCollectionPreparer(ctx)
   204  	if err != nil {
   205  		return result, autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "listByReplicationMigrationItemsNextResults", nil, "Failure preparing next results request")
   206  	}
   207  	if req == nil {
   208  		return
   209  	}
   210  	resp, err := client.ListByReplicationMigrationItemsSender(req)
   211  	if err != nil {
   212  		result.Response = autorest.Response{Response: resp}
   213  		return result, autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "listByReplicationMigrationItemsNextResults", resp, "Failure sending next results request")
   214  	}
   215  	result, err = client.ListByReplicationMigrationItemsResponder(resp)
   216  	if err != nil {
   217  		err = autorest.NewErrorWithError(err, "siterecovery.MigrationRecoveryPointsClient", "listByReplicationMigrationItemsNextResults", resp, "Failure responding to next results request")
   218  	}
   219  	return
   220  }
   221  
   222  // ListByReplicationMigrationItemsComplete enumerates all values, automatically crossing page boundaries as required.
   223  func (client MigrationRecoveryPointsClient) ListByReplicationMigrationItemsComplete(ctx context.Context, fabricName string, protectionContainerName string, migrationItemName string) (result MigrationRecoveryPointCollectionIterator, err error) {
   224  	if tracing.IsEnabled() {
   225  		ctx = tracing.StartSpan(ctx, fqdn+"/MigrationRecoveryPointsClient.ListByReplicationMigrationItems")
   226  		defer func() {
   227  			sc := -1
   228  			if result.Response().Response.Response != nil {
   229  				sc = result.page.Response().Response.Response.StatusCode
   230  			}
   231  			tracing.EndSpan(ctx, sc, err)
   232  		}()
   233  	}
   234  	result.page, err = client.ListByReplicationMigrationItems(ctx, fabricName, protectionContainerName, migrationItemName)
   235  	return
   236  }
   237  

View as plain text