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