1package 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 9import ( 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// ProtectionContainerOperationResultsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 18type ProtectionContainerOperationResultsClient struct { 19 BaseClient 20} 21 22// NewProtectionContainerOperationResultsClient creates an instance of the ProtectionContainerOperationResultsClient 23// client. 24func NewProtectionContainerOperationResultsClient(subscriptionID string) ProtectionContainerOperationResultsClient { 25 return NewProtectionContainerOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewProtectionContainerOperationResultsClientWithBaseURI creates an instance of the 29// ProtectionContainerOperationResultsClient client using a custom endpoint. Use this when interacting with an Azure 30// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewProtectionContainerOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) ProtectionContainerOperationResultsClient { 32 return ProtectionContainerOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Get fetches the result of any operation on the container. 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// containerName - container name whose information should be fetched. 41// operationID - operation ID which represents the operation whose result needs to be fetched. 42func (client ProtectionContainerOperationResultsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, operationID string) (result ProtectionContainerResource, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/ProtectionContainerOperationResultsClient.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, operationID) 54 if err != nil { 55 err = autorest.NewErrorWithError(err, "backup.ProtectionContainerOperationResultsClient", "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.ProtectionContainerOperationResultsClient", "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.ProtectionContainerOperationResultsClient", "Get", resp, "Failure responding to request") 69 return 70 } 71 72 return 73} 74 75// GetPreparer prepares the Get request. 76func (client ProtectionContainerOperationResultsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName 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 "resourceGroupName": autorest.Encode("path", resourceGroupName), 82 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 83 "vaultName": autorest.Encode("path", vaultName), 84 } 85 86 const APIVersion = "2021-01-01" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsGet(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/operationResults/{operationId}", pathParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// GetSender sends the Get request. The method will close the 100// http.Response Body if it receives an error. 101func (client ProtectionContainerOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { 102 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 103} 104 105// GetResponder handles the response to the Get request. The method always 106// closes the http.Response Body. 107func (client ProtectionContainerOperationResultsClient) GetResponder(resp *http.Response) (result ProtectionContainerResource, err error) { 108 err = autorest.Respond( 109 resp, 110 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 111 autorest.ByUnmarshallingJSON(&result), 112 autorest.ByClosing()) 113 result.Response = autorest.Response{Response: resp} 114 return 115} 116