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