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 P2sVpnGatewaysClient struct {
19 BaseClient
20 }
21
22
23 func NewP2sVpnGatewaysClient(subscriptionID string) P2sVpnGatewaysClient {
24 return NewP2sVpnGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29 func NewP2sVpnGatewaysClientWithBaseURI(baseURI string, subscriptionID string) P2sVpnGatewaysClient {
30 return P2sVpnGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
31 }
32
33
34
35
36
37
38 func (client P2sVpnGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters P2SVpnGateway) (result P2sVpnGatewaysCreateOrUpdateFuture, err error) {
39 if tracing.IsEnabled() {
40 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.CreateOrUpdate")
41 defer func() {
42 sc := -1
43 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
44 sc = result.FutureAPI.Response().StatusCode
45 }
46 tracing.EndSpan(ctx, sc, err)
47 }()
48 }
49 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, gatewayName, p2SVpnGatewayParameters)
50 if err != nil {
51 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
52 return
53 }
54
55 result, err = client.CreateOrUpdateSender(req)
56 if err != nil {
57 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "CreateOrUpdate", result.Response(), "Failure sending request")
58 return
59 }
60
61 return
62 }
63
64
65 func (client P2sVpnGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters P2SVpnGateway) (*http.Request, error) {
66 pathParameters := map[string]interface{}{
67 "gatewayName": autorest.Encode("path", gatewayName),
68 "resourceGroupName": autorest.Encode("path", resourceGroupName),
69 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
70 }
71
72 const APIVersion = "2022-05-01"
73 queryParameters := map[string]interface{}{
74 "api-version": APIVersion,
75 }
76
77 p2SVpnGatewayParameters.Etag = nil
78 preparer := autorest.CreatePreparer(
79 autorest.AsContentType("application/json; charset=utf-8"),
80 autorest.AsPut(),
81 autorest.WithBaseURL(client.BaseURI),
82 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters),
83 autorest.WithJSON(p2SVpnGatewayParameters),
84 autorest.WithQueryParameters(queryParameters))
85 return preparer.Prepare((&http.Request{}).WithContext(ctx))
86 }
87
88
89
90 func (client P2sVpnGatewaysClient) CreateOrUpdateSender(req *http.Request) (future P2sVpnGatewaysCreateOrUpdateFuture, err error) {
91 var resp *http.Response
92 future.FutureAPI = &azure.Future{}
93 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
94 if err != nil {
95 return
96 }
97 var azf azure.Future
98 azf, err = azure.NewFutureFromResponse(resp)
99 future.FutureAPI = &azf
100 future.Result = future.result
101 return
102 }
103
104
105
106 func (client P2sVpnGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result P2SVpnGateway, err error) {
107 err = autorest.Respond(
108 resp,
109 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
110 autorest.ByUnmarshallingJSON(&result),
111 autorest.ByClosing())
112 result.Response = autorest.Response{Response: resp}
113 return
114 }
115
116
117
118
119
120 func (client P2sVpnGatewaysClient) Delete(ctx context.Context, resourceGroupName string, gatewayName string) (result P2sVpnGatewaysDeleteFuture, err error) {
121 if tracing.IsEnabled() {
122 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Delete")
123 defer func() {
124 sc := -1
125 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
126 sc = result.FutureAPI.Response().StatusCode
127 }
128 tracing.EndSpan(ctx, sc, err)
129 }()
130 }
131 req, err := client.DeletePreparer(ctx, resourceGroupName, gatewayName)
132 if err != nil {
133 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Delete", nil, "Failure preparing request")
134 return
135 }
136
137 result, err = client.DeleteSender(req)
138 if err != nil {
139 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Delete", result.Response(), "Failure sending request")
140 return
141 }
142
143 return
144 }
145
146
147 func (client P2sVpnGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) {
148 pathParameters := map[string]interface{}{
149 "gatewayName": autorest.Encode("path", gatewayName),
150 "resourceGroupName": autorest.Encode("path", resourceGroupName),
151 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
152 }
153
154 const APIVersion = "2022-05-01"
155 queryParameters := map[string]interface{}{
156 "api-version": APIVersion,
157 }
158
159 preparer := autorest.CreatePreparer(
160 autorest.AsDelete(),
161 autorest.WithBaseURL(client.BaseURI),
162 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters),
163 autorest.WithQueryParameters(queryParameters))
164 return preparer.Prepare((&http.Request{}).WithContext(ctx))
165 }
166
167
168
169 func (client P2sVpnGatewaysClient) DeleteSender(req *http.Request) (future P2sVpnGatewaysDeleteFuture, err error) {
170 var resp *http.Response
171 future.FutureAPI = &azure.Future{}
172 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
173 if err != nil {
174 return
175 }
176 var azf azure.Future
177 azf, err = azure.NewFutureFromResponse(resp)
178 future.FutureAPI = &azf
179 future.Result = future.result
180 return
181 }
182
183
184
185 func (client P2sVpnGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
186 err = autorest.Respond(
187 resp,
188 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
189 autorest.ByClosing())
190 result.Response = resp
191 return
192 }
193
194
195
196
197
198
199
200 func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnections(ctx context.Context, resourceGroupName string, p2sVpnGatewayName string, request P2SVpnConnectionRequest) (result P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture, err error) {
201 if tracing.IsEnabled() {
202 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.DisconnectP2sVpnConnections")
203 defer func() {
204 sc := -1
205 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
206 sc = result.FutureAPI.Response().StatusCode
207 }
208 tracing.EndSpan(ctx, sc, err)
209 }()
210 }
211 req, err := client.DisconnectP2sVpnConnectionsPreparer(ctx, resourceGroupName, p2sVpnGatewayName, request)
212 if err != nil {
213 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "DisconnectP2sVpnConnections", nil, "Failure preparing request")
214 return
215 }
216
217 result, err = client.DisconnectP2sVpnConnectionsSender(req)
218 if err != nil {
219 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "DisconnectP2sVpnConnections", result.Response(), "Failure sending request")
220 return
221 }
222
223 return
224 }
225
226
227 func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsPreparer(ctx context.Context, resourceGroupName string, p2sVpnGatewayName string, request P2SVpnConnectionRequest) (*http.Request, error) {
228 pathParameters := map[string]interface{}{
229 "p2sVpnGatewayName": autorest.Encode("path", p2sVpnGatewayName),
230 "resourceGroupName": autorest.Encode("path", resourceGroupName),
231 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
232 }
233
234 const APIVersion = "2022-05-01"
235 queryParameters := map[string]interface{}{
236 "api-version": APIVersion,
237 }
238
239 preparer := autorest.CreatePreparer(
240 autorest.AsContentType("application/json; charset=utf-8"),
241 autorest.AsPost(),
242 autorest.WithBaseURL(client.BaseURI),
243 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{p2sVpnGatewayName}/disconnectP2sVpnConnections", pathParameters),
244 autorest.WithJSON(request),
245 autorest.WithQueryParameters(queryParameters))
246 return preparer.Prepare((&http.Request{}).WithContext(ctx))
247 }
248
249
250
251 func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsSender(req *http.Request) (future P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture, err error) {
252 var resp *http.Response
253 future.FutureAPI = &azure.Future{}
254 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
255 if err != nil {
256 return
257 }
258 var azf azure.Future
259 azf, err = azure.NewFutureFromResponse(resp)
260 future.FutureAPI = &azf
261 future.Result = future.result
262 return
263 }
264
265
266
267 func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsResponder(resp *http.Response) (result autorest.Response, err error) {
268 err = autorest.Respond(
269 resp,
270 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
271 autorest.ByClosing())
272 result.Response = resp
273 return
274 }
275
276
277
278
279
280
281 func (client P2sVpnGatewaysClient) GenerateVpnProfile(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVpnProfileParameters) (result P2sVpnGatewaysGenerateVpnProfileFuture, err error) {
282 if tracing.IsEnabled() {
283 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GenerateVpnProfile")
284 defer func() {
285 sc := -1
286 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
287 sc = result.FutureAPI.Response().StatusCode
288 }
289 tracing.EndSpan(ctx, sc, err)
290 }()
291 }
292 req, err := client.GenerateVpnProfilePreparer(ctx, resourceGroupName, gatewayName, parameters)
293 if err != nil {
294 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GenerateVpnProfile", nil, "Failure preparing request")
295 return
296 }
297
298 result, err = client.GenerateVpnProfileSender(req)
299 if err != nil {
300 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GenerateVpnProfile", result.Response(), "Failure sending request")
301 return
302 }
303
304 return
305 }
306
307
308 func (client P2sVpnGatewaysClient) GenerateVpnProfilePreparer(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVpnProfileParameters) (*http.Request, error) {
309 pathParameters := map[string]interface{}{
310 "gatewayName": autorest.Encode("path", gatewayName),
311 "resourceGroupName": autorest.Encode("path", resourceGroupName),
312 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
313 }
314
315 const APIVersion = "2022-05-01"
316 queryParameters := map[string]interface{}{
317 "api-version": APIVersion,
318 }
319
320 preparer := autorest.CreatePreparer(
321 autorest.AsContentType("application/json; charset=utf-8"),
322 autorest.AsPost(),
323 autorest.WithBaseURL(client.BaseURI),
324 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/generatevpnprofile", pathParameters),
325 autorest.WithJSON(parameters),
326 autorest.WithQueryParameters(queryParameters))
327 return preparer.Prepare((&http.Request{}).WithContext(ctx))
328 }
329
330
331
332 func (client P2sVpnGatewaysClient) GenerateVpnProfileSender(req *http.Request) (future P2sVpnGatewaysGenerateVpnProfileFuture, err error) {
333 var resp *http.Response
334 future.FutureAPI = &azure.Future{}
335 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
336 if err != nil {
337 return
338 }
339 var azf azure.Future
340 azf, err = azure.NewFutureFromResponse(resp)
341 future.FutureAPI = &azf
342 future.Result = future.result
343 return
344 }
345
346
347
348 func (client P2sVpnGatewaysClient) GenerateVpnProfileResponder(resp *http.Response) (result VpnProfileResponse, err error) {
349 err = autorest.Respond(
350 resp,
351 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
352 autorest.ByUnmarshallingJSON(&result),
353 autorest.ByClosing())
354 result.Response = autorest.Response{Response: resp}
355 return
356 }
357
358
359
360
361
362 func (client P2sVpnGatewaysClient) Get(ctx context.Context, resourceGroupName string, gatewayName string) (result P2SVpnGateway, err error) {
363 if tracing.IsEnabled() {
364 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Get")
365 defer func() {
366 sc := -1
367 if result.Response.Response != nil {
368 sc = result.Response.Response.StatusCode
369 }
370 tracing.EndSpan(ctx, sc, err)
371 }()
372 }
373 req, err := client.GetPreparer(ctx, resourceGroupName, gatewayName)
374 if err != nil {
375 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", nil, "Failure preparing request")
376 return
377 }
378
379 resp, err := client.GetSender(req)
380 if err != nil {
381 result.Response = autorest.Response{Response: resp}
382 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", resp, "Failure sending request")
383 return
384 }
385
386 result, err = client.GetResponder(resp)
387 if err != nil {
388 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", resp, "Failure responding to request")
389 return
390 }
391
392 return
393 }
394
395
396 func (client P2sVpnGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) {
397 pathParameters := map[string]interface{}{
398 "gatewayName": autorest.Encode("path", gatewayName),
399 "resourceGroupName": autorest.Encode("path", resourceGroupName),
400 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
401 }
402
403 const APIVersion = "2022-05-01"
404 queryParameters := map[string]interface{}{
405 "api-version": APIVersion,
406 }
407
408 preparer := autorest.CreatePreparer(
409 autorest.AsGet(),
410 autorest.WithBaseURL(client.BaseURI),
411 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters),
412 autorest.WithQueryParameters(queryParameters))
413 return preparer.Prepare((&http.Request{}).WithContext(ctx))
414 }
415
416
417
418 func (client P2sVpnGatewaysClient) GetSender(req *http.Request) (*http.Response, error) {
419 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
420 }
421
422
423
424 func (client P2sVpnGatewaysClient) GetResponder(resp *http.Response) (result P2SVpnGateway, err error) {
425 err = autorest.Respond(
426 resp,
427 azure.WithErrorUnlessStatusCode(http.StatusOK),
428 autorest.ByUnmarshallingJSON(&result),
429 autorest.ByClosing())
430 result.Response = autorest.Response{Response: resp}
431 return
432 }
433
434
435
436
437
438
439 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealth(ctx context.Context, resourceGroupName string, gatewayName string) (result P2sVpnGatewaysGetP2sVpnConnectionHealthFuture, err error) {
440 if tracing.IsEnabled() {
441 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GetP2sVpnConnectionHealth")
442 defer func() {
443 sc := -1
444 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
445 sc = result.FutureAPI.Response().StatusCode
446 }
447 tracing.EndSpan(ctx, sc, err)
448 }()
449 }
450 req, err := client.GetP2sVpnConnectionHealthPreparer(ctx, resourceGroupName, gatewayName)
451 if err != nil {
452 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealth", nil, "Failure preparing request")
453 return
454 }
455
456 result, err = client.GetP2sVpnConnectionHealthSender(req)
457 if err != nil {
458 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealth", result.Response(), "Failure sending request")
459 return
460 }
461
462 return
463 }
464
465
466 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) {
467 pathParameters := map[string]interface{}{
468 "gatewayName": autorest.Encode("path", gatewayName),
469 "resourceGroupName": autorest.Encode("path", resourceGroupName),
470 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
471 }
472
473 const APIVersion = "2022-05-01"
474 queryParameters := map[string]interface{}{
475 "api-version": APIVersion,
476 }
477
478 preparer := autorest.CreatePreparer(
479 autorest.AsPost(),
480 autorest.WithBaseURL(client.BaseURI),
481 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealth", pathParameters),
482 autorest.WithQueryParameters(queryParameters))
483 return preparer.Prepare((&http.Request{}).WithContext(ctx))
484 }
485
486
487
488 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthSender(req *http.Request) (future P2sVpnGatewaysGetP2sVpnConnectionHealthFuture, err error) {
489 var resp *http.Response
490 future.FutureAPI = &azure.Future{}
491 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
492 if err != nil {
493 return
494 }
495 var azf azure.Future
496 azf, err = azure.NewFutureFromResponse(resp)
497 future.FutureAPI = &azf
498 future.Result = future.result
499 return
500 }
501
502
503
504 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthResponder(resp *http.Response) (result P2SVpnGateway, err error) {
505 err = autorest.Respond(
506 resp,
507 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
508 autorest.ByUnmarshallingJSON(&result),
509 autorest.ByClosing())
510 result.Response = autorest.Response{Response: resp}
511 return
512 }
513
514
515
516
517
518
519
520 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailed(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVpnConnectionHealthRequest) (result P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture, err error) {
521 if tracing.IsEnabled() {
522 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GetP2sVpnConnectionHealthDetailed")
523 defer func() {
524 sc := -1
525 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
526 sc = result.FutureAPI.Response().StatusCode
527 }
528 tracing.EndSpan(ctx, sc, err)
529 }()
530 }
531 req, err := client.GetP2sVpnConnectionHealthDetailedPreparer(ctx, resourceGroupName, gatewayName, request)
532 if err != nil {
533 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealthDetailed", nil, "Failure preparing request")
534 return
535 }
536
537 result, err = client.GetP2sVpnConnectionHealthDetailedSender(req)
538 if err != nil {
539 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealthDetailed", result.Response(), "Failure sending request")
540 return
541 }
542
543 return
544 }
545
546
547 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedPreparer(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVpnConnectionHealthRequest) (*http.Request, error) {
548 pathParameters := map[string]interface{}{
549 "gatewayName": autorest.Encode("path", gatewayName),
550 "resourceGroupName": autorest.Encode("path", resourceGroupName),
551 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
552 }
553
554 const APIVersion = "2022-05-01"
555 queryParameters := map[string]interface{}{
556 "api-version": APIVersion,
557 }
558
559 preparer := autorest.CreatePreparer(
560 autorest.AsContentType("application/json; charset=utf-8"),
561 autorest.AsPost(),
562 autorest.WithBaseURL(client.BaseURI),
563 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealthDetailed", pathParameters),
564 autorest.WithJSON(request),
565 autorest.WithQueryParameters(queryParameters))
566 return preparer.Prepare((&http.Request{}).WithContext(ctx))
567 }
568
569
570
571 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedSender(req *http.Request) (future P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture, err error) {
572 var resp *http.Response
573 future.FutureAPI = &azure.Future{}
574 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
575 if err != nil {
576 return
577 }
578 var azf azure.Future
579 azf, err = azure.NewFutureFromResponse(resp)
580 future.FutureAPI = &azf
581 future.Result = future.result
582 return
583 }
584
585
586
587 func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedResponder(resp *http.Response) (result P2SVpnConnectionHealth, err error) {
588 err = autorest.Respond(
589 resp,
590 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
591 autorest.ByUnmarshallingJSON(&result),
592 autorest.ByClosing())
593 result.Response = autorest.Response{Response: resp}
594 return
595 }
596
597
598 func (client P2sVpnGatewaysClient) List(ctx context.Context) (result ListP2SVpnGatewaysResultPage, err error) {
599 if tracing.IsEnabled() {
600 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.List")
601 defer func() {
602 sc := -1
603 if result.lpvgr.Response.Response != nil {
604 sc = result.lpvgr.Response.Response.StatusCode
605 }
606 tracing.EndSpan(ctx, sc, err)
607 }()
608 }
609 result.fn = client.listNextResults
610 req, err := client.ListPreparer(ctx)
611 if err != nil {
612 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", nil, "Failure preparing request")
613 return
614 }
615
616 resp, err := client.ListSender(req)
617 if err != nil {
618 result.lpvgr.Response = autorest.Response{Response: resp}
619 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", resp, "Failure sending request")
620 return
621 }
622
623 result.lpvgr, err = client.ListResponder(resp)
624 if err != nil {
625 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", resp, "Failure responding to request")
626 return
627 }
628 if result.lpvgr.hasNextLink() && result.lpvgr.IsEmpty() {
629 err = result.NextWithContext(ctx)
630 return
631 }
632
633 return
634 }
635
636
637 func (client P2sVpnGatewaysClient) ListPreparer(ctx context.Context) (*http.Request, error) {
638 pathParameters := map[string]interface{}{
639 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
640 }
641
642 const APIVersion = "2022-05-01"
643 queryParameters := map[string]interface{}{
644 "api-version": APIVersion,
645 }
646
647 preparer := autorest.CreatePreparer(
648 autorest.AsGet(),
649 autorest.WithBaseURL(client.BaseURI),
650 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/p2svpnGateways", pathParameters),
651 autorest.WithQueryParameters(queryParameters))
652 return preparer.Prepare((&http.Request{}).WithContext(ctx))
653 }
654
655
656
657 func (client P2sVpnGatewaysClient) ListSender(req *http.Request) (*http.Response, error) {
658 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
659 }
660
661
662
663 func (client P2sVpnGatewaysClient) ListResponder(resp *http.Response) (result ListP2SVpnGatewaysResult, err error) {
664 err = autorest.Respond(
665 resp,
666 azure.WithErrorUnlessStatusCode(http.StatusOK),
667 autorest.ByUnmarshallingJSON(&result),
668 autorest.ByClosing())
669 result.Response = autorest.Response{Response: resp}
670 return
671 }
672
673
674 func (client P2sVpnGatewaysClient) listNextResults(ctx context.Context, lastResults ListP2SVpnGatewaysResult) (result ListP2SVpnGatewaysResult, err error) {
675 req, err := lastResults.listP2SVpnGatewaysResultPreparer(ctx)
676 if err != nil {
677 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", nil, "Failure preparing next results request")
678 }
679 if req == nil {
680 return
681 }
682 resp, err := client.ListSender(req)
683 if err != nil {
684 result.Response = autorest.Response{Response: resp}
685 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", resp, "Failure sending next results request")
686 }
687 result, err = client.ListResponder(resp)
688 if err != nil {
689 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", resp, "Failure responding to next results request")
690 }
691 return
692 }
693
694
695 func (client P2sVpnGatewaysClient) ListComplete(ctx context.Context) (result ListP2SVpnGatewaysResultIterator, err error) {
696 if tracing.IsEnabled() {
697 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.List")
698 defer func() {
699 sc := -1
700 if result.Response().Response.Response != nil {
701 sc = result.page.Response().Response.Response.StatusCode
702 }
703 tracing.EndSpan(ctx, sc, err)
704 }()
705 }
706 result.page, err = client.List(ctx)
707 return
708 }
709
710
711
712
713 func (client P2sVpnGatewaysClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListP2SVpnGatewaysResultPage, err error) {
714 if tracing.IsEnabled() {
715 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.ListByResourceGroup")
716 defer func() {
717 sc := -1
718 if result.lpvgr.Response.Response != nil {
719 sc = result.lpvgr.Response.Response.StatusCode
720 }
721 tracing.EndSpan(ctx, sc, err)
722 }()
723 }
724 result.fn = client.listByResourceGroupNextResults
725 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
726 if err != nil {
727 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", nil, "Failure preparing request")
728 return
729 }
730
731 resp, err := client.ListByResourceGroupSender(req)
732 if err != nil {
733 result.lpvgr.Response = autorest.Response{Response: resp}
734 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", resp, "Failure sending request")
735 return
736 }
737
738 result.lpvgr, err = client.ListByResourceGroupResponder(resp)
739 if err != nil {
740 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", resp, "Failure responding to request")
741 return
742 }
743 if result.lpvgr.hasNextLink() && result.lpvgr.IsEmpty() {
744 err = result.NextWithContext(ctx)
745 return
746 }
747
748 return
749 }
750
751
752 func (client P2sVpnGatewaysClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
753 pathParameters := map[string]interface{}{
754 "resourceGroupName": autorest.Encode("path", resourceGroupName),
755 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
756 }
757
758 const APIVersion = "2022-05-01"
759 queryParameters := map[string]interface{}{
760 "api-version": APIVersion,
761 }
762
763 preparer := autorest.CreatePreparer(
764 autorest.AsGet(),
765 autorest.WithBaseURL(client.BaseURI),
766 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways", pathParameters),
767 autorest.WithQueryParameters(queryParameters))
768 return preparer.Prepare((&http.Request{}).WithContext(ctx))
769 }
770
771
772
773 func (client P2sVpnGatewaysClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
774 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
775 }
776
777
778
779 func (client P2sVpnGatewaysClient) ListByResourceGroupResponder(resp *http.Response) (result ListP2SVpnGatewaysResult, err error) {
780 err = autorest.Respond(
781 resp,
782 azure.WithErrorUnlessStatusCode(http.StatusOK),
783 autorest.ByUnmarshallingJSON(&result),
784 autorest.ByClosing())
785 result.Response = autorest.Response{Response: resp}
786 return
787 }
788
789
790 func (client P2sVpnGatewaysClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListP2SVpnGatewaysResult) (result ListP2SVpnGatewaysResult, err error) {
791 req, err := lastResults.listP2SVpnGatewaysResultPreparer(ctx)
792 if err != nil {
793 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
794 }
795 if req == nil {
796 return
797 }
798 resp, err := client.ListByResourceGroupSender(req)
799 if err != nil {
800 result.Response = autorest.Response{Response: resp}
801 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
802 }
803 result, err = client.ListByResourceGroupResponder(resp)
804 if err != nil {
805 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
806 }
807 return
808 }
809
810
811 func (client P2sVpnGatewaysClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListP2SVpnGatewaysResultIterator, err error) {
812 if tracing.IsEnabled() {
813 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.ListByResourceGroup")
814 defer func() {
815 sc := -1
816 if result.Response().Response.Response != nil {
817 sc = result.page.Response().Response.Response.StatusCode
818 }
819 tracing.EndSpan(ctx, sc, err)
820 }()
821 }
822 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
823 return
824 }
825
826
827
828
829
830 func (client P2sVpnGatewaysClient) Reset(ctx context.Context, resourceGroupName string, gatewayName string) (result P2SVpnGatewaysResetFuture, err error) {
831 if tracing.IsEnabled() {
832 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Reset")
833 defer func() {
834 sc := -1
835 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
836 sc = result.FutureAPI.Response().StatusCode
837 }
838 tracing.EndSpan(ctx, sc, err)
839 }()
840 }
841 req, err := client.ResetPreparer(ctx, resourceGroupName, gatewayName)
842 if err != nil {
843 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Reset", nil, "Failure preparing request")
844 return
845 }
846
847 result, err = client.ResetSender(req)
848 if err != nil {
849 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Reset", result.Response(), "Failure sending request")
850 return
851 }
852
853 return
854 }
855
856
857 func (client P2sVpnGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) {
858 pathParameters := map[string]interface{}{
859 "gatewayName": autorest.Encode("path", gatewayName),
860 "resourceGroupName": autorest.Encode("path", resourceGroupName),
861 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
862 }
863
864 const APIVersion = "2022-05-01"
865 queryParameters := map[string]interface{}{
866 "api-version": APIVersion,
867 }
868
869 preparer := autorest.CreatePreparer(
870 autorest.AsPost(),
871 autorest.WithBaseURL(client.BaseURI),
872 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/reset", pathParameters),
873 autorest.WithQueryParameters(queryParameters))
874 return preparer.Prepare((&http.Request{}).WithContext(ctx))
875 }
876
877
878
879 func (client P2sVpnGatewaysClient) ResetSender(req *http.Request) (future P2SVpnGatewaysResetFuture, err error) {
880 var resp *http.Response
881 future.FutureAPI = &azure.Future{}
882 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
883 if err != nil {
884 return
885 }
886 var azf azure.Future
887 azf, err = azure.NewFutureFromResponse(resp)
888 future.FutureAPI = &azf
889 future.Result = future.result
890 return
891 }
892
893
894
895 func (client P2sVpnGatewaysClient) ResetResponder(resp *http.Response) (result P2SVpnGateway, err error) {
896 err = autorest.Respond(
897 resp,
898 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
899 autorest.ByUnmarshallingJSON(&result),
900 autorest.ByClosing())
901 result.Response = autorest.Response{Response: resp}
902 return
903 }
904
905
906
907
908
909
910 func (client P2sVpnGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters TagsObject) (result P2sVpnGatewaysUpdateTagsFuture, err error) {
911 if tracing.IsEnabled() {
912 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.UpdateTags")
913 defer func() {
914 sc := -1
915 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
916 sc = result.FutureAPI.Response().StatusCode
917 }
918 tracing.EndSpan(ctx, sc, err)
919 }()
920 }
921 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, gatewayName, p2SVpnGatewayParameters)
922 if err != nil {
923 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", nil, "Failure preparing request")
924 return
925 }
926
927 result, err = client.UpdateTagsSender(req)
928 if err != nil {
929 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", result.Response(), "Failure sending request")
930 return
931 }
932
933 return
934 }
935
936
937 func (client P2sVpnGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters TagsObject) (*http.Request, error) {
938 pathParameters := map[string]interface{}{
939 "gatewayName": autorest.Encode("path", gatewayName),
940 "resourceGroupName": autorest.Encode("path", resourceGroupName),
941 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
942 }
943
944 const APIVersion = "2022-05-01"
945 queryParameters := map[string]interface{}{
946 "api-version": APIVersion,
947 }
948
949 preparer := autorest.CreatePreparer(
950 autorest.AsContentType("application/json; charset=utf-8"),
951 autorest.AsPatch(),
952 autorest.WithBaseURL(client.BaseURI),
953 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters),
954 autorest.WithJSON(p2SVpnGatewayParameters),
955 autorest.WithQueryParameters(queryParameters))
956 return preparer.Prepare((&http.Request{}).WithContext(ctx))
957 }
958
959
960
961 func (client P2sVpnGatewaysClient) UpdateTagsSender(req *http.Request) (future P2sVpnGatewaysUpdateTagsFuture, err error) {
962 var resp *http.Response
963 future.FutureAPI = &azure.Future{}
964 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
965 if err != nil {
966 return
967 }
968 var azf azure.Future
969 azf, err = azure.NewFutureFromResponse(resp)
970 future.FutureAPI = &azf
971 future.Result = future.result
972 return
973 }
974
975
976
977 func (client P2sVpnGatewaysClient) UpdateTagsResponder(resp *http.Response) (result P2SVpnGateway, err error) {
978 err = autorest.Respond(
979 resp,
980 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
981 autorest.ByUnmarshallingJSON(&result),
982 autorest.ByClosing())
983 result.Response = autorest.Response{Response: resp}
984 return
985 }
986
View as plain text