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 "net/http" 25) 26 27// LoadBalancerProbesClient is the network Client 28type LoadBalancerProbesClient struct { 29 BaseClient 30} 31 32// NewLoadBalancerProbesClient creates an instance of the LoadBalancerProbesClient client. 33func NewLoadBalancerProbesClient(subscriptionID string) LoadBalancerProbesClient { 34 return NewLoadBalancerProbesClientWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewLoadBalancerProbesClientWithBaseURI creates an instance of the LoadBalancerProbesClient client. 38func NewLoadBalancerProbesClientWithBaseURI(baseURI string, subscriptionID string) LoadBalancerProbesClient { 39 return LoadBalancerProbesClient{NewWithBaseURI(baseURI, subscriptionID)} 40} 41 42// Get gets load balancer probe. 43// Parameters: 44// resourceGroupName - the name of the resource group. 45// loadBalancerName - the name of the load balancer. 46// probeName - the name of the probe. 47func (client LoadBalancerProbesClient) Get(ctx context.Context, resourceGroupName string, loadBalancerName string, probeName string) (result Probe, err error) { 48 req, err := client.GetPreparer(ctx, resourceGroupName, loadBalancerName, probeName) 49 if err != nil { 50 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "Get", nil, "Failure preparing request") 51 return 52 } 53 54 resp, err := client.GetSender(req) 55 if err != nil { 56 result.Response = autorest.Response{Response: resp} 57 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "Get", resp, "Failure sending request") 58 return 59 } 60 61 result, err = client.GetResponder(resp) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "Get", resp, "Failure responding to request") 64 } 65 66 return 67} 68 69// GetPreparer prepares the Get request. 70func (client LoadBalancerProbesClient) GetPreparer(ctx context.Context, resourceGroupName string, loadBalancerName string, probeName string) (*http.Request, error) { 71 pathParameters := map[string]interface{}{ 72 "loadBalancerName": autorest.Encode("path", loadBalancerName), 73 "probeName": autorest.Encode("path", probeName), 74 "resourceGroupName": autorest.Encode("path", resourceGroupName), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 } 77 78 const APIVersion = "2017-11-01" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 preparer := autorest.CreatePreparer( 84 autorest.AsGet(), 85 autorest.WithBaseURL(client.BaseURI), 86 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}", pathParameters), 87 autorest.WithQueryParameters(queryParameters)) 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// GetSender sends the Get request. The method will close the 92// http.Response Body if it receives an error. 93func (client LoadBalancerProbesClient) GetSender(req *http.Request) (*http.Response, error) { 94 return autorest.SendWithSender(client, req, 95 azure.DoRetryWithRegistration(client.Client)) 96} 97 98// GetResponder handles the response to the Get request. The method always 99// closes the http.Response Body. 100func (client LoadBalancerProbesClient) GetResponder(resp *http.Response) (result Probe, err error) { 101 err = autorest.Respond( 102 resp, 103 client.ByInspecting(), 104 azure.WithErrorUnlessStatusCode(http.StatusOK), 105 autorest.ByUnmarshallingJSON(&result), 106 autorest.ByClosing()) 107 result.Response = autorest.Response{Response: resp} 108 return 109} 110 111// List gets all the load balancer probes. 112// Parameters: 113// resourceGroupName - the name of the resource group. 114// loadBalancerName - the name of the load balancer. 115func (client LoadBalancerProbesClient) List(ctx context.Context, resourceGroupName string, loadBalancerName string) (result LoadBalancerProbeListResultPage, err error) { 116 result.fn = client.listNextResults 117 req, err := client.ListPreparer(ctx, resourceGroupName, loadBalancerName) 118 if err != nil { 119 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "List", nil, "Failure preparing request") 120 return 121 } 122 123 resp, err := client.ListSender(req) 124 if err != nil { 125 result.lbplr.Response = autorest.Response{Response: resp} 126 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "List", resp, "Failure sending request") 127 return 128 } 129 130 result.lbplr, err = client.ListResponder(resp) 131 if err != nil { 132 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "List", resp, "Failure responding to request") 133 } 134 135 return 136} 137 138// ListPreparer prepares the List request. 139func (client LoadBalancerProbesClient) ListPreparer(ctx context.Context, resourceGroupName string, loadBalancerName string) (*http.Request, error) { 140 pathParameters := map[string]interface{}{ 141 "loadBalancerName": autorest.Encode("path", loadBalancerName), 142 "resourceGroupName": autorest.Encode("path", resourceGroupName), 143 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 144 } 145 146 const APIVersion = "2017-11-01" 147 queryParameters := map[string]interface{}{ 148 "api-version": APIVersion, 149 } 150 151 preparer := autorest.CreatePreparer( 152 autorest.AsGet(), 153 autorest.WithBaseURL(client.BaseURI), 154 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes", pathParameters), 155 autorest.WithQueryParameters(queryParameters)) 156 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 157} 158 159// ListSender sends the List request. The method will close the 160// http.Response Body if it receives an error. 161func (client LoadBalancerProbesClient) ListSender(req *http.Request) (*http.Response, error) { 162 return autorest.SendWithSender(client, req, 163 azure.DoRetryWithRegistration(client.Client)) 164} 165 166// ListResponder handles the response to the List request. The method always 167// closes the http.Response Body. 168func (client LoadBalancerProbesClient) ListResponder(resp *http.Response) (result LoadBalancerProbeListResult, err error) { 169 err = autorest.Respond( 170 resp, 171 client.ByInspecting(), 172 azure.WithErrorUnlessStatusCode(http.StatusOK), 173 autorest.ByUnmarshallingJSON(&result), 174 autorest.ByClosing()) 175 result.Response = autorest.Response{Response: resp} 176 return 177} 178 179// listNextResults retrieves the next set of results, if any. 180func (client LoadBalancerProbesClient) listNextResults(lastResults LoadBalancerProbeListResult) (result LoadBalancerProbeListResult, err error) { 181 req, err := lastResults.loadBalancerProbeListResultPreparer() 182 if err != nil { 183 return result, autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "listNextResults", nil, "Failure preparing next results request") 184 } 185 if req == nil { 186 return 187 } 188 resp, err := client.ListSender(req) 189 if err != nil { 190 result.Response = autorest.Response{Response: resp} 191 return result, autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "listNextResults", resp, "Failure sending next results request") 192 } 193 result, err = client.ListResponder(resp) 194 if err != nil { 195 err = autorest.NewErrorWithError(err, "network.LoadBalancerProbesClient", "listNextResults", resp, "Failure responding to next results request") 196 } 197 return 198} 199 200// ListComplete enumerates all values, automatically crossing page boundaries as required. 201func (client LoadBalancerProbesClient) ListComplete(ctx context.Context, resourceGroupName string, loadBalancerName string) (result LoadBalancerProbeListResultIterator, err error) { 202 result.page, err = client.List(ctx, resourceGroupName, loadBalancerName) 203 return 204} 205