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// AvailableEndpointServicesClient is the network Client
28type AvailableEndpointServicesClient struct {
29	BaseClient
30}
31
32// NewAvailableEndpointServicesClient creates an instance of the AvailableEndpointServicesClient client.
33func NewAvailableEndpointServicesClient(subscriptionID string) AvailableEndpointServicesClient {
34	return NewAvailableEndpointServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
35}
36
37// NewAvailableEndpointServicesClientWithBaseURI creates an instance of the AvailableEndpointServicesClient client.
38func NewAvailableEndpointServicesClientWithBaseURI(baseURI string, subscriptionID string) AvailableEndpointServicesClient {
39	return AvailableEndpointServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
40}
41
42// List list what values of endpoint services are available for use.
43// Parameters:
44// location - the location to check available endpoint services.
45func (client AvailableEndpointServicesClient) List(ctx context.Context, location string) (result EndpointServicesListResultPage, err error) {
46	result.fn = client.listNextResults
47	req, err := client.ListPreparer(ctx, location)
48	if err != nil {
49		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", nil, "Failure preparing request")
50		return
51	}
52
53	resp, err := client.ListSender(req)
54	if err != nil {
55		result.eslr.Response = autorest.Response{Response: resp}
56		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", resp, "Failure sending request")
57		return
58	}
59
60	result.eslr, err = client.ListResponder(resp)
61	if err != nil {
62		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", resp, "Failure responding to request")
63	}
64
65	return
66}
67
68// ListPreparer prepares the List request.
69func (client AvailableEndpointServicesClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
70	pathParameters := map[string]interface{}{
71		"location":       autorest.Encode("path", location),
72		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
73	}
74
75	const APIVersion = "2018-04-01"
76	queryParameters := map[string]interface{}{
77		"api-version": APIVersion,
78	}
79
80	preparer := autorest.CreatePreparer(
81		autorest.AsGet(),
82		autorest.WithBaseURL(client.BaseURI),
83		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/virtualNetworkAvailableEndpointServices", pathParameters),
84		autorest.WithQueryParameters(queryParameters))
85	return preparer.Prepare((&http.Request{}).WithContext(ctx))
86}
87
88// ListSender sends the List request. The method will close the
89// http.Response Body if it receives an error.
90func (client AvailableEndpointServicesClient) ListSender(req *http.Request) (*http.Response, error) {
91	return autorest.SendWithSender(client, req,
92		azure.DoRetryWithRegistration(client.Client))
93}
94
95// ListResponder handles the response to the List request. The method always
96// closes the http.Response Body.
97func (client AvailableEndpointServicesClient) ListResponder(resp *http.Response) (result EndpointServicesListResult, err error) {
98	err = autorest.Respond(
99		resp,
100		client.ByInspecting(),
101		azure.WithErrorUnlessStatusCode(http.StatusOK),
102		autorest.ByUnmarshallingJSON(&result),
103		autorest.ByClosing())
104	result.Response = autorest.Response{Response: resp}
105	return
106}
107
108// listNextResults retrieves the next set of results, if any.
109func (client AvailableEndpointServicesClient) listNextResults(lastResults EndpointServicesListResult) (result EndpointServicesListResult, err error) {
110	req, err := lastResults.endpointServicesListResultPreparer()
111	if err != nil {
112		return result, autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", nil, "Failure preparing next results request")
113	}
114	if req == nil {
115		return
116	}
117	resp, err := client.ListSender(req)
118	if err != nil {
119		result.Response = autorest.Response{Response: resp}
120		return result, autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", resp, "Failure sending next results request")
121	}
122	result, err = client.ListResponder(resp)
123	if err != nil {
124		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", resp, "Failure responding to next results request")
125	}
126	return
127}
128
129// ListComplete enumerates all values, automatically crossing page boundaries as required.
130func (client AvailableEndpointServicesClient) ListComplete(ctx context.Context, location string) (result EndpointServicesListResultIterator, err error) {
131	result.page, err = client.List(ctx, location)
132	return
133}
134