1package network 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/tracing" 25 "net/http" 26) 27 28// ApplicationGatewayPrivateEndpointConnectionsClient is the network Client 29type ApplicationGatewayPrivateEndpointConnectionsClient struct { 30 BaseClient 31} 32 33// NewApplicationGatewayPrivateEndpointConnectionsClient creates an instance of the 34// ApplicationGatewayPrivateEndpointConnectionsClient client. 35func NewApplicationGatewayPrivateEndpointConnectionsClient(subscriptionID string) ApplicationGatewayPrivateEndpointConnectionsClient { 36 return NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI creates an instance of the 40// ApplicationGatewayPrivateEndpointConnectionsClient client using a custom endpoint. Use this when interacting with 41// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationGatewayPrivateEndpointConnectionsClient { 43 return ApplicationGatewayPrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// Delete deletes the specified private endpoint connection on application gateway. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// applicationGatewayName - the name of the application gateway. 50// connectionName - the name of the application gateway private endpoint connection. 51func (client ApplicationGatewayPrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (result ApplicationGatewayPrivateEndpointConnectionsDeleteFuture, err error) { 52 if tracing.IsEnabled() { 53 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Delete") 54 defer func() { 55 sc := -1 56 if result.Response() != nil { 57 sc = result.Response().StatusCode 58 } 59 tracing.EndSpan(ctx, sc, err) 60 }() 61 } 62 req, err := client.DeletePreparer(ctx, resourceGroupName, applicationGatewayName, connectionName) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") 65 return 66 } 67 68 result, err = client.DeleteSender(req) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") 71 return 72 } 73 74 return 75} 76 77// DeletePreparer prepares the Delete request. 78func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (*http.Request, error) { 79 pathParameters := map[string]interface{}{ 80 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 81 "connectionName": autorest.Encode("path", connectionName), 82 "resourceGroupName": autorest.Encode("path", resourceGroupName), 83 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 84 } 85 86 const APIVersion = "2020-05-01" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsDelete(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// DeleteSender sends the Delete request. The method will close the 100// http.Response Body if it receives an error. 101func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future ApplicationGatewayPrivateEndpointConnectionsDeleteFuture, err error) { 102 var resp *http.Response 103 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 104 if err != nil { 105 return 106 } 107 future.Future, err = azure.NewFutureFromResponse(resp) 108 return 109} 110 111// DeleteResponder handles the response to the Delete request. The method always 112// closes the http.Response Body. 113func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 114 err = autorest.Respond( 115 resp, 116 client.ByInspecting(), 117 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 118 autorest.ByClosing()) 119 result.Response = resp 120 return 121} 122 123// Get gets the specified private endpoint connection on application gateway. 124// Parameters: 125// resourceGroupName - the name of the resource group. 126// applicationGatewayName - the name of the application gateway. 127// connectionName - the name of the application gateway private endpoint connection. 128func (client ApplicationGatewayPrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (result ApplicationGatewayPrivateEndpointConnection, err error) { 129 if tracing.IsEnabled() { 130 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Get") 131 defer func() { 132 sc := -1 133 if result.Response.Response != nil { 134 sc = result.Response.Response.StatusCode 135 } 136 tracing.EndSpan(ctx, sc, err) 137 }() 138 } 139 req, err := client.GetPreparer(ctx, resourceGroupName, applicationGatewayName, connectionName) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") 142 return 143 } 144 145 resp, err := client.GetSender(req) 146 if err != nil { 147 result.Response = autorest.Response{Response: resp} 148 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") 149 return 150 } 151 152 result, err = client.GetResponder(resp) 153 if err != nil { 154 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") 155 } 156 157 return 158} 159 160// GetPreparer prepares the Get request. 161func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (*http.Request, error) { 162 pathParameters := map[string]interface{}{ 163 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 164 "connectionName": autorest.Encode("path", connectionName), 165 "resourceGroupName": autorest.Encode("path", resourceGroupName), 166 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 167 } 168 169 const APIVersion = "2020-05-01" 170 queryParameters := map[string]interface{}{ 171 "api-version": APIVersion, 172 } 173 174 preparer := autorest.CreatePreparer( 175 autorest.AsGet(), 176 autorest.WithBaseURL(client.BaseURI), 177 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters), 178 autorest.WithQueryParameters(queryParameters)) 179 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 180} 181 182// GetSender sends the Get request. The method will close the 183// http.Response Body if it receives an error. 184func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { 185 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 186} 187 188// GetResponder handles the response to the Get request. The method always 189// closes the http.Response Body. 190func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnection, err error) { 191 err = autorest.Respond( 192 resp, 193 client.ByInspecting(), 194 azure.WithErrorUnlessStatusCode(http.StatusOK), 195 autorest.ByUnmarshallingJSON(&result), 196 autorest.ByClosing()) 197 result.Response = autorest.Response{Response: resp} 198 return 199} 200 201// List lists all private endpoint connections on an application gateway. 202// Parameters: 203// resourceGroupName - the name of the resource group. 204// applicationGatewayName - the name of the application gateway. 205func (client ApplicationGatewayPrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateEndpointConnectionListResultPage, err error) { 206 if tracing.IsEnabled() { 207 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.List") 208 defer func() { 209 sc := -1 210 if result.agpeclr.Response.Response != nil { 211 sc = result.agpeclr.Response.Response.StatusCode 212 } 213 tracing.EndSpan(ctx, sc, err) 214 }() 215 } 216 result.fn = client.listNextResults 217 req, err := client.ListPreparer(ctx, resourceGroupName, applicationGatewayName) 218 if err != nil { 219 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") 220 return 221 } 222 223 resp, err := client.ListSender(req) 224 if err != nil { 225 result.agpeclr.Response = autorest.Response{Response: resp} 226 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", resp, "Failure sending request") 227 return 228 } 229 230 result.agpeclr, err = client.ListResponder(resp) 231 if err != nil { 232 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") 233 } 234 235 return 236} 237 238// ListPreparer prepares the List request. 239func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 240 pathParameters := map[string]interface{}{ 241 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 242 "resourceGroupName": autorest.Encode("path", resourceGroupName), 243 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 244 } 245 246 const APIVersion = "2020-05-01" 247 queryParameters := map[string]interface{}{ 248 "api-version": APIVersion, 249 } 250 251 preparer := autorest.CreatePreparer( 252 autorest.AsGet(), 253 autorest.WithBaseURL(client.BaseURI), 254 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections", pathParameters), 255 autorest.WithQueryParameters(queryParameters)) 256 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 257} 258 259// ListSender sends the List request. The method will close the 260// http.Response Body if it receives an error. 261func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { 262 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 263} 264 265// ListResponder handles the response to the List request. The method always 266// closes the http.Response Body. 267func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnectionListResult, err error) { 268 err = autorest.Respond( 269 resp, 270 client.ByInspecting(), 271 azure.WithErrorUnlessStatusCode(http.StatusOK), 272 autorest.ByUnmarshallingJSON(&result), 273 autorest.ByClosing()) 274 result.Response = autorest.Response{Response: resp} 275 return 276} 277 278// listNextResults retrieves the next set of results, if any. 279func (client ApplicationGatewayPrivateEndpointConnectionsClient) listNextResults(ctx context.Context, lastResults ApplicationGatewayPrivateEndpointConnectionListResult) (result ApplicationGatewayPrivateEndpointConnectionListResult, err error) { 280 req, err := lastResults.applicationGatewayPrivateEndpointConnectionListResultPreparer(ctx) 281 if err != nil { 282 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", nil, "Failure preparing next results request") 283 } 284 if req == nil { 285 return 286 } 287 resp, err := client.ListSender(req) 288 if err != nil { 289 result.Response = autorest.Response{Response: resp} 290 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", resp, "Failure sending next results request") 291 } 292 result, err = client.ListResponder(resp) 293 if err != nil { 294 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", resp, "Failure responding to next results request") 295 } 296 return 297} 298 299// ListComplete enumerates all values, automatically crossing page boundaries as required. 300func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateEndpointConnectionListResultIterator, err error) { 301 if tracing.IsEnabled() { 302 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.List") 303 defer func() { 304 sc := -1 305 if result.Response().Response.Response != nil { 306 sc = result.page.Response().Response.Response.StatusCode 307 } 308 tracing.EndSpan(ctx, sc, err) 309 }() 310 } 311 result.page, err = client.List(ctx, resourceGroupName, applicationGatewayName) 312 return 313} 314 315// Update updates the specified private endpoint connection on application gateway. 316// Parameters: 317// resourceGroupName - the name of the resource group. 318// applicationGatewayName - the name of the application gateway. 319// connectionName - the name of the application gateway private endpoint connection. 320// parameters - parameters supplied to update application gateway private endpoint connection operation. 321func (client ApplicationGatewayPrivateEndpointConnectionsClient) Update(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string, parameters ApplicationGatewayPrivateEndpointConnection) (result ApplicationGatewayPrivateEndpointConnectionsUpdateFuture, err error) { 322 if tracing.IsEnabled() { 323 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Update") 324 defer func() { 325 sc := -1 326 if result.Response() != nil { 327 sc = result.Response().StatusCode 328 } 329 tracing.EndSpan(ctx, sc, err) 330 }() 331 } 332 req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationGatewayName, connectionName, parameters) 333 if err != nil { 334 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request") 335 return 336 } 337 338 result, err = client.UpdateSender(req) 339 if err != nil { 340 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Update", result.Response(), "Failure sending request") 341 return 342 } 343 344 return 345} 346 347// UpdatePreparer prepares the Update request. 348func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string, parameters ApplicationGatewayPrivateEndpointConnection) (*http.Request, error) { 349 pathParameters := map[string]interface{}{ 350 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 351 "connectionName": autorest.Encode("path", connectionName), 352 "resourceGroupName": autorest.Encode("path", resourceGroupName), 353 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 354 } 355 356 const APIVersion = "2020-05-01" 357 queryParameters := map[string]interface{}{ 358 "api-version": APIVersion, 359 } 360 361 parameters.Etag = nil 362 parameters.Type = nil 363 preparer := autorest.CreatePreparer( 364 autorest.AsContentType("application/json; charset=utf-8"), 365 autorest.AsPut(), 366 autorest.WithBaseURL(client.BaseURI), 367 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters), 368 autorest.WithJSON(parameters), 369 autorest.WithQueryParameters(queryParameters)) 370 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 371} 372 373// UpdateSender sends the Update request. The method will close the 374// http.Response Body if it receives an error. 375func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (future ApplicationGatewayPrivateEndpointConnectionsUpdateFuture, err error) { 376 var resp *http.Response 377 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 378 if err != nil { 379 return 380 } 381 future.Future, err = azure.NewFutureFromResponse(resp) 382 return 383} 384 385// UpdateResponder handles the response to the Update request. The method always 386// closes the http.Response Body. 387func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnection, err error) { 388 err = autorest.Respond( 389 resp, 390 client.ByInspecting(), 391 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 392 autorest.ByUnmarshallingJSON(&result), 393 autorest.ByClosing()) 394 result.Response = autorest.Response{Response: resp} 395 return 396} 397