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// AvailableEndpointServicesClient is the network Client 29type AvailableEndpointServicesClient struct { 30 BaseClient 31} 32 33// NewAvailableEndpointServicesClient creates an instance of the AvailableEndpointServicesClient client. 34func NewAvailableEndpointServicesClient(subscriptionID string) AvailableEndpointServicesClient { 35 return NewAvailableEndpointServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewAvailableEndpointServicesClientWithBaseURI creates an instance of the AvailableEndpointServicesClient client 39// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign 40// clouds, Azure stack). 41func NewAvailableEndpointServicesClientWithBaseURI(baseURI string, subscriptionID string) AvailableEndpointServicesClient { 42 return AvailableEndpointServicesClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// List list what values of endpoint services are available for use. 46// Parameters: 47// location - the location to check available endpoint services. 48func (client AvailableEndpointServicesClient) List(ctx context.Context, location string) (result EndpointServicesListResultPage, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/AvailableEndpointServicesClient.List") 51 defer func() { 52 sc := -1 53 if result.eslr.Response.Response != nil { 54 sc = result.eslr.Response.Response.StatusCode 55 } 56 tracing.EndSpan(ctx, sc, err) 57 }() 58 } 59 result.fn = client.listNextResults 60 req, err := client.ListPreparer(ctx, location) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", nil, "Failure preparing request") 63 return 64 } 65 66 resp, err := client.ListSender(req) 67 if err != nil { 68 result.eslr.Response = autorest.Response{Response: resp} 69 err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", resp, "Failure sending request") 70 return 71 } 72 73 result.eslr, err = client.ListResponder(resp) 74 if err != nil { 75 err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", resp, "Failure responding to request") 76 return 77 } 78 if result.eslr.hasNextLink() && result.eslr.IsEmpty() { 79 err = result.NextWithContext(ctx) 80 return 81 } 82 83 return 84} 85 86// ListPreparer prepares the List request. 87func (client AvailableEndpointServicesClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) { 88 pathParameters := map[string]interface{}{ 89 "location": autorest.Encode("path", location), 90 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 91 } 92 93 const APIVersion = "2019-06-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}/providers/Microsoft.Network/locations/{location}/virtualNetworkAvailableEndpointServices", pathParameters), 102 autorest.WithQueryParameters(queryParameters)) 103 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 104} 105 106// ListSender sends the List request. The method will close the 107// http.Response Body if it receives an error. 108func (client AvailableEndpointServicesClient) ListSender(req *http.Request) (*http.Response, error) { 109 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 110} 111 112// ListResponder handles the response to the List request. The method always 113// closes the http.Response Body. 114func (client AvailableEndpointServicesClient) ListResponder(resp *http.Response) (result EndpointServicesListResult, 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// listNextResults retrieves the next set of results, if any. 125func (client AvailableEndpointServicesClient) listNextResults(ctx context.Context, lastResults EndpointServicesListResult) (result EndpointServicesListResult, err error) { 126 req, err := lastResults.endpointServicesListResultPreparer(ctx) 127 if err != nil { 128 return result, autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", nil, "Failure preparing next results request") 129 } 130 if req == nil { 131 return 132 } 133 resp, err := client.ListSender(req) 134 if err != nil { 135 result.Response = autorest.Response{Response: resp} 136 return result, autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", resp, "Failure sending next results request") 137 } 138 result, err = client.ListResponder(resp) 139 if err != nil { 140 err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", resp, "Failure responding to next results request") 141 } 142 return 143} 144 145// ListComplete enumerates all values, automatically crossing page boundaries as required. 146func (client AvailableEndpointServicesClient) ListComplete(ctx context.Context, location string) (result EndpointServicesListResultIterator, err error) { 147 if tracing.IsEnabled() { 148 ctx = tracing.StartSpan(ctx, fqdn+"/AvailableEndpointServicesClient.List") 149 defer func() { 150 sc := -1 151 if result.Response().Response.Response != nil { 152 sc = result.page.Response().Response.Response.StatusCode 153 } 154 tracing.EndSpan(ctx, sc, err) 155 }() 156 } 157 result.page, err = client.List(ctx, location) 158 return 159} 160