1package backup 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "net/http" 25) 26 27// ExportJobsOperationResultsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 28type ExportJobsOperationResultsClient struct { 29 BaseClient 30} 31 32// NewExportJobsOperationResultsClient creates an instance of the ExportJobsOperationResultsClient client. 33func NewExportJobsOperationResultsClient(subscriptionID string) ExportJobsOperationResultsClient { 34 return NewExportJobsOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewExportJobsOperationResultsClientWithBaseURI creates an instance of the ExportJobsOperationResultsClient client. 38func NewExportJobsOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) ExportJobsOperationResultsClient { 39 return ExportJobsOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} 40} 41 42// Get gets the operation result of operation triggered by Export Jobs API. If the operation is successful, then it 43// also 44// contains URL of a Blob and a SAS key to access the same. The blob contains exported jobs in JSON serialized format. 45// Parameters: 46// vaultName - the name of the recovery services vault. 47// resourceGroupName - the name of the resource group where the recovery services vault is present. 48// operationID - operationID which represents the export job. 49func (client ExportJobsOperationResultsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, operationID string) (result OperationResultInfoBaseResource, err error) { 50 req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, operationID) 51 if err != nil { 52 err = autorest.NewErrorWithError(err, "backup.ExportJobsOperationResultsClient", "Get", nil, "Failure preparing request") 53 return 54 } 55 56 resp, err := client.GetSender(req) 57 if err != nil { 58 result.Response = autorest.Response{Response: resp} 59 err = autorest.NewErrorWithError(err, "backup.ExportJobsOperationResultsClient", "Get", resp, "Failure sending request") 60 return 61 } 62 63 result, err = client.GetResponder(resp) 64 if err != nil { 65 err = autorest.NewErrorWithError(err, "backup.ExportJobsOperationResultsClient", "Get", resp, "Failure responding to request") 66 } 67 68 return 69} 70 71// GetPreparer prepares the Get request. 72func (client ExportJobsOperationResultsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, operationID string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "operationId": autorest.Encode("path", operationID), 75 "resourceGroupName": autorest.Encode("path", resourceGroupName), 76 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 77 "vaultName": autorest.Encode("path", vaultName), 78 } 79 80 const APIVersion = "2017-07-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/operationResults/{operationId}", 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 ExportJobsOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { 96 return autorest.SendWithSender(client, req, 97 azure.DoRetryWithRegistration(client.Client)) 98} 99 100// GetResponder handles the response to the Get request. The method always 101// closes the http.Response Body. 102func (client ExportJobsOperationResultsClient) GetResponder(resp *http.Response) (result OperationResultInfoBaseResource, err error) { 103 err = autorest.Respond( 104 resp, 105 client.ByInspecting(), 106 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 107 autorest.ByUnmarshallingJSON(&result), 108 autorest.ByClosing()) 109 result.Response = autorest.Response{Response: resp} 110 return 111} 112