1 package network
2
3
4
5
6
7
8
9 import (
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
18 type ExpressRoutePortsLocationsClient struct {
19 BaseClient
20 }
21
22
23 func NewExpressRoutePortsLocationsClient(subscriptionID string) ExpressRoutePortsLocationsClient {
24 return NewExpressRoutePortsLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29
30 func NewExpressRoutePortsLocationsClientWithBaseURI(baseURI string, subscriptionID string) ExpressRoutePortsLocationsClient {
31 return ExpressRoutePortsLocationsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38 func (client ExpressRoutePortsLocationsClient) Get(ctx context.Context, locationName string) (result ExpressRoutePortsLocation, err error) {
39 if tracing.IsEnabled() {
40 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRoutePortsLocationsClient.Get")
41 defer func() {
42 sc := -1
43 if result.Response.Response != nil {
44 sc = result.Response.Response.StatusCode
45 }
46 tracing.EndSpan(ctx, sc, err)
47 }()
48 }
49 req, err := client.GetPreparer(ctx, locationName)
50 if err != nil {
51 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "Get", nil, "Failure preparing request")
52 return
53 }
54
55 resp, err := client.GetSender(req)
56 if err != nil {
57 result.Response = autorest.Response{Response: resp}
58 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "Get", resp, "Failure sending request")
59 return
60 }
61
62 result, err = client.GetResponder(resp)
63 if err != nil {
64 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "Get", resp, "Failure responding to request")
65 return
66 }
67
68 return
69 }
70
71
72 func (client ExpressRoutePortsLocationsClient) GetPreparer(ctx context.Context, locationName string) (*http.Request, error) {
73 pathParameters := map[string]interface{}{
74 "locationName": autorest.Encode("path", locationName),
75 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
76 }
77
78 const APIVersion = "2022-05-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}/providers/Microsoft.Network/ExpressRoutePortsLocations/{locationName}", pathParameters),
87 autorest.WithQueryParameters(queryParameters))
88 return preparer.Prepare((&http.Request{}).WithContext(ctx))
89 }
90
91
92
93 func (client ExpressRoutePortsLocationsClient) GetSender(req *http.Request) (*http.Response, error) {
94 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
95 }
96
97
98
99 func (client ExpressRoutePortsLocationsClient) GetResponder(resp *http.Response) (result ExpressRoutePortsLocation, err error) {
100 err = autorest.Respond(
101 resp,
102 azure.WithErrorUnlessStatusCode(http.StatusOK),
103 autorest.ByUnmarshallingJSON(&result),
104 autorest.ByClosing())
105 result.Response = autorest.Response{Response: resp}
106 return
107 }
108
109
110
111 func (client ExpressRoutePortsLocationsClient) List(ctx context.Context) (result ExpressRoutePortsLocationListResultPage, err error) {
112 if tracing.IsEnabled() {
113 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRoutePortsLocationsClient.List")
114 defer func() {
115 sc := -1
116 if result.erpllr.Response.Response != nil {
117 sc = result.erpllr.Response.Response.StatusCode
118 }
119 tracing.EndSpan(ctx, sc, err)
120 }()
121 }
122 result.fn = client.listNextResults
123 req, err := client.ListPreparer(ctx)
124 if err != nil {
125 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "List", nil, "Failure preparing request")
126 return
127 }
128
129 resp, err := client.ListSender(req)
130 if err != nil {
131 result.erpllr.Response = autorest.Response{Response: resp}
132 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "List", resp, "Failure sending request")
133 return
134 }
135
136 result.erpllr, err = client.ListResponder(resp)
137 if err != nil {
138 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "List", resp, "Failure responding to request")
139 return
140 }
141 if result.erpllr.hasNextLink() && result.erpllr.IsEmpty() {
142 err = result.NextWithContext(ctx)
143 return
144 }
145
146 return
147 }
148
149
150 func (client ExpressRoutePortsLocationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
151 pathParameters := map[string]interface{}{
152 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
153 }
154
155 const APIVersion = "2022-05-01"
156 queryParameters := map[string]interface{}{
157 "api-version": APIVersion,
158 }
159
160 preparer := autorest.CreatePreparer(
161 autorest.AsGet(),
162 autorest.WithBaseURL(client.BaseURI),
163 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/ExpressRoutePortsLocations", pathParameters),
164 autorest.WithQueryParameters(queryParameters))
165 return preparer.Prepare((&http.Request{}).WithContext(ctx))
166 }
167
168
169
170 func (client ExpressRoutePortsLocationsClient) ListSender(req *http.Request) (*http.Response, error) {
171 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
172 }
173
174
175
176 func (client ExpressRoutePortsLocationsClient) ListResponder(resp *http.Response) (result ExpressRoutePortsLocationListResult, err error) {
177 err = autorest.Respond(
178 resp,
179 azure.WithErrorUnlessStatusCode(http.StatusOK),
180 autorest.ByUnmarshallingJSON(&result),
181 autorest.ByClosing())
182 result.Response = autorest.Response{Response: resp}
183 return
184 }
185
186
187 func (client ExpressRoutePortsLocationsClient) listNextResults(ctx context.Context, lastResults ExpressRoutePortsLocationListResult) (result ExpressRoutePortsLocationListResult, err error) {
188 req, err := lastResults.expressRoutePortsLocationListResultPreparer(ctx)
189 if err != nil {
190 return result, autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "listNextResults", nil, "Failure preparing next results request")
191 }
192 if req == nil {
193 return
194 }
195 resp, err := client.ListSender(req)
196 if err != nil {
197 result.Response = autorest.Response{Response: resp}
198 return result, autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "listNextResults", resp, "Failure sending next results request")
199 }
200 result, err = client.ListResponder(resp)
201 if err != nil {
202 err = autorest.NewErrorWithError(err, "network.ExpressRoutePortsLocationsClient", "listNextResults", resp, "Failure responding to next results request")
203 }
204 return
205 }
206
207
208 func (client ExpressRoutePortsLocationsClient) ListComplete(ctx context.Context) (result ExpressRoutePortsLocationListResultIterator, err error) {
209 if tracing.IsEnabled() {
210 ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRoutePortsLocationsClient.List")
211 defer func() {
212 sc := -1
213 if result.Response().Response.Response != nil {
214 sc = result.page.Response().Response.Response.StatusCode
215 }
216 tracing.EndSpan(ctx, sc, err)
217 }()
218 }
219 result.page, err = client.List(ctx)
220 return
221 }
222
View as plain text