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// GetIkeSas lists IKE Security Associations for Vpn Site Link Connection in the specified resource group. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// gatewayName - the name of the gateway. 38// connectionName - the name of the vpn connection. 39// linkConnectionName - the name of the vpn link connection. 40func (client VpnLinkConnectionsClient) GetIkeSas(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string) (result VpnLinkConnectionsGetIkeSasFuture, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/VpnLinkConnectionsClient.GetIkeSas") 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.GetIkeSasPreparer(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "GetIkeSas", nil, "Failure preparing request") 54 return 55 } 56 57 result, err = client.GetIkeSasSender(req) 58 if err != nil { 59 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "GetIkeSas", nil, "Failure sending request") 60 return 61 } 62 63 return 64} 65 66// GetIkeSasPreparer prepares the GetIkeSas request. 67func (client VpnLinkConnectionsClient) GetIkeSasPreparer(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string) (*http.Request, error) { 68 pathParameters := map[string]interface{}{ 69 "connectionName": autorest.Encode("path", connectionName), 70 "gatewayName": autorest.Encode("path", gatewayName), 71 "linkConnectionName": autorest.Encode("path", linkConnectionName), 72 "resourceGroupName": autorest.Encode("path", resourceGroupName), 73 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 74 } 75 76 const APIVersion = "2020-11-01" 77 queryParameters := map[string]interface{}{ 78 "api-version": APIVersion, 79 } 80 81 preparer := autorest.CreatePreparer( 82 autorest.AsPost(), 83 autorest.WithBaseURL(client.BaseURI), 84 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/getikesas", pathParameters), 85 autorest.WithQueryParameters(queryParameters)) 86 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 87} 88 89// GetIkeSasSender sends the GetIkeSas request. The method will close the 90// http.Response Body if it receives an error. 91func (client VpnLinkConnectionsClient) GetIkeSasSender(req *http.Request) (future VpnLinkConnectionsGetIkeSasFuture, err error) { 92 var resp *http.Response 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// GetIkeSasResponder handles the response to the GetIkeSas request. The method always 105// closes the http.Response Body. 106func (client VpnLinkConnectionsClient) GetIkeSasResponder(resp *http.Response) (result String, err error) { 107 err = autorest.Respond( 108 resp, 109 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 110 autorest.ByUnmarshallingJSON(&result), 111 autorest.ByClosing()) 112 result.Response = autorest.Response{Response: resp} 113 return 114} 115 116// ListByVpnConnection retrieves all vpn site link connections for a particular virtual wan vpn gateway vpn connection. 117// Parameters: 118// resourceGroupName - the resource group name of the vpn gateway. 119// gatewayName - the name of the gateway. 120// connectionName - the name of the vpn connection. 121func (client VpnLinkConnectionsClient) ListByVpnConnection(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string) (result ListVpnSiteLinkConnectionsResultPage, err error) { 122 if tracing.IsEnabled() { 123 ctx = tracing.StartSpan(ctx, fqdn+"/VpnLinkConnectionsClient.ListByVpnConnection") 124 defer func() { 125 sc := -1 126 if result.lvslcr.Response.Response != nil { 127 sc = result.lvslcr.Response.Response.StatusCode 128 } 129 tracing.EndSpan(ctx, sc, err) 130 }() 131 } 132 result.fn = client.listByVpnConnectionNextResults 133 req, err := client.ListByVpnConnectionPreparer(ctx, resourceGroupName, gatewayName, connectionName) 134 if err != nil { 135 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "ListByVpnConnection", nil, "Failure preparing request") 136 return 137 } 138 139 resp, err := client.ListByVpnConnectionSender(req) 140 if err != nil { 141 result.lvslcr.Response = autorest.Response{Response: resp} 142 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "ListByVpnConnection", resp, "Failure sending request") 143 return 144 } 145 146 result.lvslcr, err = client.ListByVpnConnectionResponder(resp) 147 if err != nil { 148 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "ListByVpnConnection", resp, "Failure responding to request") 149 return 150 } 151 if result.lvslcr.hasNextLink() && result.lvslcr.IsEmpty() { 152 err = result.NextWithContext(ctx) 153 return 154 } 155 156 return 157} 158 159// ListByVpnConnectionPreparer prepares the ListByVpnConnection request. 160func (client VpnLinkConnectionsClient) ListByVpnConnectionPreparer(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string) (*http.Request, error) { 161 pathParameters := map[string]interface{}{ 162 "connectionName": autorest.Encode("path", connectionName), 163 "gatewayName": autorest.Encode("path", gatewayName), 164 "resourceGroupName": autorest.Encode("path", resourceGroupName), 165 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 166 } 167 168 const APIVersion = "2020-11-01" 169 queryParameters := map[string]interface{}{ 170 "api-version": APIVersion, 171 } 172 173 preparer := autorest.CreatePreparer( 174 autorest.AsGet(), 175 autorest.WithBaseURL(client.BaseURI), 176 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections", pathParameters), 177 autorest.WithQueryParameters(queryParameters)) 178 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 179} 180 181// ListByVpnConnectionSender sends the ListByVpnConnection request. The method will close the 182// http.Response Body if it receives an error. 183func (client VpnLinkConnectionsClient) ListByVpnConnectionSender(req *http.Request) (*http.Response, error) { 184 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 185} 186 187// ListByVpnConnectionResponder handles the response to the ListByVpnConnection request. The method always 188// closes the http.Response Body. 189func (client VpnLinkConnectionsClient) ListByVpnConnectionResponder(resp *http.Response) (result ListVpnSiteLinkConnectionsResult, err error) { 190 err = autorest.Respond( 191 resp, 192 azure.WithErrorUnlessStatusCode(http.StatusOK), 193 autorest.ByUnmarshallingJSON(&result), 194 autorest.ByClosing()) 195 result.Response = autorest.Response{Response: resp} 196 return 197} 198 199// listByVpnConnectionNextResults retrieves the next set of results, if any. 200func (client VpnLinkConnectionsClient) listByVpnConnectionNextResults(ctx context.Context, lastResults ListVpnSiteLinkConnectionsResult) (result ListVpnSiteLinkConnectionsResult, err error) { 201 req, err := lastResults.listVpnSiteLinkConnectionsResultPreparer(ctx) 202 if err != nil { 203 return result, autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "listByVpnConnectionNextResults", nil, "Failure preparing next results request") 204 } 205 if req == nil { 206 return 207 } 208 resp, err := client.ListByVpnConnectionSender(req) 209 if err != nil { 210 result.Response = autorest.Response{Response: resp} 211 return result, autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "listByVpnConnectionNextResults", resp, "Failure sending next results request") 212 } 213 result, err = client.ListByVpnConnectionResponder(resp) 214 if err != nil { 215 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "listByVpnConnectionNextResults", resp, "Failure responding to next results request") 216 } 217 return 218} 219 220// ListByVpnConnectionComplete enumerates all values, automatically crossing page boundaries as required. 221func (client VpnLinkConnectionsClient) ListByVpnConnectionComplete(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string) (result ListVpnSiteLinkConnectionsResultIterator, err error) { 222 if tracing.IsEnabled() { 223 ctx = tracing.StartSpan(ctx, fqdn+"/VpnLinkConnectionsClient.ListByVpnConnection") 224 defer func() { 225 sc := -1 226 if result.Response().Response.Response != nil { 227 sc = result.page.Response().Response.Response.StatusCode 228 } 229 tracing.EndSpan(ctx, sc, err) 230 }() 231 } 232 result.page, err = client.ListByVpnConnection(ctx, resourceGroupName, gatewayName, connectionName) 233 return 234} 235 236// ResetConnection resets the VpnLink connection specified. 237// Parameters: 238// resourceGroupName - the name of the resource group. 239// gatewayName - the name of the gateway. 240// connectionName - the name of the vpn connection. 241// linkConnectionName - the name of the vpn link connection. 242func (client VpnLinkConnectionsClient) ResetConnection(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string) (result VpnLinkConnectionsResetConnectionFuture, err error) { 243 if tracing.IsEnabled() { 244 ctx = tracing.StartSpan(ctx, fqdn+"/VpnLinkConnectionsClient.ResetConnection") 245 defer func() { 246 sc := -1 247 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 248 sc = result.FutureAPI.Response().StatusCode 249 } 250 tracing.EndSpan(ctx, sc, err) 251 }() 252 } 253 req, err := client.ResetConnectionPreparer(ctx, resourceGroupName, gatewayName, connectionName, linkConnectionName) 254 if err != nil { 255 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "ResetConnection", nil, "Failure preparing request") 256 return 257 } 258 259 result, err = client.ResetConnectionSender(req) 260 if err != nil { 261 err = autorest.NewErrorWithError(err, "network.VpnLinkConnectionsClient", "ResetConnection", nil, "Failure sending request") 262 return 263 } 264 265 return 266} 267 268// ResetConnectionPreparer prepares the ResetConnection request. 269func (client VpnLinkConnectionsClient) ResetConnectionPreparer(ctx context.Context, resourceGroupName string, gatewayName string, connectionName string, linkConnectionName string) (*http.Request, error) { 270 pathParameters := map[string]interface{}{ 271 "connectionName": autorest.Encode("path", connectionName), 272 "gatewayName": autorest.Encode("path", gatewayName), 273 "linkConnectionName": autorest.Encode("path", linkConnectionName), 274 "resourceGroupName": autorest.Encode("path", resourceGroupName), 275 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 276 } 277 278 const APIVersion = "2020-11-01" 279 queryParameters := map[string]interface{}{ 280 "api-version": APIVersion, 281 } 282 283 preparer := autorest.CreatePreparer( 284 autorest.AsPost(), 285 autorest.WithBaseURL(client.BaseURI), 286 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}/resetconnection", pathParameters), 287 autorest.WithQueryParameters(queryParameters)) 288 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 289} 290 291// ResetConnectionSender sends the ResetConnection request. The method will close the 292// http.Response Body if it receives an error. 293func (client VpnLinkConnectionsClient) ResetConnectionSender(req *http.Request) (future VpnLinkConnectionsResetConnectionFuture, err error) { 294 var resp *http.Response 295 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 296 if err != nil { 297 return 298 } 299 var azf azure.Future 300 azf, err = azure.NewFutureFromResponse(resp) 301 future.FutureAPI = &azf 302 future.Result = future.result 303 return 304} 305 306// ResetConnectionResponder handles the response to the ResetConnection request. The method always 307// closes the http.Response Body. 308func (client VpnLinkConnectionsClient) ResetConnectionResponder(resp *http.Response) (result autorest.Response, err error) { 309 err = autorest.Respond( 310 resp, 311 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 312 autorest.ByClosing()) 313 result.Response = resp 314 return 315} 316