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// ApplicationGatewayPrivateLinkResourcesClient is the network Client 18type ApplicationGatewayPrivateLinkResourcesClient struct { 19 BaseClient 20} 21 22// NewApplicationGatewayPrivateLinkResourcesClient creates an instance of the 23// ApplicationGatewayPrivateLinkResourcesClient client. 24func NewApplicationGatewayPrivateLinkResourcesClient(subscriptionID string) ApplicationGatewayPrivateLinkResourcesClient { 25 return NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI creates an instance of the 29// ApplicationGatewayPrivateLinkResourcesClient client using a custom endpoint. Use this when interacting with an 30// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) ApplicationGatewayPrivateLinkResourcesClient { 32 return ApplicationGatewayPrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// List lists all private link resources on an application gateway. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// applicationGatewayName - the name of the application gateway. 39func (client ApplicationGatewayPrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateLinkResourceListResultPage, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateLinkResourcesClient.List") 42 defer func() { 43 sc := -1 44 if result.agplrlr.Response.Response != nil { 45 sc = result.agplrlr.Response.Response.StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 result.fn = client.listNextResults 51 req, err := client.ListPreparer(ctx, resourceGroupName, applicationGatewayName) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "List", nil, "Failure preparing request") 54 return 55 } 56 57 resp, err := client.ListSender(req) 58 if err != nil { 59 result.agplrlr.Response = autorest.Response{Response: resp} 60 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "List", resp, "Failure sending request") 61 return 62 } 63 64 result.agplrlr, err = client.ListResponder(resp) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "List", resp, "Failure responding to request") 67 return 68 } 69 if result.agplrlr.hasNextLink() && result.agplrlr.IsEmpty() { 70 err = result.NextWithContext(ctx) 71 return 72 } 73 74 return 75} 76 77// ListPreparer prepares the List request. 78func (client ApplicationGatewayPrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 79 pathParameters := map[string]interface{}{ 80 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 81 "resourceGroupName": autorest.Encode("path", resourceGroupName), 82 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 83 } 84 85 const APIVersion = "2020-06-01" 86 queryParameters := map[string]interface{}{ 87 "api-version": APIVersion, 88 } 89 90 preparer := autorest.CreatePreparer( 91 autorest.AsGet(), 92 autorest.WithBaseURL(client.BaseURI), 93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/privateLinkResources", pathParameters), 94 autorest.WithQueryParameters(queryParameters)) 95 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 96} 97 98// ListSender sends the List request. The method will close the 99// http.Response Body if it receives an error. 100func (client ApplicationGatewayPrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { 101 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 102} 103 104// ListResponder handles the response to the List request. The method always 105// closes the http.Response Body. 106func (client ApplicationGatewayPrivateLinkResourcesClient) ListResponder(resp *http.Response) (result ApplicationGatewayPrivateLinkResourceListResult, err error) { 107 err = autorest.Respond( 108 resp, 109 azure.WithErrorUnlessStatusCode(http.StatusOK), 110 autorest.ByUnmarshallingJSON(&result), 111 autorest.ByClosing()) 112 result.Response = autorest.Response{Response: resp} 113 return 114} 115 116// listNextResults retrieves the next set of results, if any. 117func (client ApplicationGatewayPrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults ApplicationGatewayPrivateLinkResourceListResult) (result ApplicationGatewayPrivateLinkResourceListResult, err error) { 118 req, err := lastResults.applicationGatewayPrivateLinkResourceListResultPreparer(ctx) 119 if err != nil { 120 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request") 121 } 122 if req == nil { 123 return 124 } 125 resp, err := client.ListSender(req) 126 if err != nil { 127 result.Response = autorest.Response{Response: resp} 128 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request") 129 } 130 result, err = client.ListResponder(resp) 131 if err != nil { 132 err = autorest.NewErrorWithError(err, "network.ApplicationGatewayPrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") 133 } 134 return 135} 136 137// ListComplete enumerates all values, automatically crossing page boundaries as required. 138func (client ApplicationGatewayPrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewayPrivateLinkResourceListResultIterator, err error) { 139 if tracing.IsEnabled() { 140 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewayPrivateLinkResourcesClient.List") 141 defer func() { 142 sc := -1 143 if result.Response().Response.Response != nil { 144 sc = result.page.Response().Response.Response.StatusCode 145 } 146 tracing.EndSpan(ctx, sc, err) 147 }() 148 } 149 result.page, err = client.List(ctx, resourceGroupName, applicationGatewayName) 150 return 151} 152