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 DdosProtectionPlansClient struct {
19 BaseClient
20 }
21
22
23 func NewDdosProtectionPlansClient(subscriptionID string) DdosProtectionPlansClient {
24 return NewDdosProtectionPlansClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29
30 func NewDdosProtectionPlansClientWithBaseURI(baseURI string, subscriptionID string) DdosProtectionPlansClient {
31 return DdosProtectionPlansClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client DdosProtectionPlansClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters DdosProtectionPlan) (result DdosProtectionPlansCreateOrUpdateFuture, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.CreateOrUpdate")
42 defer func() {
43 sc := -1
44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
45 sc = result.FutureAPI.Response().StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ddosProtectionPlanName, parameters)
51 if err != nil {
52 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "CreateOrUpdate", nil, "Failure preparing request")
53 return
54 }
55
56 result, err = client.CreateOrUpdateSender(req)
57 if err != nil {
58 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "CreateOrUpdate", result.Response(), "Failure sending request")
59 return
60 }
61
62 return
63 }
64
65
66 func (client DdosProtectionPlansClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters DdosProtectionPlan) (*http.Request, error) {
67 pathParameters := map[string]interface{}{
68 "ddosProtectionPlanName": autorest.Encode("path", ddosProtectionPlanName),
69 "resourceGroupName": autorest.Encode("path", resourceGroupName),
70 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
71 }
72
73 const APIVersion = "2022-05-01"
74 queryParameters := map[string]interface{}{
75 "api-version": APIVersion,
76 }
77
78 parameters.ID = nil
79 parameters.Name = nil
80 parameters.Type = nil
81 parameters.Etag = nil
82 preparer := autorest.CreatePreparer(
83 autorest.AsContentType("application/json; charset=utf-8"),
84 autorest.AsPut(),
85 autorest.WithBaseURL(client.BaseURI),
86 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}", pathParameters),
87 autorest.WithJSON(parameters),
88 autorest.WithQueryParameters(queryParameters))
89 return preparer.Prepare((&http.Request{}).WithContext(ctx))
90 }
91
92
93
94 func (client DdosProtectionPlansClient) CreateOrUpdateSender(req *http.Request) (future DdosProtectionPlansCreateOrUpdateFuture, err error) {
95 var resp *http.Response
96 future.FutureAPI = &azure.Future{}
97 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
98 if err != nil {
99 return
100 }
101 var azf azure.Future
102 azf, err = azure.NewFutureFromResponse(resp)
103 future.FutureAPI = &azf
104 future.Result = future.result
105 return
106 }
107
108
109
110 func (client DdosProtectionPlansClient) CreateOrUpdateResponder(resp *http.Response) (result DdosProtectionPlan, err error) {
111 err = autorest.Respond(
112 resp,
113 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
114 autorest.ByUnmarshallingJSON(&result),
115 autorest.ByClosing())
116 result.Response = autorest.Response{Response: resp}
117 return
118 }
119
120
121
122
123
124 func (client DdosProtectionPlansClient) Delete(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (result DdosProtectionPlansDeleteFuture, err error) {
125 if tracing.IsEnabled() {
126 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.Delete")
127 defer func() {
128 sc := -1
129 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
130 sc = result.FutureAPI.Response().StatusCode
131 }
132 tracing.EndSpan(ctx, sc, err)
133 }()
134 }
135 req, err := client.DeletePreparer(ctx, resourceGroupName, ddosProtectionPlanName)
136 if err != nil {
137 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "Delete", nil, "Failure preparing request")
138 return
139 }
140
141 result, err = client.DeleteSender(req)
142 if err != nil {
143 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "Delete", result.Response(), "Failure sending request")
144 return
145 }
146
147 return
148 }
149
150
151 func (client DdosProtectionPlansClient) DeletePreparer(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (*http.Request, error) {
152 pathParameters := map[string]interface{}{
153 "ddosProtectionPlanName": autorest.Encode("path", ddosProtectionPlanName),
154 "resourceGroupName": autorest.Encode("path", resourceGroupName),
155 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
156 }
157
158 const APIVersion = "2022-05-01"
159 queryParameters := map[string]interface{}{
160 "api-version": APIVersion,
161 }
162
163 preparer := autorest.CreatePreparer(
164 autorest.AsDelete(),
165 autorest.WithBaseURL(client.BaseURI),
166 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}", pathParameters),
167 autorest.WithQueryParameters(queryParameters))
168 return preparer.Prepare((&http.Request{}).WithContext(ctx))
169 }
170
171
172
173 func (client DdosProtectionPlansClient) DeleteSender(req *http.Request) (future DdosProtectionPlansDeleteFuture, err error) {
174 var resp *http.Response
175 future.FutureAPI = &azure.Future{}
176 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
177 if err != nil {
178 return
179 }
180 var azf azure.Future
181 azf, err = azure.NewFutureFromResponse(resp)
182 future.FutureAPI = &azf
183 future.Result = future.result
184 return
185 }
186
187
188
189 func (client DdosProtectionPlansClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
190 err = autorest.Respond(
191 resp,
192 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
193 autorest.ByClosing())
194 result.Response = resp
195 return
196 }
197
198
199
200
201
202 func (client DdosProtectionPlansClient) Get(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (result DdosProtectionPlan, err error) {
203 if tracing.IsEnabled() {
204 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.Get")
205 defer func() {
206 sc := -1
207 if result.Response.Response != nil {
208 sc = result.Response.Response.StatusCode
209 }
210 tracing.EndSpan(ctx, sc, err)
211 }()
212 }
213 req, err := client.GetPreparer(ctx, resourceGroupName, ddosProtectionPlanName)
214 if err != nil {
215 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "Get", nil, "Failure preparing request")
216 return
217 }
218
219 resp, err := client.GetSender(req)
220 if err != nil {
221 result.Response = autorest.Response{Response: resp}
222 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "Get", resp, "Failure sending request")
223 return
224 }
225
226 result, err = client.GetResponder(resp)
227 if err != nil {
228 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "Get", resp, "Failure responding to request")
229 return
230 }
231
232 return
233 }
234
235
236 func (client DdosProtectionPlansClient) GetPreparer(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (*http.Request, error) {
237 pathParameters := map[string]interface{}{
238 "ddosProtectionPlanName": autorest.Encode("path", ddosProtectionPlanName),
239 "resourceGroupName": autorest.Encode("path", resourceGroupName),
240 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
241 }
242
243 const APIVersion = "2022-05-01"
244 queryParameters := map[string]interface{}{
245 "api-version": APIVersion,
246 }
247
248 preparer := autorest.CreatePreparer(
249 autorest.AsGet(),
250 autorest.WithBaseURL(client.BaseURI),
251 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}", pathParameters),
252 autorest.WithQueryParameters(queryParameters))
253 return preparer.Prepare((&http.Request{}).WithContext(ctx))
254 }
255
256
257
258 func (client DdosProtectionPlansClient) GetSender(req *http.Request) (*http.Response, error) {
259 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
260 }
261
262
263
264 func (client DdosProtectionPlansClient) GetResponder(resp *http.Response) (result DdosProtectionPlan, err error) {
265 err = autorest.Respond(
266 resp,
267 azure.WithErrorUnlessStatusCode(http.StatusOK),
268 autorest.ByUnmarshallingJSON(&result),
269 autorest.ByClosing())
270 result.Response = autorest.Response{Response: resp}
271 return
272 }
273
274
275 func (client DdosProtectionPlansClient) List(ctx context.Context) (result DdosProtectionPlanListResultPage, err error) {
276 if tracing.IsEnabled() {
277 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.List")
278 defer func() {
279 sc := -1
280 if result.dpplr.Response.Response != nil {
281 sc = result.dpplr.Response.Response.StatusCode
282 }
283 tracing.EndSpan(ctx, sc, err)
284 }()
285 }
286 result.fn = client.listNextResults
287 req, err := client.ListPreparer(ctx)
288 if err != nil {
289 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "List", nil, "Failure preparing request")
290 return
291 }
292
293 resp, err := client.ListSender(req)
294 if err != nil {
295 result.dpplr.Response = autorest.Response{Response: resp}
296 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "List", resp, "Failure sending request")
297 return
298 }
299
300 result.dpplr, err = client.ListResponder(resp)
301 if err != nil {
302 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "List", resp, "Failure responding to request")
303 return
304 }
305 if result.dpplr.hasNextLink() && result.dpplr.IsEmpty() {
306 err = result.NextWithContext(ctx)
307 return
308 }
309
310 return
311 }
312
313
314 func (client DdosProtectionPlansClient) ListPreparer(ctx context.Context) (*http.Request, error) {
315 pathParameters := map[string]interface{}{
316 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
317 }
318
319 const APIVersion = "2022-05-01"
320 queryParameters := map[string]interface{}{
321 "api-version": APIVersion,
322 }
323
324 preparer := autorest.CreatePreparer(
325 autorest.AsGet(),
326 autorest.WithBaseURL(client.BaseURI),
327 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/ddosProtectionPlans", pathParameters),
328 autorest.WithQueryParameters(queryParameters))
329 return preparer.Prepare((&http.Request{}).WithContext(ctx))
330 }
331
332
333
334 func (client DdosProtectionPlansClient) ListSender(req *http.Request) (*http.Response, error) {
335 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
336 }
337
338
339
340 func (client DdosProtectionPlansClient) ListResponder(resp *http.Response) (result DdosProtectionPlanListResult, err error) {
341 err = autorest.Respond(
342 resp,
343 azure.WithErrorUnlessStatusCode(http.StatusOK),
344 autorest.ByUnmarshallingJSON(&result),
345 autorest.ByClosing())
346 result.Response = autorest.Response{Response: resp}
347 return
348 }
349
350
351 func (client DdosProtectionPlansClient) listNextResults(ctx context.Context, lastResults DdosProtectionPlanListResult) (result DdosProtectionPlanListResult, err error) {
352 req, err := lastResults.ddosProtectionPlanListResultPreparer(ctx)
353 if err != nil {
354 return result, autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "listNextResults", nil, "Failure preparing next results request")
355 }
356 if req == nil {
357 return
358 }
359 resp, err := client.ListSender(req)
360 if err != nil {
361 result.Response = autorest.Response{Response: resp}
362 return result, autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "listNextResults", resp, "Failure sending next results request")
363 }
364 result, err = client.ListResponder(resp)
365 if err != nil {
366 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "listNextResults", resp, "Failure responding to next results request")
367 }
368 return
369 }
370
371
372 func (client DdosProtectionPlansClient) ListComplete(ctx context.Context) (result DdosProtectionPlanListResultIterator, err error) {
373 if tracing.IsEnabled() {
374 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.List")
375 defer func() {
376 sc := -1
377 if result.Response().Response.Response != nil {
378 sc = result.page.Response().Response.Response.StatusCode
379 }
380 tracing.EndSpan(ctx, sc, err)
381 }()
382 }
383 result.page, err = client.List(ctx)
384 return
385 }
386
387
388
389
390 func (client DdosProtectionPlansClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DdosProtectionPlanListResultPage, err error) {
391 if tracing.IsEnabled() {
392 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.ListByResourceGroup")
393 defer func() {
394 sc := -1
395 if result.dpplr.Response.Response != nil {
396 sc = result.dpplr.Response.Response.StatusCode
397 }
398 tracing.EndSpan(ctx, sc, err)
399 }()
400 }
401 result.fn = client.listByResourceGroupNextResults
402 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
403 if err != nil {
404 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "ListByResourceGroup", nil, "Failure preparing request")
405 return
406 }
407
408 resp, err := client.ListByResourceGroupSender(req)
409 if err != nil {
410 result.dpplr.Response = autorest.Response{Response: resp}
411 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "ListByResourceGroup", resp, "Failure sending request")
412 return
413 }
414
415 result.dpplr, err = client.ListByResourceGroupResponder(resp)
416 if err != nil {
417 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "ListByResourceGroup", resp, "Failure responding to request")
418 return
419 }
420 if result.dpplr.hasNextLink() && result.dpplr.IsEmpty() {
421 err = result.NextWithContext(ctx)
422 return
423 }
424
425 return
426 }
427
428
429 func (client DdosProtectionPlansClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
430 pathParameters := map[string]interface{}{
431 "resourceGroupName": autorest.Encode("path", resourceGroupName),
432 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
433 }
434
435 const APIVersion = "2022-05-01"
436 queryParameters := map[string]interface{}{
437 "api-version": APIVersion,
438 }
439
440 preparer := autorest.CreatePreparer(
441 autorest.AsGet(),
442 autorest.WithBaseURL(client.BaseURI),
443 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans", pathParameters),
444 autorest.WithQueryParameters(queryParameters))
445 return preparer.Prepare((&http.Request{}).WithContext(ctx))
446 }
447
448
449
450 func (client DdosProtectionPlansClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
451 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
452 }
453
454
455
456 func (client DdosProtectionPlansClient) ListByResourceGroupResponder(resp *http.Response) (result DdosProtectionPlanListResult, err error) {
457 err = autorest.Respond(
458 resp,
459 azure.WithErrorUnlessStatusCode(http.StatusOK),
460 autorest.ByUnmarshallingJSON(&result),
461 autorest.ByClosing())
462 result.Response = autorest.Response{Response: resp}
463 return
464 }
465
466
467 func (client DdosProtectionPlansClient) listByResourceGroupNextResults(ctx context.Context, lastResults DdosProtectionPlanListResult) (result DdosProtectionPlanListResult, err error) {
468 req, err := lastResults.ddosProtectionPlanListResultPreparer(ctx)
469 if err != nil {
470 return result, autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
471 }
472 if req == nil {
473 return
474 }
475 resp, err := client.ListByResourceGroupSender(req)
476 if err != nil {
477 result.Response = autorest.Response{Response: resp}
478 return result, autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
479 }
480 result, err = client.ListByResourceGroupResponder(resp)
481 if err != nil {
482 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
483 }
484 return
485 }
486
487
488 func (client DdosProtectionPlansClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DdosProtectionPlanListResultIterator, err error) {
489 if tracing.IsEnabled() {
490 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.ListByResourceGroup")
491 defer func() {
492 sc := -1
493 if result.Response().Response.Response != nil {
494 sc = result.page.Response().Response.Response.StatusCode
495 }
496 tracing.EndSpan(ctx, sc, err)
497 }()
498 }
499 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
500 return
501 }
502
503
504
505
506
507
508 func (client DdosProtectionPlansClient) UpdateTags(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject) (result DdosProtectionPlan, err error) {
509 if tracing.IsEnabled() {
510 ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.UpdateTags")
511 defer func() {
512 sc := -1
513 if result.Response.Response != nil {
514 sc = result.Response.Response.StatusCode
515 }
516 tracing.EndSpan(ctx, sc, err)
517 }()
518 }
519 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, ddosProtectionPlanName, parameters)
520 if err != nil {
521 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", nil, "Failure preparing request")
522 return
523 }
524
525 resp, err := client.UpdateTagsSender(req)
526 if err != nil {
527 result.Response = autorest.Response{Response: resp}
528 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", resp, "Failure sending request")
529 return
530 }
531
532 result, err = client.UpdateTagsResponder(resp)
533 if err != nil {
534 err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", resp, "Failure responding to request")
535 return
536 }
537
538 return
539 }
540
541
542 func (client DdosProtectionPlansClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject) (*http.Request, error) {
543 pathParameters := map[string]interface{}{
544 "ddosProtectionPlanName": autorest.Encode("path", ddosProtectionPlanName),
545 "resourceGroupName": autorest.Encode("path", resourceGroupName),
546 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
547 }
548
549 const APIVersion = "2022-05-01"
550 queryParameters := map[string]interface{}{
551 "api-version": APIVersion,
552 }
553
554 preparer := autorest.CreatePreparer(
555 autorest.AsContentType("application/json; charset=utf-8"),
556 autorest.AsPatch(),
557 autorest.WithBaseURL(client.BaseURI),
558 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}", pathParameters),
559 autorest.WithJSON(parameters),
560 autorest.WithQueryParameters(queryParameters))
561 return preparer.Prepare((&http.Request{}).WithContext(ctx))
562 }
563
564
565
566 func (client DdosProtectionPlansClient) UpdateTagsSender(req *http.Request) (*http.Response, error) {
567 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
568 }
569
570
571
572 func (client DdosProtectionPlansClient) UpdateTagsResponder(resp *http.Response) (result DdosProtectionPlan, err error) {
573 err = autorest.Respond(
574 resp,
575 azure.WithErrorUnlessStatusCode(http.StatusOK),
576 autorest.ByUnmarshallingJSON(&result),
577 autorest.ByClosing())
578 result.Response = autorest.Response{Response: resp}
579 return
580 }
581
View as plain text