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// JobOperationResultsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 18type JobOperationResultsClient struct { 19 BaseClient 20} 21 22// NewJobOperationResultsClient creates an instance of the JobOperationResultsClient client. 23func NewJobOperationResultsClient(subscriptionID string) JobOperationResultsClient { 24 return NewJobOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewJobOperationResultsClientWithBaseURI creates an instance of the JobOperationResultsClient 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 NewJobOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) JobOperationResultsClient { 31 return JobOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Get fetches the result of any operation. 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// jobName - job name whose operation result has to be fetched. 39// operationID - operationID which represents the operation whose result has to be fetched. 40func (client JobOperationResultsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, jobName string, operationID string) (result autorest.Response, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/JobOperationResultsClient.Get") 43 defer func() { 44 sc := -1 45 if result.Response != nil { 46 sc = result.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, jobName, operationID) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "backup.JobOperationResultsClient", "Get", nil, "Failure preparing request") 54 return 55 } 56 57 resp, err := client.GetSender(req) 58 if err != nil { 59 result.Response = resp 60 err = autorest.NewErrorWithError(err, "backup.JobOperationResultsClient", "Get", resp, "Failure sending request") 61 return 62 } 63 64 result, err = client.GetResponder(resp) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "backup.JobOperationResultsClient", "Get", resp, "Failure responding to request") 67 return 68 } 69 70 return 71} 72 73// GetPreparer prepares the Get request. 74func (client JobOperationResultsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, jobName string, operationID string) (*http.Request, error) { 75 pathParameters := map[string]interface{}{ 76 "jobName": autorest.Encode("path", jobName), 77 "operationId": autorest.Encode("path", operationID), 78 "resourceGroupName": autorest.Encode("path", resourceGroupName), 79 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 80 "vaultName": autorest.Encode("path", vaultName), 81 } 82 83 const APIVersion = "2019-06-15" 84 queryParameters := map[string]interface{}{ 85 "api-version": APIVersion, 86 } 87 88 preparer := autorest.CreatePreparer( 89 autorest.AsGet(), 90 autorest.WithBaseURL(client.BaseURI), 91 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupJobs/{jobName}/operationResults/{operationId}", pathParameters), 92 autorest.WithQueryParameters(queryParameters)) 93 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 94} 95 96// GetSender sends the Get request. The method will close the 97// http.Response Body if it receives an error. 98func (client JobOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { 99 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 100} 101 102// GetResponder handles the response to the Get request. The method always 103// closes the http.Response Body. 104func (client JobOperationResultsClient) GetResponder(resp *http.Response) (result autorest.Response, err error) { 105 err = autorest.Respond( 106 resp, 107 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 108 autorest.ByClosing()) 109 result.Response = resp 110 return 111} 112