...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2022-03-01/backup/privateendpoint.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  // PrivateEndpointClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type PrivateEndpointClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewPrivateEndpointClient creates an instance of the PrivateEndpointClient client.
    23  func NewPrivateEndpointClient(subscriptionID string) PrivateEndpointClient {
    24  	return NewPrivateEndpointClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewPrivateEndpointClientWithBaseURI creates an instance of the PrivateEndpointClient 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).
    29  func NewPrivateEndpointClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointClient {
    30  	return PrivateEndpointClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // GetOperationStatus sends the get operation status request.
    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  // privateEndpointConnectionName - the name of the private endpoint connection.
    38  // operationID - operation id
    39  func (client PrivateEndpointClient) GetOperationStatus(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string, operationID string) (result OperationStatus, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointClient.GetOperationStatus")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response.Response != nil {
    45  				sc = result.Response.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	req, err := client.GetOperationStatusPreparer(ctx, vaultName, resourceGroupName, privateEndpointConnectionName, operationID)
    51  	if err != nil {
    52  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointClient", "GetOperationStatus", nil, "Failure preparing request")
    53  		return
    54  	}
    55  
    56  	resp, err := client.GetOperationStatusSender(req)
    57  	if err != nil {
    58  		result.Response = autorest.Response{Response: resp}
    59  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointClient", "GetOperationStatus", resp, "Failure sending request")
    60  		return
    61  	}
    62  
    63  	result, err = client.GetOperationStatusResponder(resp)
    64  	if err != nil {
    65  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointClient", "GetOperationStatus", resp, "Failure responding to request")
    66  		return
    67  	}
    68  
    69  	return
    70  }
    71  
    72  // GetOperationStatusPreparer prepares the GetOperationStatus request.
    73  func (client PrivateEndpointClient) GetOperationStatusPreparer(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string, operationID string) (*http.Request, error) {
    74  	pathParameters := map[string]interface{}{
    75  		"operationId":                   autorest.Encode("path", operationID),
    76  		"privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName),
    77  		"resourceGroupName":             autorest.Encode("path", resourceGroupName),
    78  		"subscriptionId":                autorest.Encode("path", client.SubscriptionID),
    79  		"vaultName":                     autorest.Encode("path", vaultName),
    80  	}
    81  
    82  	const APIVersion = "2022-03-01"
    83  	queryParameters := map[string]interface{}{
    84  		"api-version": APIVersion,
    85  	}
    86  
    87  	preparer := autorest.CreatePreparer(
    88  		autorest.AsGet(),
    89  		autorest.WithBaseURL(client.BaseURI),
    90  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}/operationsStatus/{operationId}", pathParameters),
    91  		autorest.WithQueryParameters(queryParameters))
    92  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    93  }
    94  
    95  // GetOperationStatusSender sends the GetOperationStatus request. The method will close the
    96  // http.Response Body if it receives an error.
    97  func (client PrivateEndpointClient) GetOperationStatusSender(req *http.Request) (*http.Response, error) {
    98  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    99  }
   100  
   101  // GetOperationStatusResponder handles the response to the GetOperationStatus request. The method always
   102  // closes the http.Response Body.
   103  func (client PrivateEndpointClient) GetOperationStatusResponder(resp *http.Response) (result OperationStatus, err error) {
   104  	err = autorest.Respond(
   105  		resp,
   106  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   107  		autorest.ByUnmarshallingJSON(&result),
   108  		autorest.ByClosing())
   109  	result.Response = autorest.Response{Response: resp}
   110  	return
   111  }
   112  

View as plain text