...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2022-03-01/backup/securitypins.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2022-03-01/backup

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

View as plain text