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// FeatureSupportClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 18type FeatureSupportClient struct { 19 BaseClient 20} 21 22// NewFeatureSupportClient creates an instance of the FeatureSupportClient client. 23func NewFeatureSupportClient(subscriptionID string) FeatureSupportClient { 24 return NewFeatureSupportClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewFeatureSupportClientWithBaseURI creates an instance of the FeatureSupportClient client using a custom endpoint. 28// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewFeatureSupportClientWithBaseURI(baseURI string, subscriptionID string) FeatureSupportClient { 30 return FeatureSupportClient{NewWithBaseURI(baseURI, subscriptionID)} 31} 32 33// Validate sends the validate request. 34// Parameters: 35// azureRegion - azure region to hit Api 36// parameters - feature support request object 37func (client FeatureSupportClient) Validate(ctx context.Context, azureRegion string, parameters BasicFeatureSupportRequest) (result AzureVMResourceFeatureSupportResponse, err error) { 38 if tracing.IsEnabled() { 39 ctx = tracing.StartSpan(ctx, fqdn+"/FeatureSupportClient.Validate") 40 defer func() { 41 sc := -1 42 if result.Response.Response != nil { 43 sc = result.Response.Response.StatusCode 44 } 45 tracing.EndSpan(ctx, sc, err) 46 }() 47 } 48 req, err := client.ValidatePreparer(ctx, azureRegion, parameters) 49 if err != nil { 50 err = autorest.NewErrorWithError(err, "backup.FeatureSupportClient", "Validate", nil, "Failure preparing request") 51 return 52 } 53 54 resp, err := client.ValidateSender(req) 55 if err != nil { 56 result.Response = autorest.Response{Response: resp} 57 err = autorest.NewErrorWithError(err, "backup.FeatureSupportClient", "Validate", resp, "Failure sending request") 58 return 59 } 60 61 result, err = client.ValidateResponder(resp) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "backup.FeatureSupportClient", "Validate", resp, "Failure responding to request") 64 return 65 } 66 67 return 68} 69 70// ValidatePreparer prepares the Validate request. 71func (client FeatureSupportClient) ValidatePreparer(ctx context.Context, azureRegion string, parameters BasicFeatureSupportRequest) (*http.Request, error) { 72 pathParameters := map[string]interface{}{ 73 "azureRegion": autorest.Encode("path", azureRegion), 74 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 75 } 76 77 const APIVersion = "2017-07-01" 78 queryParameters := map[string]interface{}{ 79 "api-version": APIVersion, 80 } 81 82 preparer := autorest.CreatePreparer( 83 autorest.AsContentType("application/json; charset=utf-8"), 84 autorest.AsPost(), 85 autorest.WithBaseURL(client.BaseURI), 86 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/providers/Microsoft.RecoveryServices/locations/{azureRegion}/backupValidateFeatures", pathParameters), 87 autorest.WithJSON(parameters), 88 autorest.WithQueryParameters(queryParameters)) 89 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 90} 91 92// ValidateSender sends the Validate request. The method will close the 93// http.Response Body if it receives an error. 94func (client FeatureSupportClient) ValidateSender(req *http.Request) (*http.Response, error) { 95 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 96} 97 98// ValidateResponder handles the response to the Validate request. The method always 99// closes the http.Response Body. 100func (client FeatureSupportClient) ValidateResponder(resp *http.Response) (result AzureVMResourceFeatureSupportResponse, err error) { 101 err = autorest.Respond( 102 resp, 103 azure.WithErrorUnlessStatusCode(http.StatusOK), 104 autorest.ByUnmarshallingJSON(&result), 105 autorest.ByClosing()) 106 result.Response = autorest.Response{Response: resp} 107 return 108} 109