1package network 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/tracing" 25 "net/http" 26) 27 28// LoadBalancerFrontendIPConfigurationsClient is the network Client 29type LoadBalancerFrontendIPConfigurationsClient struct { 30 BaseClient 31} 32 33// NewLoadBalancerFrontendIPConfigurationsClient creates an instance of the LoadBalancerFrontendIPConfigurationsClient 34// client. 35func NewLoadBalancerFrontendIPConfigurationsClient(subscriptionID string) LoadBalancerFrontendIPConfigurationsClient { 36 return NewLoadBalancerFrontendIPConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewLoadBalancerFrontendIPConfigurationsClientWithBaseURI creates an instance of the 40// LoadBalancerFrontendIPConfigurationsClient client using a custom endpoint. Use this when interacting with an Azure 41// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewLoadBalancerFrontendIPConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) LoadBalancerFrontendIPConfigurationsClient { 43 return LoadBalancerFrontendIPConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// Get gets load balancer frontend IP configuration. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// loadBalancerName - the name of the load balancer. 50// frontendIPConfigurationName - the name of the frontend IP configuration. 51func (client LoadBalancerFrontendIPConfigurationsClient) Get(ctx context.Context, resourceGroupName string, loadBalancerName string, frontendIPConfigurationName string) (result FrontendIPConfiguration, err error) { 52 if tracing.IsEnabled() { 53 ctx = tracing.StartSpan(ctx, fqdn+"/LoadBalancerFrontendIPConfigurationsClient.Get") 54 defer func() { 55 sc := -1 56 if result.Response.Response != nil { 57 sc = result.Response.Response.StatusCode 58 } 59 tracing.EndSpan(ctx, sc, err) 60 }() 61 } 62 req, err := client.GetPreparer(ctx, resourceGroupName, loadBalancerName, frontendIPConfigurationName) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "Get", nil, "Failure preparing request") 65 return 66 } 67 68 resp, err := client.GetSender(req) 69 if err != nil { 70 result.Response = autorest.Response{Response: resp} 71 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "Get", resp, "Failure sending request") 72 return 73 } 74 75 result, err = client.GetResponder(resp) 76 if err != nil { 77 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "Get", resp, "Failure responding to request") 78 return 79 } 80 81 return 82} 83 84// GetPreparer prepares the Get request. 85func (client LoadBalancerFrontendIPConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, loadBalancerName string, frontendIPConfigurationName string) (*http.Request, error) { 86 pathParameters := map[string]interface{}{ 87 "frontendIPConfigurationName": autorest.Encode("path", frontendIPConfigurationName), 88 "loadBalancerName": autorest.Encode("path", loadBalancerName), 89 "resourceGroupName": autorest.Encode("path", resourceGroupName), 90 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 91 } 92 93 const APIVersion = "2019-07-01" 94 queryParameters := map[string]interface{}{ 95 "api-version": APIVersion, 96 } 97 98 preparer := autorest.CreatePreparer( 99 autorest.AsGet(), 100 autorest.WithBaseURL(client.BaseURI), 101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/frontendIPConfigurations/{frontendIPConfigurationName}", pathParameters), 102 autorest.WithQueryParameters(queryParameters)) 103 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 104} 105 106// GetSender sends the Get request. The method will close the 107// http.Response Body if it receives an error. 108func (client LoadBalancerFrontendIPConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { 109 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 110} 111 112// GetResponder handles the response to the Get request. The method always 113// closes the http.Response Body. 114func (client LoadBalancerFrontendIPConfigurationsClient) GetResponder(resp *http.Response) (result FrontendIPConfiguration, err error) { 115 err = autorest.Respond( 116 resp, 117 azure.WithErrorUnlessStatusCode(http.StatusOK), 118 autorest.ByUnmarshallingJSON(&result), 119 autorest.ByClosing()) 120 result.Response = autorest.Response{Response: resp} 121 return 122} 123 124// List gets all the load balancer frontend IP configurations. 125// Parameters: 126// resourceGroupName - the name of the resource group. 127// loadBalancerName - the name of the load balancer. 128func (client LoadBalancerFrontendIPConfigurationsClient) List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result LoadBalancerFrontendIPConfigurationListResultPage, err error) { 129 if tracing.IsEnabled() { 130 ctx = tracing.StartSpan(ctx, fqdn+"/LoadBalancerFrontendIPConfigurationsClient.List") 131 defer func() { 132 sc := -1 133 if result.lbficlr.Response.Response != nil { 134 sc = result.lbficlr.Response.Response.StatusCode 135 } 136 tracing.EndSpan(ctx, sc, err) 137 }() 138 } 139 result.fn = client.listNextResults 140 req, err := client.ListPreparer(ctx, resourceGroupName, loadBalancerName) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "List", nil, "Failure preparing request") 143 return 144 } 145 146 resp, err := client.ListSender(req) 147 if err != nil { 148 result.lbficlr.Response = autorest.Response{Response: resp} 149 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "List", resp, "Failure sending request") 150 return 151 } 152 153 result.lbficlr, err = client.ListResponder(resp) 154 if err != nil { 155 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "List", resp, "Failure responding to request") 156 return 157 } 158 if result.lbficlr.hasNextLink() && result.lbficlr.IsEmpty() { 159 err = result.NextWithContext(ctx) 160 return 161 } 162 163 return 164} 165 166// ListPreparer prepares the List request. 167func (client LoadBalancerFrontendIPConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, loadBalancerName string) (*http.Request, error) { 168 pathParameters := map[string]interface{}{ 169 "loadBalancerName": autorest.Encode("path", loadBalancerName), 170 "resourceGroupName": autorest.Encode("path", resourceGroupName), 171 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 172 } 173 174 const APIVersion = "2019-07-01" 175 queryParameters := map[string]interface{}{ 176 "api-version": APIVersion, 177 } 178 179 preparer := autorest.CreatePreparer( 180 autorest.AsGet(), 181 autorest.WithBaseURL(client.BaseURI), 182 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/frontendIPConfigurations", pathParameters), 183 autorest.WithQueryParameters(queryParameters)) 184 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 185} 186 187// ListSender sends the List request. The method will close the 188// http.Response Body if it receives an error. 189func (client LoadBalancerFrontendIPConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { 190 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 191} 192 193// ListResponder handles the response to the List request. The method always 194// closes the http.Response Body. 195func (client LoadBalancerFrontendIPConfigurationsClient) ListResponder(resp *http.Response) (result LoadBalancerFrontendIPConfigurationListResult, err error) { 196 err = autorest.Respond( 197 resp, 198 azure.WithErrorUnlessStatusCode(http.StatusOK), 199 autorest.ByUnmarshallingJSON(&result), 200 autorest.ByClosing()) 201 result.Response = autorest.Response{Response: resp} 202 return 203} 204 205// listNextResults retrieves the next set of results, if any. 206func (client LoadBalancerFrontendIPConfigurationsClient) listNextResults(ctx context.Context, lastResults LoadBalancerFrontendIPConfigurationListResult) (result LoadBalancerFrontendIPConfigurationListResult, err error) { 207 req, err := lastResults.loadBalancerFrontendIPConfigurationListResultPreparer(ctx) 208 if err != nil { 209 return result, autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "listNextResults", nil, "Failure preparing next results request") 210 } 211 if req == nil { 212 return 213 } 214 resp, err := client.ListSender(req) 215 if err != nil { 216 result.Response = autorest.Response{Response: resp} 217 return result, autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "listNextResults", resp, "Failure sending next results request") 218 } 219 result, err = client.ListResponder(resp) 220 if err != nil { 221 err = autorest.NewErrorWithError(err, "network.LoadBalancerFrontendIPConfigurationsClient", "listNextResults", resp, "Failure responding to next results request") 222 } 223 return 224} 225 226// ListComplete enumerates all values, automatically crossing page boundaries as required. 227func (client LoadBalancerFrontendIPConfigurationsClient) ListComplete(ctx context.Context, resourceGroupName string, loadBalancerName string) (result LoadBalancerFrontendIPConfigurationListResultIterator, err error) { 228 if tracing.IsEnabled() { 229 ctx = tracing.StartSpan(ctx, fqdn+"/LoadBalancerFrontendIPConfigurationsClient.List") 230 defer func() { 231 sc := -1 232 if result.Response().Response.Response != nil { 233 sc = result.page.Response().Response.Response.StatusCode 234 } 235 tracing.EndSpan(ctx, sc, err) 236 }() 237 } 238 result.page, err = client.List(ctx, resourceGroupName, loadBalancerName) 239 return 240} 241