1# coding=utf-8
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# --------------------------------------------------------------------------
8from typing import TYPE_CHECKING
9import warnings
10
11from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
12from azure.core.paging import ItemPaged
13from azure.core.pipeline import PipelineResponse
14from azure.core.pipeline.transport import HttpRequest, HttpResponse
15from azure.core.polling import LROPoller, NoPolling, PollingMethod
16from azure.mgmt.core.exceptions import ARMErrorFormat
17from azure.mgmt.core.polling.arm_polling import ARMPolling
18
19from .. import models as _models
20
21if TYPE_CHECKING:
22    # pylint: disable=unused-import,ungrouped-imports
23    from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union
24
25    T = TypeVar('T')
26    ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
27
28class DdosProtectionPlansOperations(object):
29    """DdosProtectionPlansOperations operations.
30
31    You should not instantiate this class directly. Instead, you should create a Client instance that
32    instantiates it for you and attaches it as an attribute.
33
34    :ivar models: Alias to model classes used in this operation group.
35    :type models: ~azure.mgmt.network.v2019_11_01.models
36    :param client: Client for service requests.
37    :param config: Configuration of service client.
38    :param serializer: An object model serializer.
39    :param deserializer: An object model deserializer.
40    """
41
42    models = _models
43
44    def __init__(self, client, config, serializer, deserializer):
45        self._client = client
46        self._serialize = serializer
47        self._deserialize = deserializer
48        self._config = config
49
50    def _delete_initial(
51        self,
52        resource_group_name,  # type: str
53        ddos_protection_plan_name,  # type: str
54        **kwargs  # type: Any
55    ):
56        # type: (...) -> None
57        cls = kwargs.pop('cls', None)  # type: ClsType[None]
58        error_map = {
59            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
60        }
61        error_map.update(kwargs.pop('error_map', {}))
62        api_version = "2019-11-01"
63        accept = "application/json"
64
65        # Construct URL
66        url = self._delete_initial.metadata['url']  # type: ignore
67        path_format_arguments = {
68            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
69            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
70            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
71        }
72        url = self._client.format_url(url, **path_format_arguments)
73
74        # Construct parameters
75        query_parameters = {}  # type: Dict[str, Any]
76        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
77
78        # Construct headers
79        header_parameters = {}  # type: Dict[str, Any]
80        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
81
82        request = self._client.delete(url, query_parameters, header_parameters)
83        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
84        response = pipeline_response.http_response
85
86        if response.status_code not in [200, 202, 204]:
87            map_error(status_code=response.status_code, response=response, error_map=error_map)
88            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
89
90        if cls:
91            return cls(pipeline_response, None, {})
92
93    _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}'}  # type: ignore
94
95    def begin_delete(
96        self,
97        resource_group_name,  # type: str
98        ddos_protection_plan_name,  # type: str
99        **kwargs  # type: Any
100    ):
101        # type: (...) -> LROPoller[None]
102        """Deletes the specified DDoS protection plan.
103
104        :param resource_group_name: The name of the resource group.
105        :type resource_group_name: str
106        :param ddos_protection_plan_name: The name of the DDoS protection plan.
107        :type ddos_protection_plan_name: str
108        :keyword callable cls: A custom type or function that will be passed the direct response
109        :keyword str continuation_token: A continuation token to restart a poller from a saved state.
110        :keyword polling: Pass in True if you'd like the ARMPolling polling method,
111         False for no polling, or your own initialized polling object for a personal polling strategy.
112        :paramtype polling: bool or ~azure.core.polling.PollingMethod
113        :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
114        :return: An instance of LROPoller that returns either None or the result of cls(response)
115        :rtype: ~azure.core.polling.LROPoller[None]
116        :raises ~azure.core.exceptions.HttpResponseError:
117        """
118        polling = kwargs.pop('polling', True)  # type: Union[bool, PollingMethod]
119        cls = kwargs.pop('cls', None)  # type: ClsType[None]
120        lro_delay = kwargs.pop(
121            'polling_interval',
122            self._config.polling_interval
123        )
124        cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
125        if cont_token is None:
126            raw_result = self._delete_initial(
127                resource_group_name=resource_group_name,
128                ddos_protection_plan_name=ddos_protection_plan_name,
129                cls=lambda x,y,z: x,
130                **kwargs
131            )
132
133        kwargs.pop('error_map', None)
134        kwargs.pop('content_type', None)
135
136        def get_long_running_output(pipeline_response):
137            if cls:
138                return cls(pipeline_response, None, {})
139
140        path_format_arguments = {
141            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
142            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
143            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
144        }
145
146        if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments,  **kwargs)
147        elif polling is False: polling_method = NoPolling()
148        else: polling_method = polling
149        if cont_token:
150            return LROPoller.from_continuation_token(
151                polling_method=polling_method,
152                continuation_token=cont_token,
153                client=self._client,
154                deserialization_callback=get_long_running_output
155            )
156        else:
157            return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
158    begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}'}  # type: ignore
159
160    def get(
161        self,
162        resource_group_name,  # type: str
163        ddos_protection_plan_name,  # type: str
164        **kwargs  # type: Any
165    ):
166        # type: (...) -> "_models.DdosProtectionPlan"
167        """Gets information about the specified DDoS protection plan.
168
169        :param resource_group_name: The name of the resource group.
170        :type resource_group_name: str
171        :param ddos_protection_plan_name: The name of the DDoS protection plan.
172        :type ddos_protection_plan_name: str
173        :keyword callable cls: A custom type or function that will be passed the direct response
174        :return: DdosProtectionPlan, or the result of cls(response)
175        :rtype: ~azure.mgmt.network.v2019_11_01.models.DdosProtectionPlan
176        :raises: ~azure.core.exceptions.HttpResponseError
177        """
178        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DdosProtectionPlan"]
179        error_map = {
180            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
181        }
182        error_map.update(kwargs.pop('error_map', {}))
183        api_version = "2019-11-01"
184        accept = "application/json"
185
186        # Construct URL
187        url = self.get.metadata['url']  # type: ignore
188        path_format_arguments = {
189            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
190            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
191            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
192        }
193        url = self._client.format_url(url, **path_format_arguments)
194
195        # Construct parameters
196        query_parameters = {}  # type: Dict[str, Any]
197        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
198
199        # Construct headers
200        header_parameters = {}  # type: Dict[str, Any]
201        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
202
203        request = self._client.get(url, query_parameters, header_parameters)
204        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
205        response = pipeline_response.http_response
206
207        if response.status_code not in [200]:
208            map_error(status_code=response.status_code, response=response, error_map=error_map)
209            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
210
211        deserialized = self._deserialize('DdosProtectionPlan', pipeline_response)
212
213        if cls:
214            return cls(pipeline_response, deserialized, {})
215
216        return deserialized
217    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}'}  # type: ignore
218
219    def _create_or_update_initial(
220        self,
221        resource_group_name,  # type: str
222        ddos_protection_plan_name,  # type: str
223        parameters,  # type: "_models.DdosProtectionPlan"
224        **kwargs  # type: Any
225    ):
226        # type: (...) -> "_models.DdosProtectionPlan"
227        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DdosProtectionPlan"]
228        error_map = {
229            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
230        }
231        error_map.update(kwargs.pop('error_map', {}))
232        api_version = "2019-11-01"
233        content_type = kwargs.pop("content_type", "application/json")
234        accept = "application/json"
235
236        # Construct URL
237        url = self._create_or_update_initial.metadata['url']  # type: ignore
238        path_format_arguments = {
239            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
240            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
241            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
242        }
243        url = self._client.format_url(url, **path_format_arguments)
244
245        # Construct parameters
246        query_parameters = {}  # type: Dict[str, Any]
247        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
248
249        # Construct headers
250        header_parameters = {}  # type: Dict[str, Any]
251        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
252        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
253
254        body_content_kwargs = {}  # type: Dict[str, Any]
255        body_content = self._serialize.body(parameters, 'DdosProtectionPlan')
256        body_content_kwargs['content'] = body_content
257        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
258        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
259        response = pipeline_response.http_response
260
261        if response.status_code not in [200, 201]:
262            map_error(status_code=response.status_code, response=response, error_map=error_map)
263            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
264
265        if response.status_code == 200:
266            deserialized = self._deserialize('DdosProtectionPlan', pipeline_response)
267
268        if response.status_code == 201:
269            deserialized = self._deserialize('DdosProtectionPlan', pipeline_response)
270
271        if cls:
272            return cls(pipeline_response, deserialized, {})
273
274        return deserialized
275    _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}'}  # type: ignore
276
277    def begin_create_or_update(
278        self,
279        resource_group_name,  # type: str
280        ddos_protection_plan_name,  # type: str
281        parameters,  # type: "_models.DdosProtectionPlan"
282        **kwargs  # type: Any
283    ):
284        # type: (...) -> LROPoller["_models.DdosProtectionPlan"]
285        """Creates or updates a DDoS protection plan.
286
287        :param resource_group_name: The name of the resource group.
288        :type resource_group_name: str
289        :param ddos_protection_plan_name: The name of the DDoS protection plan.
290        :type ddos_protection_plan_name: str
291        :param parameters: Parameters supplied to the create or update operation.
292        :type parameters: ~azure.mgmt.network.v2019_11_01.models.DdosProtectionPlan
293        :keyword callable cls: A custom type or function that will be passed the direct response
294        :keyword str continuation_token: A continuation token to restart a poller from a saved state.
295        :keyword polling: Pass in True if you'd like the ARMPolling polling method,
296         False for no polling, or your own initialized polling object for a personal polling strategy.
297        :paramtype polling: bool or ~azure.core.polling.PollingMethod
298        :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
299        :return: An instance of LROPoller that returns either DdosProtectionPlan or the result of cls(response)
300        :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.network.v2019_11_01.models.DdosProtectionPlan]
301        :raises ~azure.core.exceptions.HttpResponseError:
302        """
303        polling = kwargs.pop('polling', True)  # type: Union[bool, PollingMethod]
304        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DdosProtectionPlan"]
305        lro_delay = kwargs.pop(
306            'polling_interval',
307            self._config.polling_interval
308        )
309        cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
310        if cont_token is None:
311            raw_result = self._create_or_update_initial(
312                resource_group_name=resource_group_name,
313                ddos_protection_plan_name=ddos_protection_plan_name,
314                parameters=parameters,
315                cls=lambda x,y,z: x,
316                **kwargs
317            )
318
319        kwargs.pop('error_map', None)
320        kwargs.pop('content_type', None)
321
322        def get_long_running_output(pipeline_response):
323            deserialized = self._deserialize('DdosProtectionPlan', pipeline_response)
324
325            if cls:
326                return cls(pipeline_response, deserialized, {})
327            return deserialized
328
329        path_format_arguments = {
330            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
331            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
332            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
333        }
334
335        if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments,  **kwargs)
336        elif polling is False: polling_method = NoPolling()
337        else: polling_method = polling
338        if cont_token:
339            return LROPoller.from_continuation_token(
340                polling_method=polling_method,
341                continuation_token=cont_token,
342                client=self._client,
343                deserialization_callback=get_long_running_output
344            )
345        else:
346            return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
347    begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}'}  # type: ignore
348
349    def update_tags(
350        self,
351        resource_group_name,  # type: str
352        ddos_protection_plan_name,  # type: str
353        parameters,  # type: "_models.TagsObject"
354        **kwargs  # type: Any
355    ):
356        # type: (...) -> "_models.DdosProtectionPlan"
357        """Update a DDoS protection plan tags.
358
359        :param resource_group_name: The name of the resource group.
360        :type resource_group_name: str
361        :param ddos_protection_plan_name: The name of the DDoS protection plan.
362        :type ddos_protection_plan_name: str
363        :param parameters: Parameters supplied to the update DDoS protection plan resource tags.
364        :type parameters: ~azure.mgmt.network.v2019_11_01.models.TagsObject
365        :keyword callable cls: A custom type or function that will be passed the direct response
366        :return: DdosProtectionPlan, or the result of cls(response)
367        :rtype: ~azure.mgmt.network.v2019_11_01.models.DdosProtectionPlan
368        :raises: ~azure.core.exceptions.HttpResponseError
369        """
370        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DdosProtectionPlan"]
371        error_map = {
372            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
373        }
374        error_map.update(kwargs.pop('error_map', {}))
375        api_version = "2019-11-01"
376        content_type = kwargs.pop("content_type", "application/json")
377        accept = "application/json"
378
379        # Construct URL
380        url = self.update_tags.metadata['url']  # type: ignore
381        path_format_arguments = {
382            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
383            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
384            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
385        }
386        url = self._client.format_url(url, **path_format_arguments)
387
388        # Construct parameters
389        query_parameters = {}  # type: Dict[str, Any]
390        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
391
392        # Construct headers
393        header_parameters = {}  # type: Dict[str, Any]
394        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
395        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
396
397        body_content_kwargs = {}  # type: Dict[str, Any]
398        body_content = self._serialize.body(parameters, 'TagsObject')
399        body_content_kwargs['content'] = body_content
400        request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
401        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
402        response = pipeline_response.http_response
403
404        if response.status_code not in [200]:
405            map_error(status_code=response.status_code, response=response, error_map=error_map)
406            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
407
408        deserialized = self._deserialize('DdosProtectionPlan', pipeline_response)
409
410        if cls:
411            return cls(pipeline_response, deserialized, {})
412
413        return deserialized
414    update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}'}  # type: ignore
415
416    def list(
417        self,
418        **kwargs  # type: Any
419    ):
420        # type: (...) -> Iterable["_models.DdosProtectionPlanListResult"]
421        """Gets all DDoS protection plans in a subscription.
422
423        :keyword callable cls: A custom type or function that will be passed the direct response
424        :return: An iterator like instance of either DdosProtectionPlanListResult or the result of cls(response)
425        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.network.v2019_11_01.models.DdosProtectionPlanListResult]
426        :raises: ~azure.core.exceptions.HttpResponseError
427        """
428        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DdosProtectionPlanListResult"]
429        error_map = {
430            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
431        }
432        error_map.update(kwargs.pop('error_map', {}))
433        api_version = "2019-11-01"
434        accept = "application/json"
435
436        def prepare_request(next_link=None):
437            # Construct headers
438            header_parameters = {}  # type: Dict[str, Any]
439            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
440
441            if not next_link:
442                # Construct URL
443                url = self.list.metadata['url']  # type: ignore
444                path_format_arguments = {
445                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
446                }
447                url = self._client.format_url(url, **path_format_arguments)
448                # Construct parameters
449                query_parameters = {}  # type: Dict[str, Any]
450                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
451
452                request = self._client.get(url, query_parameters, header_parameters)
453            else:
454                url = next_link
455                query_parameters = {}  # type: Dict[str, Any]
456                request = self._client.get(url, query_parameters, header_parameters)
457            return request
458
459        def extract_data(pipeline_response):
460            deserialized = self._deserialize('DdosProtectionPlanListResult', pipeline_response)
461            list_of_elem = deserialized.value
462            if cls:
463                list_of_elem = cls(list_of_elem)
464            return deserialized.next_link or None, iter(list_of_elem)
465
466        def get_next(next_link=None):
467            request = prepare_request(next_link)
468
469            pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
470            response = pipeline_response.http_response
471
472            if response.status_code not in [200]:
473                map_error(status_code=response.status_code, response=response, error_map=error_map)
474                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
475
476            return pipeline_response
477
478        return ItemPaged(
479            get_next, extract_data
480        )
481    list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/ddosProtectionPlans'}  # type: ignore
482
483    def list_by_resource_group(
484        self,
485        resource_group_name,  # type: str
486        **kwargs  # type: Any
487    ):
488        # type: (...) -> Iterable["_models.DdosProtectionPlanListResult"]
489        """Gets all the DDoS protection plans in a resource group.
490
491        :param resource_group_name: The name of the resource group.
492        :type resource_group_name: str
493        :keyword callable cls: A custom type or function that will be passed the direct response
494        :return: An iterator like instance of either DdosProtectionPlanListResult or the result of cls(response)
495        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.network.v2019_11_01.models.DdosProtectionPlanListResult]
496        :raises: ~azure.core.exceptions.HttpResponseError
497        """
498        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DdosProtectionPlanListResult"]
499        error_map = {
500            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
501        }
502        error_map.update(kwargs.pop('error_map', {}))
503        api_version = "2019-11-01"
504        accept = "application/json"
505
506        def prepare_request(next_link=None):
507            # Construct headers
508            header_parameters = {}  # type: Dict[str, Any]
509            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
510
511            if not next_link:
512                # Construct URL
513                url = self.list_by_resource_group.metadata['url']  # type: ignore
514                path_format_arguments = {
515                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
516                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
517                }
518                url = self._client.format_url(url, **path_format_arguments)
519                # Construct parameters
520                query_parameters = {}  # type: Dict[str, Any]
521                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
522
523                request = self._client.get(url, query_parameters, header_parameters)
524            else:
525                url = next_link
526                query_parameters = {}  # type: Dict[str, Any]
527                request = self._client.get(url, query_parameters, header_parameters)
528            return request
529
530        def extract_data(pipeline_response):
531            deserialized = self._deserialize('DdosProtectionPlanListResult', pipeline_response)
532            list_of_elem = deserialized.value
533            if cls:
534                list_of_elem = cls(list_of_elem)
535            return deserialized.next_link or None, iter(list_of_elem)
536
537        def get_next(next_link=None):
538            request = prepare_request(next_link)
539
540            pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
541            response = pipeline_response.http_response
542
543            if response.status_code not in [200]:
544                map_error(status_code=response.status_code, response=response, error_map=error_map)
545                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
546
547            return pipeline_response
548
549        return ItemPaged(
550            get_next, extract_data
551        )
552    list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans'}  # type: ignore
553