...

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

View as plain text