...

Source file src/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-05-01/network/applicationgatewayprivateendpointconnections.go

Documentation: github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-05-01/network

     1  package 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  
     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  // ApplicationGatewayPrivateEndpointConnectionsClient is the network Client
    18  type ApplicationGatewayPrivateEndpointConnectionsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewApplicationGatewayPrivateEndpointConnectionsClient creates an instance of the
    23  // ApplicationGatewayPrivateEndpointConnectionsClient client.
    24  func 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).
    31  func 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.
    40  func (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", result.Response(), "Failure sending request")
    60  		return
    61  	}
    62  
    63  	return
    64  }
    65  
    66  // DeletePreparer prepares the Delete request.
    67  func (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 = "2022-05-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.
    90  func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future ApplicationGatewayPrivateEndpointConnectionsDeleteFuture, err error) {
    91  	var resp *http.Response
    92  	future.FutureAPI = &azure.Future{}
    93  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    94  	if err != nil {
    95  		return
    96  	}
    97  	var azf azure.Future
    98  	azf, err = azure.NewFutureFromResponse(resp)
    99  	future.FutureAPI = &azf
   100  	future.Result = future.result
   101  	return
   102  }
   103  
   104  // DeleteResponder handles the response to the Delete request. The method always
   105  // closes the http.Response Body.
   106  func (client ApplicationGatewayPrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   107  	err = autorest.Respond(
   108  		resp,
   109  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   110  		autorest.ByClosing())
   111  	result.Response = resp
   112  	return
   113  }
   114  
   115  // Get gets the specified private endpoint connection on application gateway.
   116  // Parameters:
   117  // resourceGroupName - the name of the resource group.
   118  // applicationGatewayName - the name of the application gateway.
   119  // connectionName - the name of the application gateway private endpoint connection.
   120  func (client ApplicationGatewayPrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (result ApplicationGatewayPrivateEndpointConnection, err error) {
   121  	if tracing.IsEnabled() {
   122  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Get")
   123  		defer func() {
   124  			sc := -1
   125  			if result.Response.Response != nil {
   126  				sc = result.Response.Response.StatusCode
   127  			}
   128  			tracing.EndSpan(ctx, sc, err)
   129  		}()
   130  	}
   131  	req, err := client.GetPreparer(ctx, resourceGroupName, applicationGatewayName, connectionName)
   132  	if err != nil {
   133  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request")
   134  		return
   135  	}
   136  
   137  	resp, err := client.GetSender(req)
   138  	if err != nil {
   139  		result.Response = autorest.Response{Response: resp}
   140  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", resp, "Failure sending request")
   141  		return
   142  	}
   143  
   144  	result, err = client.GetResponder(resp)
   145  	if err != nil {
   146  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request")
   147  		return
   148  	}
   149  
   150  	return
   151  }
   152  
   153  // GetPreparer prepares the Get request.
   154  func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string) (*http.Request, error) {
   155  	pathParameters := map[string]interface{}{
   156  		"applicationGatewayName": autorest.Encode("path", applicationGatewayName),
   157  		"connectionName":         autorest.Encode("path", connectionName),
   158  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   159  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   160  	}
   161  
   162  	const APIVersion = "2022-05-01"
   163  	queryParameters := map[string]interface{}{
   164  		"api-version": APIVersion,
   165  	}
   166  
   167  	preparer := autorest.CreatePreparer(
   168  		autorest.AsGet(),
   169  		autorest.WithBaseURL(client.BaseURI),
   170  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters),
   171  		autorest.WithQueryParameters(queryParameters))
   172  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   173  }
   174  
   175  // GetSender sends the Get request. The method will close the
   176  // http.Response Body if it receives an error.
   177  func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) {
   178  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   179  }
   180  
   181  // GetResponder handles the response to the Get request. The method always
   182  // closes the http.Response Body.
   183  func (client ApplicationGatewayPrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnection, err error) {
   184  	err = autorest.Respond(
   185  		resp,
   186  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   187  		autorest.ByUnmarshallingJSON(&result),
   188  		autorest.ByClosing())
   189  	result.Response = autorest.Response{Response: resp}
   190  	return
   191  }
   192  
   193  // List lists all private endpoint connections on an application gateway.
   194  // Parameters:
   195  // resourceGroupName - the name of the resource group.
   196  // applicationGatewayName - the name of the application gateway.
   197  func (client ApplicationGatewayPrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateEndpointConnectionListResultPage, err error) {
   198  	if tracing.IsEnabled() {
   199  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.List")
   200  		defer func() {
   201  			sc := -1
   202  			if result.agpeclr.Response.Response != nil {
   203  				sc = result.agpeclr.Response.Response.StatusCode
   204  			}
   205  			tracing.EndSpan(ctx, sc, err)
   206  		}()
   207  	}
   208  	result.fn = client.listNextResults
   209  	req, err := client.ListPreparer(ctx, resourceGroupName, applicationGatewayName)
   210  	if err != nil {
   211  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", nil, "Failure preparing request")
   212  		return
   213  	}
   214  
   215  	resp, err := client.ListSender(req)
   216  	if err != nil {
   217  		result.agpeclr.Response = autorest.Response{Response: resp}
   218  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", resp, "Failure sending request")
   219  		return
   220  	}
   221  
   222  	result.agpeclr, err = client.ListResponder(resp)
   223  	if err != nil {
   224  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "List", resp, "Failure responding to request")
   225  		return
   226  	}
   227  	if result.agpeclr.hasNextLink() && result.agpeclr.IsEmpty() {
   228  		err = result.NextWithContext(ctx)
   229  		return
   230  	}
   231  
   232  	return
   233  }
   234  
   235  // ListPreparer prepares the List request.
   236  func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) {
   237  	pathParameters := map[string]interface{}{
   238  		"applicationGatewayName": autorest.Encode("path", applicationGatewayName),
   239  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   240  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   241  	}
   242  
   243  	const APIVersion = "2022-05-01"
   244  	queryParameters := map[string]interface{}{
   245  		"api-version": APIVersion,
   246  	}
   247  
   248  	preparer := autorest.CreatePreparer(
   249  		autorest.AsGet(),
   250  		autorest.WithBaseURL(client.BaseURI),
   251  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections", pathParameters),
   252  		autorest.WithQueryParameters(queryParameters))
   253  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   254  }
   255  
   256  // ListSender sends the List request. The method will close the
   257  // http.Response Body if it receives an error.
   258  func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) {
   259  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   260  }
   261  
   262  // ListResponder handles the response to the List request. The method always
   263  // closes the http.Response Body.
   264  func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnectionListResult, err error) {
   265  	err = autorest.Respond(
   266  		resp,
   267  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   268  		autorest.ByUnmarshallingJSON(&result),
   269  		autorest.ByClosing())
   270  	result.Response = autorest.Response{Response: resp}
   271  	return
   272  }
   273  
   274  // listNextResults retrieves the next set of results, if any.
   275  func (client ApplicationGatewayPrivateEndpointConnectionsClient) listNextResults(ctx context.Context, lastResults ApplicationGatewayPrivateEndpointConnectionListResult) (result ApplicationGatewayPrivateEndpointConnectionListResult, err error) {
   276  	req, err := lastResults.applicationGatewayPrivateEndpointConnectionListResultPreparer(ctx)
   277  	if err != nil {
   278  		return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", nil, "Failure preparing next results request")
   279  	}
   280  	if req == nil {
   281  		return
   282  	}
   283  	resp, err := client.ListSender(req)
   284  	if err != nil {
   285  		result.Response = autorest.Response{Response: resp}
   286  		return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", resp, "Failure sending next results request")
   287  	}
   288  	result, err = client.ListResponder(resp)
   289  	if err != nil {
   290  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "listNextResults", resp, "Failure responding to next results request")
   291  	}
   292  	return
   293  }
   294  
   295  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   296  func (client ApplicationGatewayPrivateEndpointConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateEndpointConnectionListResultIterator, err error) {
   297  	if tracing.IsEnabled() {
   298  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.List")
   299  		defer func() {
   300  			sc := -1
   301  			if result.Response().Response.Response != nil {
   302  				sc = result.page.Response().Response.Response.StatusCode
   303  			}
   304  			tracing.EndSpan(ctx, sc, err)
   305  		}()
   306  	}
   307  	result.page, err = client.List(ctx, resourceGroupName, applicationGatewayName)
   308  	return
   309  }
   310  
   311  // Update updates the specified private endpoint connection on application gateway.
   312  // Parameters:
   313  // resourceGroupName - the name of the resource group.
   314  // applicationGatewayName - the name of the application gateway.
   315  // connectionName - the name of the application gateway private endpoint connection.
   316  // parameters - parameters supplied to update application gateway private endpoint connection operation.
   317  func (client ApplicationGatewayPrivateEndpointConnectionsClient) Update(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string, parameters ApplicationGatewayPrivateEndpointConnection) (result ApplicationGatewayPrivateEndpointConnectionsUpdateFuture, err error) {
   318  	if tracing.IsEnabled() {
   319  		ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateEndpointConnectionsClient.Update")
   320  		defer func() {
   321  			sc := -1
   322  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   323  				sc = result.FutureAPI.Response().StatusCode
   324  			}
   325  			tracing.EndSpan(ctx, sc, err)
   326  		}()
   327  	}
   328  	req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationGatewayName, connectionName, parameters)
   329  	if err != nil {
   330  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request")
   331  		return
   332  	}
   333  
   334  	result, err = client.UpdateSender(req)
   335  	if err != nil {
   336  		err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateEndpointConnectionsClient", "Update", result.Response(), "Failure sending request")
   337  		return
   338  	}
   339  
   340  	return
   341  }
   342  
   343  // UpdatePreparer prepares the Update request.
   344  func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, connectionName string, parameters ApplicationGatewayPrivateEndpointConnection) (*http.Request, error) {
   345  	pathParameters := map[string]interface{}{
   346  		"applicationGatewayName": autorest.Encode("path", applicationGatewayName),
   347  		"connectionName":         autorest.Encode("path", connectionName),
   348  		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
   349  		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
   350  	}
   351  
   352  	const APIVersion = "2022-05-01"
   353  	queryParameters := map[string]interface{}{
   354  		"api-version": APIVersion,
   355  	}
   356  
   357  	parameters.Etag = nil
   358  	parameters.Type = nil
   359  	preparer := autorest.CreatePreparer(
   360  		autorest.AsContentType("application/json; charset=utf-8"),
   361  		autorest.AsPut(),
   362  		autorest.WithBaseURL(client.BaseURI),
   363  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateEndpointConnections/{connectionName}", pathParameters),
   364  		autorest.WithJSON(parameters),
   365  		autorest.WithQueryParameters(queryParameters))
   366  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   367  }
   368  
   369  // UpdateSender sends the Update request. The method will close the
   370  // http.Response Body if it receives an error.
   371  func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (future ApplicationGatewayPrivateEndpointConnectionsUpdateFuture, err error) {
   372  	var resp *http.Response
   373  	future.FutureAPI = &azure.Future{}
   374  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   375  	if err != nil {
   376  		return
   377  	}
   378  	var azf azure.Future
   379  	azf, err = azure.NewFutureFromResponse(resp)
   380  	future.FutureAPI = &azf
   381  	future.Result = future.result
   382  	return
   383  }
   384  
   385  // UpdateResponder handles the response to the Update request. The method always
   386  // closes the http.Response Body.
   387  func (client ApplicationGatewayPrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result ApplicationGatewayPrivateEndpointConnection, err error) {
   388  	err = autorest.Respond(
   389  		resp,
   390  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   391  		autorest.ByUnmarshallingJSON(&result),
   392  		autorest.ByClosing())
   393  	result.Response = autorest.Response{Response: resp}
   394  	return
   395  }
   396  

View as plain text