...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-07-01/backup/protectioncontainerrefreshoperationresults.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-07-01/backup

     1  package backup
     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  // ProtectionContainerRefreshOperationResultsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type ProtectionContainerRefreshOperationResultsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewProtectionContainerRefreshOperationResultsClient creates an instance of the
    23  // ProtectionContainerRefreshOperationResultsClient client.
    24  func NewProtectionContainerRefreshOperationResultsClient(subscriptionID string) ProtectionContainerRefreshOperationResultsClient {
    25  	return NewProtectionContainerRefreshOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewProtectionContainerRefreshOperationResultsClientWithBaseURI creates an instance of the
    29  // ProtectionContainerRefreshOperationResultsClient client using a custom endpoint.  Use this when interacting with an
    30  // Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewProtectionContainerRefreshOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) ProtectionContainerRefreshOperationResultsClient {
    32  	return ProtectionContainerRefreshOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get provides the result of the refresh operation triggered by the BeginRefresh operation.
    36  // Parameters:
    37  // vaultName - the name of the recovery services vault.
    38  // resourceGroupName - the name of the resource group where the recovery services vault is present.
    39  // fabricName - fabric name associated with the container.
    40  // operationID - operation ID associated with the operation whose result needs to be fetched.
    41  func (client ProtectionContainerRefreshOperationResultsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, operationID string) (result autorest.Response, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/ProtectionContainerRefreshOperationResultsClient.Get")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response != nil {
    47  				sc = result.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, fabricName, operationID)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "backup.ProtectionContainerRefreshOperationResultsClient", "Get", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	resp, err := client.GetSender(req)
    59  	if err != nil {
    60  		result.Response = resp
    61  		err = autorest.NewErrorWithError(err, "backup.ProtectionContainerRefreshOperationResultsClient", "Get", resp, "Failure sending request")
    62  		return
    63  	}
    64  
    65  	result, err = client.GetResponder(resp)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "backup.ProtectionContainerRefreshOperationResultsClient", "Get", resp, "Failure responding to request")
    68  		return
    69  	}
    70  
    71  	return
    72  }
    73  
    74  // GetPreparer prepares the Get request.
    75  func (client ProtectionContainerRefreshOperationResultsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, operationID string) (*http.Request, error) {
    76  	pathParameters := map[string]interface{}{
    77  		"fabricName":        autorest.Encode("path", fabricName),
    78  		"operationId":       autorest.Encode("path", operationID),
    79  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    80  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    81  		"vaultName":         autorest.Encode("path", vaultName),
    82  	}
    83  
    84  	const APIVersion = "2021-07-01"
    85  	queryParameters := map[string]interface{}{
    86  		"api-version": APIVersion,
    87  	}
    88  
    89  	preparer := autorest.CreatePreparer(
    90  		autorest.AsGet(),
    91  		autorest.WithBaseURL(client.BaseURI),
    92  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/operationResults/{operationId}", pathParameters),
    93  		autorest.WithQueryParameters(queryParameters))
    94  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    95  }
    96  
    97  // GetSender sends the Get request. The method will close the
    98  // http.Response Body if it receives an error.
    99  func (client ProtectionContainerRefreshOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) {
   100  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   101  }
   102  
   103  // GetResponder handles the response to the Get request. The method always
   104  // closes the http.Response Body.
   105  func (client ProtectionContainerRefreshOperationResultsClient) GetResponder(resp *http.Response) (result autorest.Response, err error) {
   106  	err = autorest.Respond(
   107  		resp,
   108  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   109  		autorest.ByClosing())
   110  	result.Response = resp
   111  	return
   112  }
   113  

View as plain text