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// PeerExpressRouteCircuitConnectionsClient is the network Client 18type PeerExpressRouteCircuitConnectionsClient struct { 19 BaseClient 20} 21 22// NewPeerExpressRouteCircuitConnectionsClient creates an instance of the PeerExpressRouteCircuitConnectionsClient 23// client. 24func NewPeerExpressRouteCircuitConnectionsClient(subscriptionID string) PeerExpressRouteCircuitConnectionsClient { 25 return NewPeerExpressRouteCircuitConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewPeerExpressRouteCircuitConnectionsClientWithBaseURI creates an instance of the 29// PeerExpressRouteCircuitConnectionsClient client using a custom endpoint. Use this when interacting with an Azure 30// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewPeerExpressRouteCircuitConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PeerExpressRouteCircuitConnectionsClient { 32 return PeerExpressRouteCircuitConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Get gets the specified Peer Express Route Circuit Connection from the specified express route circuit. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// circuitName - the name of the express route circuit. 39// peeringName - the name of the peering. 40// connectionName - the name of the peer express route circuit connection. 41func (client PeerExpressRouteCircuitConnectionsClient) Get(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (result PeerExpressRouteCircuitConnection, err error) { 42 if tracing.IsEnabled() { 43 ctx = tracing.StartSpan(ctx, fqdn+"/PeerExpressRouteCircuitConnectionsClient.Get") 44 defer func() { 45 sc := -1 46 if result.Response.Response != nil { 47 sc = result.Response.Response.StatusCode 48 } 49 tracing.EndSpan(ctx, sc, err) 50 }() 51 } 52 req, err := client.GetPreparer(ctx, resourceGroupName, circuitName, peeringName, connectionName) 53 if err != nil { 54 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "Get", nil, "Failure preparing request") 55 return 56 } 57 58 resp, err := client.GetSender(req) 59 if err != nil { 60 result.Response = autorest.Response{Response: resp} 61 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "Get", resp, "Failure sending request") 62 return 63 } 64 65 result, err = client.GetResponder(resp) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "Get", resp, "Failure responding to request") 68 return 69 } 70 71 return 72} 73 74// GetPreparer prepares the Get request. 75func (client PeerExpressRouteCircuitConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string, connectionName string) (*http.Request, error) { 76 pathParameters := map[string]interface{}{ 77 "circuitName": autorest.Encode("path", circuitName), 78 "connectionName": autorest.Encode("path", connectionName), 79 "peeringName": autorest.Encode("path", peeringName), 80 "resourceGroupName": autorest.Encode("path", resourceGroupName), 81 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 82 } 83 84 const APIVersion = "2019-08-01" 85 queryParameters := map[string]interface{}{ 86 "api-version": APIVersion, 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsGet(), 91 autorest.WithBaseURL(client.BaseURI), 92 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/peerConnections/{connectionName}", pathParameters), 93 autorest.WithQueryParameters(queryParameters)) 94 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 95} 96 97// GetSender sends the Get request. The method will close the 98// http.Response Body if it receives an error. 99func (client PeerExpressRouteCircuitConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { 100 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 101} 102 103// GetResponder handles the response to the Get request. The method always 104// closes the http.Response Body. 105func (client PeerExpressRouteCircuitConnectionsClient) GetResponder(resp *http.Response) (result PeerExpressRouteCircuitConnection, err error) { 106 err = autorest.Respond( 107 resp, 108 azure.WithErrorUnlessStatusCode(http.StatusOK), 109 autorest.ByUnmarshallingJSON(&result), 110 autorest.ByClosing()) 111 result.Response = autorest.Response{Response: resp} 112 return 113} 114 115// List gets all global reach peer connections associated with a private peering in an express route circuit. 116// Parameters: 117// resourceGroupName - the name of the resource group. 118// circuitName - the name of the circuit. 119// peeringName - the name of the peering. 120func (client PeerExpressRouteCircuitConnectionsClient) List(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result PeerExpressRouteCircuitConnectionListResultPage, err error) { 121 if tracing.IsEnabled() { 122 ctx = tracing.StartSpan(ctx, fqdn+"/PeerExpressRouteCircuitConnectionsClient.List") 123 defer func() { 124 sc := -1 125 if result.percclr.Response.Response != nil { 126 sc = result.percclr.Response.Response.StatusCode 127 } 128 tracing.EndSpan(ctx, sc, err) 129 }() 130 } 131 result.fn = client.listNextResults 132 req, err := client.ListPreparer(ctx, resourceGroupName, circuitName, peeringName) 133 if err != nil { 134 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "List", nil, "Failure preparing request") 135 return 136 } 137 138 resp, err := client.ListSender(req) 139 if err != nil { 140 result.percclr.Response = autorest.Response{Response: resp} 141 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "List", resp, "Failure sending request") 142 return 143 } 144 145 result.percclr, err = client.ListResponder(resp) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "List", resp, "Failure responding to request") 148 return 149 } 150 if result.percclr.hasNextLink() && result.percclr.IsEmpty() { 151 err = result.NextWithContext(ctx) 152 return 153 } 154 155 return 156} 157 158// ListPreparer prepares the List request. 159func (client PeerExpressRouteCircuitConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (*http.Request, error) { 160 pathParameters := map[string]interface{}{ 161 "circuitName": autorest.Encode("path", circuitName), 162 "peeringName": autorest.Encode("path", peeringName), 163 "resourceGroupName": autorest.Encode("path", resourceGroupName), 164 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 165 } 166 167 const APIVersion = "2019-08-01" 168 queryParameters := map[string]interface{}{ 169 "api-version": APIVersion, 170 } 171 172 preparer := autorest.CreatePreparer( 173 autorest.AsGet(), 174 autorest.WithBaseURL(client.BaseURI), 175 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/peerConnections", pathParameters), 176 autorest.WithQueryParameters(queryParameters)) 177 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 178} 179 180// ListSender sends the List request. The method will close the 181// http.Response Body if it receives an error. 182func (client PeerExpressRouteCircuitConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { 183 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 184} 185 186// ListResponder handles the response to the List request. The method always 187// closes the http.Response Body. 188func (client PeerExpressRouteCircuitConnectionsClient) ListResponder(resp *http.Response) (result PeerExpressRouteCircuitConnectionListResult, err error) { 189 err = autorest.Respond( 190 resp, 191 azure.WithErrorUnlessStatusCode(http.StatusOK), 192 autorest.ByUnmarshallingJSON(&result), 193 autorest.ByClosing()) 194 result.Response = autorest.Response{Response: resp} 195 return 196} 197 198// listNextResults retrieves the next set of results, if any. 199func (client PeerExpressRouteCircuitConnectionsClient) listNextResults(ctx context.Context, lastResults PeerExpressRouteCircuitConnectionListResult) (result PeerExpressRouteCircuitConnectionListResult, err error) { 200 req, err := lastResults.peerExpressRouteCircuitConnectionListResultPreparer(ctx) 201 if err != nil { 202 return result, autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "listNextResults", nil, "Failure preparing next results request") 203 } 204 if req == nil { 205 return 206 } 207 resp, err := client.ListSender(req) 208 if err != nil { 209 result.Response = autorest.Response{Response: resp} 210 return result, autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "listNextResults", resp, "Failure sending next results request") 211 } 212 result, err = client.ListResponder(resp) 213 if err != nil { 214 err = autorest.NewErrorWithError(err, "network.PeerExpressRouteCircuitConnectionsClient", "listNextResults", resp, "Failure responding to next results request") 215 } 216 return 217} 218 219// ListComplete enumerates all values, automatically crossing page boundaries as required. 220func (client PeerExpressRouteCircuitConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, circuitName string, peeringName string) (result PeerExpressRouteCircuitConnectionListResultIterator, err error) { 221 if tracing.IsEnabled() { 222 ctx = tracing.StartSpan(ctx, fqdn+"/PeerExpressRouteCircuitConnectionsClient.List") 223 defer func() { 224 sc := -1 225 if result.Response().Response.Response != nil { 226 sc = result.page.Response().Response.Response.StatusCode 227 } 228 tracing.EndSpan(ctx, sc, err) 229 }() 230 } 231 result.page, err = client.List(ctx, resourceGroupName, circuitName, peeringName) 232 return 233} 234