1// +build go1.13
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5// Code generated by Microsoft (R) AutoRest Code Generator.
6// Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
8package armnetwork
9
10import (
11	"context"
12	"errors"
13	"fmt"
14	"github.com/Azure/azure-sdk-for-go/sdk/armcore"
15	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
16	"net/http"
17	"net/url"
18	"strings"
19	"time"
20)
21
22// DdosProtectionPlansClient contains the methods for the DdosProtectionPlans group.
23// Don't use this type directly, use NewDdosProtectionPlansClient() instead.
24type DdosProtectionPlansClient struct {
25	con            *armcore.Connection
26	subscriptionID string
27}
28
29// NewDdosProtectionPlansClient creates a new instance of DdosProtectionPlansClient with the specified values.
30func NewDdosProtectionPlansClient(con *armcore.Connection, subscriptionID string) *DdosProtectionPlansClient {
31	return &DdosProtectionPlansClient{con: con, subscriptionID: subscriptionID}
32}
33
34// BeginCreateOrUpdate - Creates or updates a DDoS protection plan.
35// If the operation fails it returns the *CloudError error type.
36func (client *DdosProtectionPlansClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters DdosProtectionPlan, options *DdosProtectionPlansBeginCreateOrUpdateOptions) (DdosProtectionPlanPollerResponse, error) {
37	resp, err := client.createOrUpdate(ctx, resourceGroupName, ddosProtectionPlanName, parameters, options)
38	if err != nil {
39		return DdosProtectionPlanPollerResponse{}, err
40	}
41	result := DdosProtectionPlanPollerResponse{
42		RawResponse: resp.Response,
43	}
44	pt, err := armcore.NewLROPoller("DdosProtectionPlansClient.CreateOrUpdate", "azure-async-operation", resp, client.con.Pipeline(), client.createOrUpdateHandleError)
45	if err != nil {
46		return DdosProtectionPlanPollerResponse{}, err
47	}
48	poller := &ddosProtectionPlanPoller{
49		pt: pt,
50	}
51	result.Poller = poller
52	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DdosProtectionPlanResponse, error) {
53		return poller.pollUntilDone(ctx, frequency)
54	}
55	return result, nil
56}
57
58// ResumeCreateOrUpdate creates a new DdosProtectionPlanPoller from the specified resume token.
59// token - The value must come from a previous call to DdosProtectionPlanPoller.ResumeToken().
60func (client *DdosProtectionPlansClient) ResumeCreateOrUpdate(ctx context.Context, token string) (DdosProtectionPlanPollerResponse, error) {
61	pt, err := armcore.NewLROPollerFromResumeToken("DdosProtectionPlansClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError)
62	if err != nil {
63		return DdosProtectionPlanPollerResponse{}, err
64	}
65	poller := &ddosProtectionPlanPoller{
66		pt: pt,
67	}
68	resp, err := poller.Poll(ctx)
69	if err != nil {
70		return DdosProtectionPlanPollerResponse{}, err
71	}
72	result := DdosProtectionPlanPollerResponse{
73		RawResponse: resp,
74	}
75	result.Poller = poller
76	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DdosProtectionPlanResponse, error) {
77		return poller.pollUntilDone(ctx, frequency)
78	}
79	return result, nil
80}
81
82// CreateOrUpdate - Creates or updates a DDoS protection plan.
83// If the operation fails it returns the *CloudError error type.
84func (client *DdosProtectionPlansClient) createOrUpdate(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters DdosProtectionPlan, options *DdosProtectionPlansBeginCreateOrUpdateOptions) (*azcore.Response, error) {
85	req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ddosProtectionPlanName, parameters, options)
86	if err != nil {
87		return nil, err
88	}
89	resp, err := client.con.Pipeline().Do(req)
90	if err != nil {
91		return nil, err
92	}
93	if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) {
94		return nil, client.createOrUpdateHandleError(resp)
95	}
96	return resp, nil
97}
98
99// createOrUpdateCreateRequest creates the CreateOrUpdate request.
100func (client *DdosProtectionPlansClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters DdosProtectionPlan, options *DdosProtectionPlansBeginCreateOrUpdateOptions) (*azcore.Request, error) {
101	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}"
102	if resourceGroupName == "" {
103		return nil, errors.New("parameter resourceGroupName cannot be empty")
104	}
105	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
106	if ddosProtectionPlanName == "" {
107		return nil, errors.New("parameter ddosProtectionPlanName cannot be empty")
108	}
109	urlPath = strings.ReplaceAll(urlPath, "{ddosProtectionPlanName}", url.PathEscape(ddosProtectionPlanName))
110	if client.subscriptionID == "" {
111		return nil, errors.New("parameter client.subscriptionID cannot be empty")
112	}
113	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
114	req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))
115	if err != nil {
116		return nil, err
117	}
118	req.Telemetry(telemetryInfo)
119	reqQP := req.URL.Query()
120	reqQP.Set("api-version", "2021-02-01")
121	req.URL.RawQuery = reqQP.Encode()
122	req.Header.Set("Accept", "application/json")
123	return req, req.MarshalAsJSON(parameters)
124}
125
126// createOrUpdateHandleError handles the CreateOrUpdate error response.
127func (client *DdosProtectionPlansClient) createOrUpdateHandleError(resp *azcore.Response) error {
128	body, err := resp.Payload()
129	if err != nil {
130		return azcore.NewResponseError(err, resp.Response)
131	}
132	errType := CloudError{raw: string(body)}
133	if err := resp.UnmarshalAsJSON(&errType); err != nil {
134		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
135	}
136	return azcore.NewResponseError(&errType, resp.Response)
137}
138
139// BeginDelete - Deletes the specified DDoS protection plan.
140// If the operation fails it returns the *CloudError error type.
141func (client *DdosProtectionPlansClient) BeginDelete(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, options *DdosProtectionPlansBeginDeleteOptions) (HTTPPollerResponse, error) {
142	resp, err := client.deleteOperation(ctx, resourceGroupName, ddosProtectionPlanName, options)
143	if err != nil {
144		return HTTPPollerResponse{}, err
145	}
146	result := HTTPPollerResponse{
147		RawResponse: resp.Response,
148	}
149	pt, err := armcore.NewLROPoller("DdosProtectionPlansClient.Delete", "location", resp, client.con.Pipeline(), client.deleteHandleError)
150	if err != nil {
151		return HTTPPollerResponse{}, err
152	}
153	poller := &httpPoller{
154		pt: pt,
155	}
156	result.Poller = poller
157	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {
158		return poller.pollUntilDone(ctx, frequency)
159	}
160	return result, nil
161}
162
163// ResumeDelete creates a new HTTPPoller from the specified resume token.
164// token - The value must come from a previous call to HTTPPoller.ResumeToken().
165func (client *DdosProtectionPlansClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) {
166	pt, err := armcore.NewLROPollerFromResumeToken("DdosProtectionPlansClient.Delete", token, client.con.Pipeline(), client.deleteHandleError)
167	if err != nil {
168		return HTTPPollerResponse{}, err
169	}
170	poller := &httpPoller{
171		pt: pt,
172	}
173	resp, err := poller.Poll(ctx)
174	if err != nil {
175		return HTTPPollerResponse{}, err
176	}
177	result := HTTPPollerResponse{
178		RawResponse: resp,
179	}
180	result.Poller = poller
181	result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) {
182		return poller.pollUntilDone(ctx, frequency)
183	}
184	return result, nil
185}
186
187// Delete - Deletes the specified DDoS protection plan.
188// If the operation fails it returns the *CloudError error type.
189func (client *DdosProtectionPlansClient) deleteOperation(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, options *DdosProtectionPlansBeginDeleteOptions) (*azcore.Response, error) {
190	req, err := client.deleteCreateRequest(ctx, resourceGroupName, ddosProtectionPlanName, options)
191	if err != nil {
192		return nil, err
193	}
194	resp, err := client.con.Pipeline().Do(req)
195	if err != nil {
196		return nil, err
197	}
198	if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) {
199		return nil, client.deleteHandleError(resp)
200	}
201	return resp, nil
202}
203
204// deleteCreateRequest creates the Delete request.
205func (client *DdosProtectionPlansClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, options *DdosProtectionPlansBeginDeleteOptions) (*azcore.Request, error) {
206	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}"
207	if resourceGroupName == "" {
208		return nil, errors.New("parameter resourceGroupName cannot be empty")
209	}
210	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
211	if ddosProtectionPlanName == "" {
212		return nil, errors.New("parameter ddosProtectionPlanName cannot be empty")
213	}
214	urlPath = strings.ReplaceAll(urlPath, "{ddosProtectionPlanName}", url.PathEscape(ddosProtectionPlanName))
215	if client.subscriptionID == "" {
216		return nil, errors.New("parameter client.subscriptionID cannot be empty")
217	}
218	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
219	req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))
220	if err != nil {
221		return nil, err
222	}
223	req.Telemetry(telemetryInfo)
224	reqQP := req.URL.Query()
225	reqQP.Set("api-version", "2021-02-01")
226	req.URL.RawQuery = reqQP.Encode()
227	req.Header.Set("Accept", "application/json")
228	return req, nil
229}
230
231// deleteHandleError handles the Delete error response.
232func (client *DdosProtectionPlansClient) deleteHandleError(resp *azcore.Response) error {
233	body, err := resp.Payload()
234	if err != nil {
235		return azcore.NewResponseError(err, resp.Response)
236	}
237	errType := CloudError{raw: string(body)}
238	if err := resp.UnmarshalAsJSON(&errType); err != nil {
239		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
240	}
241	return azcore.NewResponseError(&errType, resp.Response)
242}
243
244// Get - Gets information about the specified DDoS protection plan.
245// If the operation fails it returns the *CloudError error type.
246func (client *DdosProtectionPlansClient) Get(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, options *DdosProtectionPlansGetOptions) (DdosProtectionPlanResponse, error) {
247	req, err := client.getCreateRequest(ctx, resourceGroupName, ddosProtectionPlanName, options)
248	if err != nil {
249		return DdosProtectionPlanResponse{}, err
250	}
251	resp, err := client.con.Pipeline().Do(req)
252	if err != nil {
253		return DdosProtectionPlanResponse{}, err
254	}
255	if !resp.HasStatusCode(http.StatusOK) {
256		return DdosProtectionPlanResponse{}, client.getHandleError(resp)
257	}
258	return client.getHandleResponse(resp)
259}
260
261// getCreateRequest creates the Get request.
262func (client *DdosProtectionPlansClient) getCreateRequest(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, options *DdosProtectionPlansGetOptions) (*azcore.Request, error) {
263	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}"
264	if resourceGroupName == "" {
265		return nil, errors.New("parameter resourceGroupName cannot be empty")
266	}
267	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
268	if ddosProtectionPlanName == "" {
269		return nil, errors.New("parameter ddosProtectionPlanName cannot be empty")
270	}
271	urlPath = strings.ReplaceAll(urlPath, "{ddosProtectionPlanName}", url.PathEscape(ddosProtectionPlanName))
272	if client.subscriptionID == "" {
273		return nil, errors.New("parameter client.subscriptionID cannot be empty")
274	}
275	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
276	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
277	if err != nil {
278		return nil, err
279	}
280	req.Telemetry(telemetryInfo)
281	reqQP := req.URL.Query()
282	reqQP.Set("api-version", "2021-02-01")
283	req.URL.RawQuery = reqQP.Encode()
284	req.Header.Set("Accept", "application/json")
285	return req, nil
286}
287
288// getHandleResponse handles the Get response.
289func (client *DdosProtectionPlansClient) getHandleResponse(resp *azcore.Response) (DdosProtectionPlanResponse, error) {
290	var val *DdosProtectionPlan
291	if err := resp.UnmarshalAsJSON(&val); err != nil {
292		return DdosProtectionPlanResponse{}, err
293	}
294	return DdosProtectionPlanResponse{RawResponse: resp.Response, DdosProtectionPlan: val}, nil
295}
296
297// getHandleError handles the Get error response.
298func (client *DdosProtectionPlansClient) getHandleError(resp *azcore.Response) error {
299	body, err := resp.Payload()
300	if err != nil {
301		return azcore.NewResponseError(err, resp.Response)
302	}
303	errType := CloudError{raw: string(body)}
304	if err := resp.UnmarshalAsJSON(&errType); err != nil {
305		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
306	}
307	return azcore.NewResponseError(&errType, resp.Response)
308}
309
310// List - Gets all DDoS protection plans in a subscription.
311// If the operation fails it returns the *CloudError error type.
312func (client *DdosProtectionPlansClient) List(options *DdosProtectionPlansListOptions) DdosProtectionPlanListResultPager {
313	return &ddosProtectionPlanListResultPager{
314		pipeline: client.con.Pipeline(),
315		requester: func(ctx context.Context) (*azcore.Request, error) {
316			return client.listCreateRequest(ctx, options)
317		},
318		responder: client.listHandleResponse,
319		errorer:   client.listHandleError,
320		advancer: func(ctx context.Context, resp DdosProtectionPlanListResultResponse) (*azcore.Request, error) {
321			return azcore.NewRequest(ctx, http.MethodGet, *resp.DdosProtectionPlanListResult.NextLink)
322		},
323		statusCodes: []int{http.StatusOK},
324	}
325}
326
327// listCreateRequest creates the List request.
328func (client *DdosProtectionPlansClient) listCreateRequest(ctx context.Context, options *DdosProtectionPlansListOptions) (*azcore.Request, error) {
329	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/ddosProtectionPlans"
330	if client.subscriptionID == "" {
331		return nil, errors.New("parameter client.subscriptionID cannot be empty")
332	}
333	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
334	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
335	if err != nil {
336		return nil, err
337	}
338	req.Telemetry(telemetryInfo)
339	reqQP := req.URL.Query()
340	reqQP.Set("api-version", "2021-02-01")
341	req.URL.RawQuery = reqQP.Encode()
342	req.Header.Set("Accept", "application/json")
343	return req, nil
344}
345
346// listHandleResponse handles the List response.
347func (client *DdosProtectionPlansClient) listHandleResponse(resp *azcore.Response) (DdosProtectionPlanListResultResponse, error) {
348	var val *DdosProtectionPlanListResult
349	if err := resp.UnmarshalAsJSON(&val); err != nil {
350		return DdosProtectionPlanListResultResponse{}, err
351	}
352	return DdosProtectionPlanListResultResponse{RawResponse: resp.Response, DdosProtectionPlanListResult: val}, nil
353}
354
355// listHandleError handles the List error response.
356func (client *DdosProtectionPlansClient) listHandleError(resp *azcore.Response) error {
357	body, err := resp.Payload()
358	if err != nil {
359		return azcore.NewResponseError(err, resp.Response)
360	}
361	errType := CloudError{raw: string(body)}
362	if err := resp.UnmarshalAsJSON(&errType); err != nil {
363		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
364	}
365	return azcore.NewResponseError(&errType, resp.Response)
366}
367
368// ListByResourceGroup - Gets all the DDoS protection plans in a resource group.
369// If the operation fails it returns the *CloudError error type.
370func (client *DdosProtectionPlansClient) ListByResourceGroup(resourceGroupName string, options *DdosProtectionPlansListByResourceGroupOptions) DdosProtectionPlanListResultPager {
371	return &ddosProtectionPlanListResultPager{
372		pipeline: client.con.Pipeline(),
373		requester: func(ctx context.Context) (*azcore.Request, error) {
374			return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options)
375		},
376		responder: client.listByResourceGroupHandleResponse,
377		errorer:   client.listByResourceGroupHandleError,
378		advancer: func(ctx context.Context, resp DdosProtectionPlanListResultResponse) (*azcore.Request, error) {
379			return azcore.NewRequest(ctx, http.MethodGet, *resp.DdosProtectionPlanListResult.NextLink)
380		},
381		statusCodes: []int{http.StatusOK},
382	}
383}
384
385// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
386func (client *DdosProtectionPlansClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DdosProtectionPlansListByResourceGroupOptions) (*azcore.Request, error) {
387	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans"
388	if resourceGroupName == "" {
389		return nil, errors.New("parameter resourceGroupName cannot be empty")
390	}
391	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
392	if client.subscriptionID == "" {
393		return nil, errors.New("parameter client.subscriptionID cannot be empty")
394	}
395	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
396	req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))
397	if err != nil {
398		return nil, err
399	}
400	req.Telemetry(telemetryInfo)
401	reqQP := req.URL.Query()
402	reqQP.Set("api-version", "2021-02-01")
403	req.URL.RawQuery = reqQP.Encode()
404	req.Header.Set("Accept", "application/json")
405	return req, nil
406}
407
408// listByResourceGroupHandleResponse handles the ListByResourceGroup response.
409func (client *DdosProtectionPlansClient) listByResourceGroupHandleResponse(resp *azcore.Response) (DdosProtectionPlanListResultResponse, error) {
410	var val *DdosProtectionPlanListResult
411	if err := resp.UnmarshalAsJSON(&val); err != nil {
412		return DdosProtectionPlanListResultResponse{}, err
413	}
414	return DdosProtectionPlanListResultResponse{RawResponse: resp.Response, DdosProtectionPlanListResult: val}, nil
415}
416
417// listByResourceGroupHandleError handles the ListByResourceGroup error response.
418func (client *DdosProtectionPlansClient) listByResourceGroupHandleError(resp *azcore.Response) error {
419	body, err := resp.Payload()
420	if err != nil {
421		return azcore.NewResponseError(err, resp.Response)
422	}
423	errType := CloudError{raw: string(body)}
424	if err := resp.UnmarshalAsJSON(&errType); err != nil {
425		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
426	}
427	return azcore.NewResponseError(&errType, resp.Response)
428}
429
430// UpdateTags - Update a DDoS protection plan tags.
431// If the operation fails it returns the *CloudError error type.
432func (client *DdosProtectionPlansClient) UpdateTags(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject, options *DdosProtectionPlansUpdateTagsOptions) (DdosProtectionPlanResponse, error) {
433	req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, ddosProtectionPlanName, parameters, options)
434	if err != nil {
435		return DdosProtectionPlanResponse{}, err
436	}
437	resp, err := client.con.Pipeline().Do(req)
438	if err != nil {
439		return DdosProtectionPlanResponse{}, err
440	}
441	if !resp.HasStatusCode(http.StatusOK) {
442		return DdosProtectionPlanResponse{}, client.updateTagsHandleError(resp)
443	}
444	return client.updateTagsHandleResponse(resp)
445}
446
447// updateTagsCreateRequest creates the UpdateTags request.
448func (client *DdosProtectionPlansClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject, options *DdosProtectionPlansUpdateTagsOptions) (*azcore.Request, error) {
449	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}"
450	if resourceGroupName == "" {
451		return nil, errors.New("parameter resourceGroupName cannot be empty")
452	}
453	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
454	if ddosProtectionPlanName == "" {
455		return nil, errors.New("parameter ddosProtectionPlanName cannot be empty")
456	}
457	urlPath = strings.ReplaceAll(urlPath, "{ddosProtectionPlanName}", url.PathEscape(ddosProtectionPlanName))
458	if client.subscriptionID == "" {
459		return nil, errors.New("parameter client.subscriptionID cannot be empty")
460	}
461	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
462	req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath))
463	if err != nil {
464		return nil, err
465	}
466	req.Telemetry(telemetryInfo)
467	reqQP := req.URL.Query()
468	reqQP.Set("api-version", "2021-02-01")
469	req.URL.RawQuery = reqQP.Encode()
470	req.Header.Set("Accept", "application/json")
471	return req, req.MarshalAsJSON(parameters)
472}
473
474// updateTagsHandleResponse handles the UpdateTags response.
475func (client *DdosProtectionPlansClient) updateTagsHandleResponse(resp *azcore.Response) (DdosProtectionPlanResponse, error) {
476	var val *DdosProtectionPlan
477	if err := resp.UnmarshalAsJSON(&val); err != nil {
478		return DdosProtectionPlanResponse{}, err
479	}
480	return DdosProtectionPlanResponse{RawResponse: resp.Response, DdosProtectionPlan: val}, nil
481}
482
483// updateTagsHandleError handles the UpdateTags error response.
484func (client *DdosProtectionPlansClient) updateTagsHandleError(resp *azcore.Response) error {
485	body, err := resp.Payload()
486	if err != nil {
487		return azcore.NewResponseError(err, resp.Response)
488	}
489	errType := CloudError{raw: string(body)}
490	if err := resp.UnmarshalAsJSON(&errType); err != nil {
491		return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response)
492	}
493	return azcore.NewResponseError(&errType, resp.Response)
494}
495