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// OperationStatusesClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 28type OperationStatusesClient struct { 29 BaseClient 30} 31 32// NewOperationStatusesClient creates an instance of the OperationStatusesClient client. 33func NewOperationStatusesClient(subscriptionID string) OperationStatusesClient { 34 return NewOperationStatusesClientWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewOperationStatusesClientWithBaseURI creates an instance of the OperationStatusesClient client. 38func NewOperationStatusesClientWithBaseURI(baseURI string, subscriptionID string) OperationStatusesClient { 39 return OperationStatusesClient{NewWithBaseURI(baseURI, subscriptionID)} 40} 41 42// Get fetches the status of an operation such as triggering a backup, restore. The status can be in progress, 43// completed 44// or failed. You can refer to the OperationStatus enum for all the possible states of an operation. Some operations 45// create jobs. This method returns the list of jobs when the operation is complete. 46// Parameters: 47// vaultName - the name of the recovery services vault. 48// resourceGroupName - the name of the resource group where the recovery services vault is present. 49// operationID - operationID which represents the operation. 50func (client OperationStatusesClient) Get(ctx context.Context, vaultName string, resourceGroupName string, operationID string) (result OperationStatus, err error) { 51 req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, operationID) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "backup.OperationStatusesClient", "Get", nil, "Failure preparing request") 54 return 55 } 56 57 resp, err := client.GetSender(req) 58 if err != nil { 59 result.Response = autorest.Response{Response: resp} 60 err = autorest.NewErrorWithError(err, "backup.OperationStatusesClient", "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.OperationStatusesClient", "Get", resp, "Failure responding to request") 67 } 68 69 return 70} 71 72// GetPreparer prepares the Get request. 73func (client OperationStatusesClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, operationID string) (*http.Request, error) { 74 pathParameters := map[string]interface{}{ 75 "operationId": autorest.Encode("path", operationID), 76 "resourceGroupName": autorest.Encode("path", resourceGroupName), 77 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 78 "vaultName": autorest.Encode("path", vaultName), 79 } 80 81 const APIVersion = "2016-12-01" 82 queryParameters := map[string]interface{}{ 83 "api-version": APIVersion, 84 } 85 86 preparer := autorest.CreatePreparer( 87 autorest.AsGet(), 88 autorest.WithBaseURL(client.BaseURI), 89 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupOperations/{operationId}", pathParameters), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// GetSender sends the Get request. The method will close the 95// http.Response Body if it receives an error. 96func (client OperationStatusesClient) GetSender(req *http.Request) (*http.Response, error) { 97 return autorest.SendWithSender(client, req, 98 azure.DoRetryWithRegistration(client.Client)) 99} 100 101// GetResponder handles the response to the Get request. The method always 102// closes the http.Response Body. 103func (client OperationStatusesClient) GetResponder(resp *http.Response) (result OperationStatus, err error) { 104 err = autorest.Respond( 105 resp, 106 client.ByInspecting(), 107 azure.WithErrorUnlessStatusCode(http.StatusOK), 108 autorest.ByUnmarshallingJSON(&result), 109 autorest.ByClosing()) 110 result.Response = autorest.Response{Response: resp} 111 return 112} 113