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// SecurityPINsClient is the open API 2.0 Specs for Azure RecoveryServices Backup service 29type SecurityPINsClient struct { 30 BaseClient 31} 32 33// NewSecurityPINsClient creates an instance of the SecurityPINsClient client. 34func NewSecurityPINsClient(subscriptionID string) SecurityPINsClient { 35 return NewSecurityPINsClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewSecurityPINsClientWithBaseURI creates an instance of the SecurityPINsClient client using a custom endpoint. Use 39// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 40func NewSecurityPINsClientWithBaseURI(baseURI string, subscriptionID string) SecurityPINsClient { 41 return SecurityPINsClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// Get get the security PIN. 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. 48func (client SecurityPINsClient) Get(ctx context.Context, vaultName string, resourceGroupName string) (result TokenInformation, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/SecurityPINsClient.Get") 51 defer func() { 52 sc := -1 53 if result.Response.Response != nil { 54 sc = result.Response.Response.StatusCode 55 } 56 tracing.EndSpan(ctx, sc, err) 57 }() 58 } 59 req, err := client.GetPreparer(ctx, vaultName, resourceGroupName) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "backup.SecurityPINsClient", "Get", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.GetSender(req) 66 if err != nil { 67 result.Response = autorest.Response{Response: resp} 68 err = autorest.NewErrorWithError(err, "backup.SecurityPINsClient", "Get", resp, "Failure sending request") 69 return 70 } 71 72 result, err = client.GetResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "backup.SecurityPINsClient", "Get", resp, "Failure responding to request") 75 return 76 } 77 78 return 79} 80 81// GetPreparer prepares the Get request. 82func (client SecurityPINsClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string) (*http.Request, error) { 83 pathParameters := map[string]interface{}{ 84 "resourceGroupName": autorest.Encode("path", resourceGroupName), 85 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 86 "vaultName": autorest.Encode("path", vaultName), 87 } 88 89 const APIVersion = "2016-12-01" 90 queryParameters := map[string]interface{}{ 91 "api-version": APIVersion, 92 } 93 94 preparer := autorest.CreatePreparer( 95 autorest.AsPost(), 96 autorest.WithBaseURL(client.BaseURI), 97 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupSecurityPIN", pathParameters), 98 autorest.WithQueryParameters(queryParameters)) 99 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 100} 101 102// GetSender sends the Get request. The method will close the 103// http.Response Body if it receives an error. 104func (client SecurityPINsClient) GetSender(req *http.Request) (*http.Response, error) { 105 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 106} 107 108// GetResponder handles the response to the Get request. The method always 109// closes the http.Response Body. 110func (client SecurityPINsClient) GetResponder(resp *http.Response) (result TokenInformation, err error) { 111 err = autorest.Respond( 112 resp, 113 azure.WithErrorUnlessStatusCode(http.StatusOK), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119