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