...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-07-01/backup/privateendpointconnection.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-07-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  // PrivateEndpointConnectionClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type PrivateEndpointConnectionClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewPrivateEndpointConnectionClient creates an instance of the PrivateEndpointConnectionClient client.
    23  func NewPrivateEndpointConnectionClient(subscriptionID string) PrivateEndpointConnectionClient {
    24  	return NewPrivateEndpointConnectionClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewPrivateEndpointConnectionClientWithBaseURI creates an instance of the PrivateEndpointConnectionClient client
    28  // using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
    29  // clouds, Azure stack).
    30  func NewPrivateEndpointConnectionClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionClient {
    31  	return PrivateEndpointConnectionClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Delete delete Private Endpoint requests. This call is made by Backup Admin.
    35  // Parameters:
    36  // vaultName - the name of the recovery services vault.
    37  // resourceGroupName - the name of the resource group where the recovery services vault is present.
    38  // privateEndpointConnectionName - the name of the private endpoint connection.
    39  func (client PrivateEndpointConnectionClient) Delete(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionDeleteFuture, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionClient.Delete")
    42  		defer func() {
    43  			sc := -1
    44  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    45  				sc = result.FutureAPI.Response().StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	req, err := client.DeletePreparer(ctx, vaultName, resourceGroupName, privateEndpointConnectionName)
    51  	if err != nil {
    52  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Delete", nil, "Failure preparing request")
    53  		return
    54  	}
    55  
    56  	result, err = client.DeleteSender(req)
    57  	if err != nil {
    58  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Delete", result.Response(), "Failure sending request")
    59  		return
    60  	}
    61  
    62  	return
    63  }
    64  
    65  // DeletePreparer prepares the Delete request.
    66  func (client PrivateEndpointConnectionClient) DeletePreparer(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string) (*http.Request, error) {
    67  	pathParameters := map[string]interface{}{
    68  		"privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName),
    69  		"resourceGroupName":             autorest.Encode("path", resourceGroupName),
    70  		"subscriptionId":                autorest.Encode("path", client.SubscriptionID),
    71  		"vaultName":                     autorest.Encode("path", vaultName),
    72  	}
    73  
    74  	const APIVersion = "2021-07-01"
    75  	queryParameters := map[string]interface{}{
    76  		"api-version": APIVersion,
    77  	}
    78  
    79  	preparer := autorest.CreatePreparer(
    80  		autorest.AsDelete(),
    81  		autorest.WithBaseURL(client.BaseURI),
    82  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters),
    83  		autorest.WithQueryParameters(queryParameters))
    84  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    85  }
    86  
    87  // DeleteSender sends the Delete request. The method will close the
    88  // http.Response Body if it receives an error.
    89  func (client PrivateEndpointConnectionClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionDeleteFuture, err error) {
    90  	var resp *http.Response
    91  	future.FutureAPI = &azure.Future{}
    92  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    93  	if err != nil {
    94  		return
    95  	}
    96  	var azf azure.Future
    97  	azf, err = azure.NewFutureFromResponse(resp)
    98  	future.FutureAPI = &azf
    99  	future.Result = future.result
   100  	return
   101  }
   102  
   103  // DeleteResponder handles the response to the Delete request. The method always
   104  // closes the http.Response Body.
   105  func (client PrivateEndpointConnectionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   106  	err = autorest.Respond(
   107  		resp,
   108  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   109  		autorest.ByClosing())
   110  	result.Response = resp
   111  	return
   112  }
   113  
   114  // Get get Private Endpoint Connection. This call is made by Backup Admin.
   115  // Parameters:
   116  // vaultName - the name of the recovery services vault.
   117  // resourceGroupName - the name of the resource group where the recovery services vault is present.
   118  // privateEndpointConnectionName - the name of the private endpoint connection.
   119  func (client PrivateEndpointConnectionClient) Get(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionResource, err error) {
   120  	if tracing.IsEnabled() {
   121  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionClient.Get")
   122  		defer func() {
   123  			sc := -1
   124  			if result.Response.Response != nil {
   125  				sc = result.Response.Response.StatusCode
   126  			}
   127  			tracing.EndSpan(ctx, sc, err)
   128  		}()
   129  	}
   130  	req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, privateEndpointConnectionName)
   131  	if err != nil {
   132  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Get", nil, "Failure preparing request")
   133  		return
   134  	}
   135  
   136  	resp, err := client.GetSender(req)
   137  	if err != nil {
   138  		result.Response = autorest.Response{Response: resp}
   139  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Get", resp, "Failure sending request")
   140  		return
   141  	}
   142  
   143  	result, err = client.GetResponder(resp)
   144  	if err != nil {
   145  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Get", resp, "Failure responding to request")
   146  		return
   147  	}
   148  
   149  	return
   150  }
   151  
   152  // GetPreparer prepares the Get request.
   153  func (client PrivateEndpointConnectionClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string) (*http.Request, error) {
   154  	pathParameters := map[string]interface{}{
   155  		"privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName),
   156  		"resourceGroupName":             autorest.Encode("path", resourceGroupName),
   157  		"subscriptionId":                autorest.Encode("path", client.SubscriptionID),
   158  		"vaultName":                     autorest.Encode("path", vaultName),
   159  	}
   160  
   161  	const APIVersion = "2021-07-01"
   162  	queryParameters := map[string]interface{}{
   163  		"api-version": APIVersion,
   164  	}
   165  
   166  	preparer := autorest.CreatePreparer(
   167  		autorest.AsGet(),
   168  		autorest.WithBaseURL(client.BaseURI),
   169  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters),
   170  		autorest.WithQueryParameters(queryParameters))
   171  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   172  }
   173  
   174  // GetSender sends the Get request. The method will close the
   175  // http.Response Body if it receives an error.
   176  func (client PrivateEndpointConnectionClient) GetSender(req *http.Request) (*http.Response, error) {
   177  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   178  }
   179  
   180  // GetResponder handles the response to the Get request. The method always
   181  // closes the http.Response Body.
   182  func (client PrivateEndpointConnectionClient) GetResponder(resp *http.Response) (result PrivateEndpointConnectionResource, err error) {
   183  	err = autorest.Respond(
   184  		resp,
   185  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   186  		autorest.ByUnmarshallingJSON(&result),
   187  		autorest.ByClosing())
   188  	result.Response = autorest.Response{Response: resp}
   189  	return
   190  }
   191  
   192  // Put approve or Reject Private Endpoint requests. This call is made by Backup Admin.
   193  // Parameters:
   194  // vaultName - the name of the recovery services vault.
   195  // resourceGroupName - the name of the resource group where the recovery services vault is present.
   196  // privateEndpointConnectionName - the name of the private endpoint connection.
   197  // parameters - request body for operation
   198  func (client PrivateEndpointConnectionClient) Put(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string, parameters PrivateEndpointConnectionResource) (result PrivateEndpointConnectionPutFuture, err error) {
   199  	if tracing.IsEnabled() {
   200  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionClient.Put")
   201  		defer func() {
   202  			sc := -1
   203  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   204  				sc = result.FutureAPI.Response().StatusCode
   205  			}
   206  			tracing.EndSpan(ctx, sc, err)
   207  		}()
   208  	}
   209  	req, err := client.PutPreparer(ctx, vaultName, resourceGroupName, privateEndpointConnectionName, parameters)
   210  	if err != nil {
   211  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Put", nil, "Failure preparing request")
   212  		return
   213  	}
   214  
   215  	result, err = client.PutSender(req)
   216  	if err != nil {
   217  		err = autorest.NewErrorWithError(err, "backup.PrivateEndpointConnectionClient", "Put", result.Response(), "Failure sending request")
   218  		return
   219  	}
   220  
   221  	return
   222  }
   223  
   224  // PutPreparer prepares the Put request.
   225  func (client PrivateEndpointConnectionClient) PutPreparer(ctx context.Context, vaultName string, resourceGroupName string, privateEndpointConnectionName string, parameters PrivateEndpointConnectionResource) (*http.Request, error) {
   226  	pathParameters := map[string]interface{}{
   227  		"privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName),
   228  		"resourceGroupName":             autorest.Encode("path", resourceGroupName),
   229  		"subscriptionId":                autorest.Encode("path", client.SubscriptionID),
   230  		"vaultName":                     autorest.Encode("path", vaultName),
   231  	}
   232  
   233  	const APIVersion = "2021-07-01"
   234  	queryParameters := map[string]interface{}{
   235  		"api-version": APIVersion,
   236  	}
   237  
   238  	preparer := autorest.CreatePreparer(
   239  		autorest.AsContentType("application/json; charset=utf-8"),
   240  		autorest.AsPut(),
   241  		autorest.WithBaseURL(client.BaseURI),
   242  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters),
   243  		autorest.WithJSON(parameters),
   244  		autorest.WithQueryParameters(queryParameters))
   245  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   246  }
   247  
   248  // PutSender sends the Put request. The method will close the
   249  // http.Response Body if it receives an error.
   250  func (client PrivateEndpointConnectionClient) PutSender(req *http.Request) (future PrivateEndpointConnectionPutFuture, err error) {
   251  	var resp *http.Response
   252  	future.FutureAPI = &azure.Future{}
   253  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   254  	if err != nil {
   255  		return
   256  	}
   257  	var azf azure.Future
   258  	azf, err = azure.NewFutureFromResponse(resp)
   259  	future.FutureAPI = &azf
   260  	future.Result = future.result
   261  	return
   262  }
   263  
   264  // PutResponder handles the response to the Put request. The method always
   265  // closes the http.Response Body.
   266  func (client PrivateEndpointConnectionClient) PutResponder(resp *http.Response) (result PrivateEndpointConnectionResource, err error) {
   267  	err = autorest.Respond(
   268  		resp,
   269  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   270  		autorest.ByUnmarshallingJSON(&result),
   271  		autorest.ByClosing())
   272  	result.Response = autorest.Response{Response: resp}
   273  	return
   274  }
   275  

View as plain text