...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-07-10/siterecovery/replicationeligibilityresults.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  // ReplicationEligibilityResultsClient is the client for the ReplicationEligibilityResults methods of the Siterecovery
    18  // service.
    19  type ReplicationEligibilityResultsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewReplicationEligibilityResultsClient creates an instance of the ReplicationEligibilityResultsClient client.
    24  func NewReplicationEligibilityResultsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationEligibilityResultsClient {
    25  	return NewReplicationEligibilityResultsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    26  }
    27  
    28  // NewReplicationEligibilityResultsClientWithBaseURI creates an instance of the ReplicationEligibilityResultsClient
    29  // client using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI
    30  // (sovereign clouds, Azure stack).
    31  func NewReplicationEligibilityResultsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationEligibilityResultsClient {
    32  	return ReplicationEligibilityResultsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    33  }
    34  
    35  // Get validates whether a given VM can be protected or not in which case returns list of errors.
    36  // Parameters:
    37  // virtualMachineName - virtual Machine name.
    38  func (client ReplicationEligibilityResultsClient) Get(ctx context.Context, virtualMachineName string) (result ReplicationEligibilityResults, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationEligibilityResultsClient.Get")
    41  		defer func() {
    42  			sc := -1
    43  			if result.Response.Response != nil {
    44  				sc = result.Response.Response.StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	req, err := client.GetPreparer(ctx, virtualMachineName)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationEligibilityResultsClient", "Get", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	resp, err := client.GetSender(req)
    56  	if err != nil {
    57  		result.Response = autorest.Response{Response: resp}
    58  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationEligibilityResultsClient", "Get", resp, "Failure sending request")
    59  		return
    60  	}
    61  
    62  	result, err = client.GetResponder(resp)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationEligibilityResultsClient", "Get", resp, "Failure responding to request")
    65  		return
    66  	}
    67  
    68  	return
    69  }
    70  
    71  // GetPreparer prepares the Get request.
    72  func (client ReplicationEligibilityResultsClient) GetPreparer(ctx context.Context, virtualMachineName string) (*http.Request, error) {
    73  	pathParameters := map[string]interface{}{
    74  		"resourceGroupName":  autorest.Encode("path", client.ResourceGroupName),
    75  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
    76  		"virtualMachineName": autorest.Encode("path", virtualMachineName),
    77  	}
    78  
    79  	const APIVersion = "2018-07-10"
    80  	queryParameters := map[string]interface{}{
    81  		"api-version": APIVersion,
    82  	}
    83  
    84  	preparer := autorest.CreatePreparer(
    85  		autorest.AsGet(),
    86  		autorest.WithBaseURL(client.BaseURI),
    87  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/providers/Microsoft.RecoveryServices/replicationEligibilityResults/default", pathParameters),
    88  		autorest.WithQueryParameters(queryParameters))
    89  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    90  }
    91  
    92  // GetSender sends the Get request. The method will close the
    93  // http.Response Body if it receives an error.
    94  func (client ReplicationEligibilityResultsClient) GetSender(req *http.Request) (*http.Response, error) {
    95  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    96  }
    97  
    98  // GetResponder handles the response to the Get request. The method always
    99  // closes the http.Response Body.
   100  func (client ReplicationEligibilityResultsClient) GetResponder(resp *http.Response) (result ReplicationEligibilityResults, err error) {
   101  	err = autorest.Respond(
   102  		resp,
   103  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   104  		autorest.ByUnmarshallingJSON(&result),
   105  		autorest.ByClosing())
   106  	result.Response = autorest.Response{Response: resp}
   107  	return
   108  }
   109  
   110  // List validates whether a given VM can be protected or not in which case returns list of errors.
   111  // Parameters:
   112  // virtualMachineName - virtual Machine name.
   113  func (client ReplicationEligibilityResultsClient) List(ctx context.Context, virtualMachineName string) (result ReplicationEligibilityResultsCollection, err error) {
   114  	if tracing.IsEnabled() {
   115  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationEligibilityResultsClient.List")
   116  		defer func() {
   117  			sc := -1
   118  			if result.Response.Response != nil {
   119  				sc = result.Response.Response.StatusCode
   120  			}
   121  			tracing.EndSpan(ctx, sc, err)
   122  		}()
   123  	}
   124  	req, err := client.ListPreparer(ctx, virtualMachineName)
   125  	if err != nil {
   126  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationEligibilityResultsClient", "List", nil, "Failure preparing request")
   127  		return
   128  	}
   129  
   130  	resp, err := client.ListSender(req)
   131  	if err != nil {
   132  		result.Response = autorest.Response{Response: resp}
   133  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationEligibilityResultsClient", "List", resp, "Failure sending request")
   134  		return
   135  	}
   136  
   137  	result, err = client.ListResponder(resp)
   138  	if err != nil {
   139  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationEligibilityResultsClient", "List", resp, "Failure responding to request")
   140  		return
   141  	}
   142  
   143  	return
   144  }
   145  
   146  // ListPreparer prepares the List request.
   147  func (client ReplicationEligibilityResultsClient) ListPreparer(ctx context.Context, virtualMachineName string) (*http.Request, error) {
   148  	pathParameters := map[string]interface{}{
   149  		"resourceGroupName":  autorest.Encode("path", client.ResourceGroupName),
   150  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
   151  		"virtualMachineName": autorest.Encode("path", virtualMachineName),
   152  	}
   153  
   154  	const APIVersion = "2018-07-10"
   155  	queryParameters := map[string]interface{}{
   156  		"api-version": APIVersion,
   157  	}
   158  
   159  	preparer := autorest.CreatePreparer(
   160  		autorest.AsGet(),
   161  		autorest.WithBaseURL(client.BaseURI),
   162  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/providers/Microsoft.RecoveryServices/replicationEligibilityResults", pathParameters),
   163  		autorest.WithQueryParameters(queryParameters))
   164  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   165  }
   166  
   167  // ListSender sends the List request. The method will close the
   168  // http.Response Body if it receives an error.
   169  func (client ReplicationEligibilityResultsClient) ListSender(req *http.Request) (*http.Response, error) {
   170  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   171  }
   172  
   173  // ListResponder handles the response to the List request. The method always
   174  // closes the http.Response Body.
   175  func (client ReplicationEligibilityResultsClient) ListResponder(resp *http.Response) (result ReplicationEligibilityResultsCollection, err error) {
   176  	err = autorest.Respond(
   177  		resp,
   178  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   179  		autorest.ByUnmarshallingJSON(&result),
   180  		autorest.ByClosing())
   181  	result.Response = autorest.Response{Response: resp}
   182  	return
   183  }
   184  

View as plain text