...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery/replicationvaulthealth.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  // ReplicationVaultHealthClient is the client for the ReplicationVaultHealth methods of the Siterecovery service.
    18  type ReplicationVaultHealthClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewReplicationVaultHealthClient creates an instance of the ReplicationVaultHealthClient client.
    23  func NewReplicationVaultHealthClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationVaultHealthClient {
    24  	return NewReplicationVaultHealthClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    25  }
    26  
    27  // NewReplicationVaultHealthClientWithBaseURI creates an instance of the ReplicationVaultHealthClient 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 NewReplicationVaultHealthClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationVaultHealthClient {
    31  	return ReplicationVaultHealthClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    32  }
    33  
    34  // Get gets the health details of the vault.
    35  func (client ReplicationVaultHealthClient) Get(ctx context.Context) (result VaultHealthDetails, err error) {
    36  	if tracing.IsEnabled() {
    37  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationVaultHealthClient.Get")
    38  		defer func() {
    39  			sc := -1
    40  			if result.Response.Response != nil {
    41  				sc = result.Response.Response.StatusCode
    42  			}
    43  			tracing.EndSpan(ctx, sc, err)
    44  		}()
    45  	}
    46  	req, err := client.GetPreparer(ctx)
    47  	if err != nil {
    48  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationVaultHealthClient", "Get", nil, "Failure preparing request")
    49  		return
    50  	}
    51  
    52  	resp, err := client.GetSender(req)
    53  	if err != nil {
    54  		result.Response = autorest.Response{Response: resp}
    55  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationVaultHealthClient", "Get", resp, "Failure sending request")
    56  		return
    57  	}
    58  
    59  	result, err = client.GetResponder(resp)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationVaultHealthClient", "Get", resp, "Failure responding to request")
    62  		return
    63  	}
    64  
    65  	return
    66  }
    67  
    68  // GetPreparer prepares the Get request.
    69  func (client ReplicationVaultHealthClient) GetPreparer(ctx context.Context) (*http.Request, error) {
    70  	pathParameters := map[string]interface{}{
    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 = "2018-01-10"
    77  	queryParameters := map[string]interface{}{
    78  		"api-version": APIVersion,
    79  	}
    80  
    81  	preparer := autorest.CreatePreparer(
    82  		autorest.AsGet(),
    83  		autorest.WithBaseURL(client.BaseURI),
    84  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationVaultHealth", pathParameters),
    85  		autorest.WithQueryParameters(queryParameters))
    86  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    87  }
    88  
    89  // GetSender sends the Get request. The method will close the
    90  // http.Response Body if it receives an error.
    91  func (client ReplicationVaultHealthClient) GetSender(req *http.Request) (*http.Response, error) {
    92  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    93  }
    94  
    95  // GetResponder handles the response to the Get request. The method always
    96  // closes the http.Response Body.
    97  func (client ReplicationVaultHealthClient) GetResponder(resp *http.Response) (result VaultHealthDetails, err error) {
    98  	err = autorest.Respond(
    99  		resp,
   100  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   101  		autorest.ByUnmarshallingJSON(&result),
   102  		autorest.ByClosing())
   103  	result.Response = autorest.Response{Response: resp}
   104  	return
   105  }
   106  
   107  // Refresh sends the refresh request.
   108  func (client ReplicationVaultHealthClient) Refresh(ctx context.Context) (result ReplicationVaultHealthRefreshFuture, err error) {
   109  	if tracing.IsEnabled() {
   110  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationVaultHealthClient.Refresh")
   111  		defer func() {
   112  			sc := -1
   113  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   114  				sc = result.FutureAPI.Response().StatusCode
   115  			}
   116  			tracing.EndSpan(ctx, sc, err)
   117  		}()
   118  	}
   119  	req, err := client.RefreshPreparer(ctx)
   120  	if err != nil {
   121  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationVaultHealthClient", "Refresh", nil, "Failure preparing request")
   122  		return
   123  	}
   124  
   125  	result, err = client.RefreshSender(req)
   126  	if err != nil {
   127  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationVaultHealthClient", "Refresh", result.Response(), "Failure sending request")
   128  		return
   129  	}
   130  
   131  	return
   132  }
   133  
   134  // RefreshPreparer prepares the Refresh request.
   135  func (client ReplicationVaultHealthClient) RefreshPreparer(ctx context.Context) (*http.Request, error) {
   136  	pathParameters := map[string]interface{}{
   137  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   138  		"resourceName":      autorest.Encode("path", client.ResourceName),
   139  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   140  	}
   141  
   142  	const APIVersion = "2018-01-10"
   143  	queryParameters := map[string]interface{}{
   144  		"api-version": APIVersion,
   145  	}
   146  
   147  	preparer := autorest.CreatePreparer(
   148  		autorest.AsPost(),
   149  		autorest.WithBaseURL(client.BaseURI),
   150  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationVaultHealth/default/refresh", pathParameters),
   151  		autorest.WithQueryParameters(queryParameters))
   152  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   153  }
   154  
   155  // RefreshSender sends the Refresh request. The method will close the
   156  // http.Response Body if it receives an error.
   157  func (client ReplicationVaultHealthClient) RefreshSender(req *http.Request) (future ReplicationVaultHealthRefreshFuture, err error) {
   158  	var resp *http.Response
   159  	future.FutureAPI = &azure.Future{}
   160  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   161  	if err != nil {
   162  		return
   163  	}
   164  	var azf azure.Future
   165  	azf, err = azure.NewFutureFromResponse(resp)
   166  	future.FutureAPI = &azf
   167  	future.Result = future.result
   168  	return
   169  }
   170  
   171  // RefreshResponder handles the response to the Refresh request. The method always
   172  // closes the http.Response Body.
   173  func (client ReplicationVaultHealthClient) RefreshResponder(resp *http.Response) (result VaultHealthDetails, err error) {
   174  	err = autorest.Respond(
   175  		resp,
   176  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   177  		autorest.ByUnmarshallingJSON(&result),
   178  		autorest.ByClosing())
   179  	result.Response = autorest.Response{Response: resp}
   180  	return
   181  }
   182  

View as plain text