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