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 "github.com/Azure/go-autorest/tracing" 25 "net/http" 26) 27 28// ProtectionContainerOperationResultsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 29type ProtectionContainerOperationResultsClient struct { 30 BaseClient 31} 32 33// NewProtectionContainerOperationResultsClient creates an instance of the ProtectionContainerOperationResultsClient 34// client. 35func NewProtectionContainerOperationResultsClient(subscriptionID string) ProtectionContainerOperationResultsClient { 36 return NewProtectionContainerOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewProtectionContainerOperationResultsClientWithBaseURI creates an instance of the 40// ProtectionContainerOperationResultsClient client using a custom endpoint. Use this when interacting with an Azure 41// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewProtectionContainerOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) ProtectionContainerOperationResultsClient { 43 return ProtectionContainerOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// Get fetches the result of any operation on the container. 47// Parameters: 48// vaultName - the name of the recovery services vault. 49// resourceGroupName - the name of the resource group where the recovery services vault is present. 50// fabricName - fabric name associated with the container. 51// containerName - container name whose information should be fetched. 52// operationID - operation ID which represents the operation whose result needs to be fetched. 53func (client ProtectionContainerOperationResultsClient) Get(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, operationID string) (result ProtectionContainerResource, err error) { 54 if tracing.IsEnabled() { 55 ctx = tracing.StartSpan(ctx, fqdn+"/ProtectionContainerOperationResultsClient.Get") 56 defer func() { 57 sc := -1 58 if result.Response.Response != nil { 59 sc = result.Response.Response.StatusCode 60 } 61 tracing.EndSpan(ctx, sc, err) 62 }() 63 } 64 req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, operationID) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "backup.ProtectionContainerOperationResultsClient", "Get", nil, "Failure preparing request") 67 return 68 } 69 70 resp, err := client.GetSender(req) 71 if err != nil { 72 result.Response = autorest.Response{Response: resp} 73 err = autorest.NewErrorWithError(err, "backup.ProtectionContainerOperationResultsClient", "Get", resp, "Failure sending request") 74 return 75 } 76 77 result, err = client.GetResponder(resp) 78 if err != nil { 79 err = autorest.NewErrorWithError(err, "backup.ProtectionContainerOperationResultsClient", "Get", resp, "Failure responding to request") 80 return 81 } 82 83 return 84} 85 86// GetPreparer prepares the Get request. 87func (client ProtectionContainerOperationResultsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, operationID string) (*http.Request, error) { 88 pathParameters := map[string]interface{}{ 89 "containerName": autorest.Encode("path", containerName), 90 "fabricName": autorest.Encode("path", fabricName), 91 "operationId": autorest.Encode("path", operationID), 92 "resourceGroupName": autorest.Encode("path", resourceGroupName), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 "vaultName": autorest.Encode("path", vaultName), 95 } 96 97 const APIVersion = "2016-12-01" 98 queryParameters := map[string]interface{}{ 99 "api-version": APIVersion, 100 } 101 102 preparer := autorest.CreatePreparer( 103 autorest.AsGet(), 104 autorest.WithBaseURL(client.BaseURI), 105 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/operationResults/{operationId}", pathParameters), 106 autorest.WithQueryParameters(queryParameters)) 107 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 108} 109 110// GetSender sends the Get request. The method will close the 111// http.Response Body if it receives an error. 112func (client ProtectionContainerOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { 113 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 114} 115 116// GetResponder handles the response to the Get request. The method always 117// closes the http.Response Body. 118func (client ProtectionContainerOperationResultsClient) GetResponder(resp *http.Response) (result ProtectionContainerResource, err error) { 119 err = autorest.Respond( 120 resp, 121 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 122 autorest.ByUnmarshallingJSON(&result), 123 autorest.ByClosing()) 124 result.Response = autorest.Response{Response: resp} 125 return 126} 127