1package network 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// ApplicationGatewayPrivateEndpointConnectionsClient is the network Client 18type ApplicationGatewayPrivateEndpointConnectionsClient struct { 19 BaseClient 20} 21 22// NewApplicationGatewayPrivateEndpointConnectionsClient creates an instance of the 23// ApplicationGatewayPrivateEndpointConnectionsClient client. 24func NewApplicationGatewayPrivateEndpointConnectionsClient(subscriptionID string) ApplicationGatewayPrivateEndpointConnectionsClient { 25 return NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI creates an instance of the 29// ApplicationGatewayPrivateEndpointConnectionsClient client using a custom endpoint. Use this when interacting with 30// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationGatewayPrivateEndpointConnectionsClient { 32 return ApplicationGatewayPrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Delete deletes the specified private endpoint connection on application gateway. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// applicationGatewayName - the name of the application gateway. 39// connectionName - the name of the application gateway private endpoint connection. 40func (client ApplicationGatewayPrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (result ApplicationGatewayPrivateEndpointConnectionsDeleteFuture, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Delete") 43 defer func() { 44 sc := -1 45 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 46 sc = result.FutureAPI.Response().StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 req, err := client.DeletePreparer(ctx, resourceGroupName, applicationGatewayName, connectionName) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") 54 return 55 } 56 57 result, err = client.DeleteSender(req) 58 if err != nil { 59 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") 60 return 61 } 62 63 return 64} 65 66// DeletePreparer prepares the Delete request. 67func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (*http.Request, error) { 68 pathParameters := map[string]interface{}{ 69 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 70 "connectionName": autorest.Encode("path", connectionName), 71 "resourceGroupName": autorest.Encode("path", resourceGroupName), 72 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 73 } 74 75 const APIVersion = "2021-02-01" 76 queryParameters := map[string]interface{}{ 77 "api-version": APIVersion, 78 } 79 80 preparer := autorest.CreatePreparer( 81 autorest.AsDelete(), 82 autorest.WithBaseURL(client.BaseURI), 83 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters), 84 autorest.WithQueryParameters(queryParameters)) 85 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 86} 87 88// DeleteSender sends the Delete request. The method will close the 89// http.Response Body if it receives an error. 90func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future ApplicationGatewayPrivateEndpointConnectionsDeleteFuture, err error) { 91 var resp *http.Response 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. 105func (client ApplicationGatewayPrivateEndpointConnectionsClient) 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 gets the specified private endpoint connection on application gateway. 115// Parameters: 116// resourceGroupName - the name of the resource group. 117// applicationGatewayName - the name of the application gateway. 118// connectionName - the name of the application gateway private endpoint connection. 119func (client ApplicationGatewayPrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (result ApplicationGatewayPrivateEndpointConnection, err error) { 120 if tracing.IsEnabled() { 121 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.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, resourceGroupName, applicationGatewayName, connectionName) 131 if err != nil { 132 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "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, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") 140 return 141 } 142 143 result, err = client.GetResponder(resp) 144 if err != nil { 145 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") 146 return 147 } 148 149 return 150} 151 152// GetPreparer prepares the Get request. 153func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (*http.Request, error) { 154 pathParameters := map[string]interface{}{ 155 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 156 "connectionName": autorest.Encode("path", connectionName), 157 "resourceGroupName": autorest.Encode("path", resourceGroupName), 158 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 159 } 160 161 const APIVersion = "2021-02-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.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", 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. 176func (client ApplicationGatewayPrivateEndpointConnectionsClient) 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. 182func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnection, 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// List lists all private endpoint connections on an application gateway. 193// Parameters: 194// resourceGroupName - the name of the resource group. 195// applicationGatewayName - the name of the application gateway. 196func (client ApplicationGatewayPrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateEndpointConnectionListResultPage, err error) { 197 if tracing.IsEnabled() { 198 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.List") 199 defer func() { 200 sc := -1 201 if result.agpeclr.Response.Response != nil { 202 sc = result.agpeclr.Response.Response.StatusCode 203 } 204 tracing.EndSpan(ctx, sc, err) 205 }() 206 } 207 result.fn = client.listNextResults 208 req, err := client.ListPreparer(ctx, resourceGroupName, applicationGatewayName) 209 if err != nil { 210 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") 211 return 212 } 213 214 resp, err := client.ListSender(req) 215 if err != nil { 216 result.agpeclr.Response = autorest.Response{Response: resp} 217 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", resp, "Failure sending request") 218 return 219 } 220 221 result.agpeclr, err = client.ListResponder(resp) 222 if err != nil { 223 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") 224 return 225 } 226 if result.agpeclr.hasNextLink() && result.agpeclr.IsEmpty() { 227 err = result.NextWithContext(ctx) 228 return 229 } 230 231 return 232} 233 234// ListPreparer prepares the List request. 235func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 236 pathParameters := map[string]interface{}{ 237 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 238 "resourceGroupName": autorest.Encode("path", resourceGroupName), 239 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 240 } 241 242 const APIVersion = "2021-02-01" 243 queryParameters := map[string]interface{}{ 244 "api-version": APIVersion, 245 } 246 247 preparer := autorest.CreatePreparer( 248 autorest.AsGet(), 249 autorest.WithBaseURL(client.BaseURI), 250 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections", pathParameters), 251 autorest.WithQueryParameters(queryParameters)) 252 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 253} 254 255// ListSender sends the List request. The method will close the 256// http.Response Body if it receives an error. 257func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { 258 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 259} 260 261// ListResponder handles the response to the List request. The method always 262// closes the http.Response Body. 263func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnectionListResult, err error) { 264 err = autorest.Respond( 265 resp, 266 azure.WithErrorUnlessStatusCode(http.StatusOK), 267 autorest.ByUnmarshallingJSON(&result), 268 autorest.ByClosing()) 269 result.Response = autorest.Response{Response: resp} 270 return 271} 272 273// listNextResults retrieves the next set of results, if any. 274func (client ApplicationGatewayPrivateEndpointConnectionsClient) listNextResults(ctx context.Context, lastResults ApplicationGatewayPrivateEndpointConnectionListResult) (result ApplicationGatewayPrivateEndpointConnectionListResult, err error) { 275 req, err := lastResults.applicationGatewayPrivateEndpointConnectionListResultPreparer(ctx) 276 if err != nil { 277 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", nil, "Failure preparing next results request") 278 } 279 if req == nil { 280 return 281 } 282 resp, err := client.ListSender(req) 283 if err != nil { 284 result.Response = autorest.Response{Response: resp} 285 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", resp, "Failure sending next results request") 286 } 287 result, err = client.ListResponder(resp) 288 if err != nil { 289 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", resp, "Failure responding to next results request") 290 } 291 return 292} 293 294// ListComplete enumerates all values, automatically crossing page boundaries as required. 295func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateEndpointConnectionListResultIterator, err error) { 296 if tracing.IsEnabled() { 297 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.List") 298 defer func() { 299 sc := -1 300 if result.Response().Response.Response != nil { 301 sc = result.page.Response().Response.Response.StatusCode 302 } 303 tracing.EndSpan(ctx, sc, err) 304 }() 305 } 306 result.page, err = client.List(ctx, resourceGroupName, applicationGatewayName) 307 return 308} 309 310// Update updates the specified private endpoint connection on application gateway. 311// Parameters: 312// resourceGroupName - the name of the resource group. 313// applicationGatewayName - the name of the application gateway. 314// connectionName - the name of the application gateway private endpoint connection. 315// parameters - parameters supplied to update application gateway private endpoint connection operation. 316func (client ApplicationGatewayPrivateEndpointConnectionsClient) Update(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string, parameters ApplicationGatewayPrivateEndpointConnection) (result ApplicationGatewayPrivateEndpointConnectionsUpdateFuture, err error) { 317 if tracing.IsEnabled() { 318 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Update") 319 defer func() { 320 sc := -1 321 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 322 sc = result.FutureAPI.Response().StatusCode 323 } 324 tracing.EndSpan(ctx, sc, err) 325 }() 326 } 327 req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationGatewayName, connectionName, parameters) 328 if err != nil { 329 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request") 330 return 331 } 332 333 result, err = client.UpdateSender(req) 334 if err != nil { 335 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Update", nil, "Failure sending request") 336 return 337 } 338 339 return 340} 341 342// UpdatePreparer prepares the Update request. 343func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string, parameters ApplicationGatewayPrivateEndpointConnection) (*http.Request, error) { 344 pathParameters := map[string]interface{}{ 345 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 346 "connectionName": autorest.Encode("path", connectionName), 347 "resourceGroupName": autorest.Encode("path", resourceGroupName), 348 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 349 } 350 351 const APIVersion = "2021-02-01" 352 queryParameters := map[string]interface{}{ 353 "api-version": APIVersion, 354 } 355 356 parameters.Etag = nil 357 parameters.Type = nil 358 preparer := autorest.CreatePreparer( 359 autorest.AsContentType("application/json; charset=utf-8"), 360 autorest.AsPut(), 361 autorest.WithBaseURL(client.BaseURI), 362 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters), 363 autorest.WithJSON(parameters), 364 autorest.WithQueryParameters(queryParameters)) 365 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 366} 367 368// UpdateSender sends the Update request. The method will close the 369// http.Response Body if it receives an error. 370func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (future ApplicationGatewayPrivateEndpointConnectionsUpdateFuture, err error) { 371 var resp *http.Response 372 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 373 if err != nil { 374 return 375 } 376 var azf azure.Future 377 azf, err = azure.NewFutureFromResponse(resp) 378 future.FutureAPI = &azf 379 future.Result = future.result 380 return 381} 382 383// UpdateResponder handles the response to the Update request. The method always 384// closes the http.Response Body. 385func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnection, err error) { 386 err = autorest.Respond( 387 resp, 388 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 389 autorest.ByUnmarshallingJSON(&result), 390 autorest.ByClosing()) 391 result.Response = autorest.Response{Response: resp} 392 return 393} 394