azure-mgmt-networkfunction 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. azure/mgmt/networkfunction/__init__.py +32 -0
  2. azure/mgmt/networkfunction/_client.py +172 -0
  3. azure/mgmt/networkfunction/_configuration.py +80 -0
  4. azure/mgmt/networkfunction/_patch.py +21 -0
  5. azure/mgmt/networkfunction/_utils/__init__.py +6 -0
  6. azure/mgmt/networkfunction/_utils/model_base.py +1770 -0
  7. azure/mgmt/networkfunction/_utils/serialization.py +2175 -0
  8. azure/mgmt/networkfunction/_version.py +9 -0
  9. azure/mgmt/networkfunction/aio/__init__.py +29 -0
  10. azure/mgmt/networkfunction/aio/_client.py +177 -0
  11. azure/mgmt/networkfunction/aio/_configuration.py +80 -0
  12. azure/mgmt/networkfunction/aio/_patch.py +21 -0
  13. azure/mgmt/networkfunction/aio/operations/__init__.py +33 -0
  14. azure/mgmt/networkfunction/aio/operations/_operations.py +1780 -0
  15. azure/mgmt/networkfunction/aio/operations/_patch.py +21 -0
  16. azure/mgmt/networkfunction/models/__init__.py +74 -0
  17. azure/mgmt/networkfunction/models/_enums.py +64 -0
  18. azure/mgmt/networkfunction/models/_models.py +718 -0
  19. azure/mgmt/networkfunction/models/_patch.py +21 -0
  20. azure/mgmt/networkfunction/operations/__init__.py +33 -0
  21. azure/mgmt/networkfunction/operations/_operations.py +2123 -0
  22. azure/mgmt/networkfunction/operations/_patch.py +21 -0
  23. azure/mgmt/networkfunction/py.typed +1 -0
  24. azure_mgmt_networkfunction-1.0.0.dist-info/METADATA +126 -0
  25. azure_mgmt_networkfunction-1.0.0.dist-info/RECORD +28 -0
  26. azure_mgmt_networkfunction-1.0.0.dist-info/WHEEL +5 -0
  27. azure_mgmt_networkfunction-1.0.0.dist-info/licenses/LICENSE +21 -0
  28. azure_mgmt_networkfunction-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1780 @@
1
+ # pylint: disable=too-many-lines
2
+ # coding=utf-8
3
+ # --------------------------------------------------------------------------
4
+ # Copyright (c) Microsoft Corporation. All rights reserved.
5
+ # Licensed under the MIT License. See License.txt in the project root for license information.
6
+ # Code generated by Microsoft (R) Python Code Generator.
7
+ # Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
+ # --------------------------------------------------------------------------
9
+ from collections.abc import MutableMapping
10
+ from io import IOBase
11
+ import json
12
+ from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload
13
+ import urllib.parse
14
+
15
+ from azure.core import AsyncPipelineClient
16
+ from azure.core.async_paging import AsyncItemPaged, AsyncList
17
+ from azure.core.exceptions import (
18
+ ClientAuthenticationError,
19
+ HttpResponseError,
20
+ ResourceExistsError,
21
+ ResourceNotFoundError,
22
+ ResourceNotModifiedError,
23
+ StreamClosedError,
24
+ StreamConsumedError,
25
+ map_error,
26
+ )
27
+ from azure.core.pipeline import PipelineResponse
28
+ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
29
+ from azure.core.rest import AsyncHttpResponse, HttpRequest
30
+ from azure.core.tracing.decorator import distributed_trace
31
+ from azure.core.tracing.decorator_async import distributed_trace_async
32
+ from azure.core.utils import case_insensitive_dict
33
+ from azure.mgmt.core.exceptions import ARMErrorFormat
34
+ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
35
+
36
+ from ... import models as _models
37
+ from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize
38
+ from ..._utils.serialization import Deserializer, Serializer
39
+ from ...operations._operations import (
40
+ build_azure_traffic_collectors_by_resource_group_list_request,
41
+ build_azure_traffic_collectors_by_subscription_list_request,
42
+ build_azure_traffic_collectors_create_or_update_request,
43
+ build_azure_traffic_collectors_delete_request,
44
+ build_azure_traffic_collectors_get_request,
45
+ build_azure_traffic_collectors_update_tags_request,
46
+ build_collector_policies_create_or_update_request,
47
+ build_collector_policies_delete_request,
48
+ build_collector_policies_get_request,
49
+ build_collector_policies_list_request,
50
+ build_collector_policies_update_tags_request,
51
+ build_network_function_list_operations_request,
52
+ )
53
+ from .._configuration import TrafficCollectorMgmtClientConfiguration
54
+
55
+ JSON = MutableMapping[str, Any]
56
+ T = TypeVar("T")
57
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]]
58
+ List = list
59
+
60
+
61
+ class AzureTrafficCollectorsOperations:
62
+ """
63
+ .. warning::
64
+ **DO NOT** instantiate this class directly.
65
+
66
+ Instead, you should access the following operations through
67
+ :class:`~azure.mgmt.networkfunction.aio.TrafficCollectorMgmtClient`'s
68
+ :attr:`azure_traffic_collectors` attribute.
69
+ """
70
+
71
+ def __init__(self, *args, **kwargs) -> None:
72
+ input_args = list(args)
73
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
74
+ self._config: TrafficCollectorMgmtClientConfiguration = (
75
+ input_args.pop(0) if input_args else kwargs.pop("config")
76
+ )
77
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
78
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
79
+
80
+ @distributed_trace_async
81
+ async def get(
82
+ self, resource_group_name: str, azure_traffic_collector_name: str, **kwargs: Any
83
+ ) -> _models.AzureTrafficCollector:
84
+ """Gets the specified Azure Traffic Collector in a specified resource group.
85
+
86
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
87
+ Required.
88
+ :type resource_group_name: str
89
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
90
+ :type azure_traffic_collector_name: str
91
+ :return: AzureTrafficCollector. The AzureTrafficCollector is compatible with MutableMapping
92
+ :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector
93
+ :raises ~azure.core.exceptions.HttpResponseError:
94
+ """
95
+ error_map: MutableMapping = {
96
+ 401: ClientAuthenticationError,
97
+ 404: ResourceNotFoundError,
98
+ 409: ResourceExistsError,
99
+ 304: ResourceNotModifiedError,
100
+ }
101
+ error_map.update(kwargs.pop("error_map", {}) or {})
102
+
103
+ _headers = kwargs.pop("headers", {}) or {}
104
+ _params = kwargs.pop("params", {}) or {}
105
+
106
+ cls: ClsType[_models.AzureTrafficCollector] = kwargs.pop("cls", None)
107
+
108
+ _request = build_azure_traffic_collectors_get_request(
109
+ resource_group_name=resource_group_name,
110
+ azure_traffic_collector_name=azure_traffic_collector_name,
111
+ subscription_id=self._config.subscription_id,
112
+ api_version=self._config.api_version,
113
+ headers=_headers,
114
+ params=_params,
115
+ )
116
+ path_format_arguments = {
117
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
118
+ }
119
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
120
+
121
+ _decompress = kwargs.pop("decompress", True)
122
+ _stream = kwargs.pop("stream", False)
123
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
124
+ _request, stream=_stream, **kwargs
125
+ )
126
+
127
+ response = pipeline_response.http_response
128
+
129
+ if response.status_code not in [200]:
130
+ if _stream:
131
+ try:
132
+ await response.read() # Load the body in memory and close the socket
133
+ except (StreamConsumedError, StreamClosedError):
134
+ pass
135
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
136
+ error = _failsafe_deserialize(
137
+ _models.CloudError,
138
+ response,
139
+ )
140
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
141
+
142
+ if _stream:
143
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
144
+ else:
145
+ deserialized = _deserialize(_models.AzureTrafficCollector, response.json())
146
+
147
+ if cls:
148
+ return cls(pipeline_response, deserialized, {}) # type: ignore
149
+
150
+ return deserialized # type: ignore
151
+
152
+ async def _create_or_update_initial(
153
+ self,
154
+ resource_group_name: str,
155
+ azure_traffic_collector_name: str,
156
+ parameters: Union[_models.AzureTrafficCollector, JSON, IO[bytes]],
157
+ **kwargs: Any
158
+ ) -> AsyncIterator[bytes]:
159
+ error_map: MutableMapping = {
160
+ 401: ClientAuthenticationError,
161
+ 404: ResourceNotFoundError,
162
+ 409: ResourceExistsError,
163
+ 304: ResourceNotModifiedError,
164
+ }
165
+ error_map.update(kwargs.pop("error_map", {}) or {})
166
+
167
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
168
+ _params = kwargs.pop("params", {}) or {}
169
+
170
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
171
+ cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
172
+
173
+ content_type = content_type or "application/json"
174
+ _content = None
175
+ if isinstance(parameters, (IOBase, bytes)):
176
+ _content = parameters
177
+ else:
178
+ _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
179
+
180
+ _request = build_azure_traffic_collectors_create_or_update_request(
181
+ resource_group_name=resource_group_name,
182
+ azure_traffic_collector_name=azure_traffic_collector_name,
183
+ subscription_id=self._config.subscription_id,
184
+ content_type=content_type,
185
+ api_version=self._config.api_version,
186
+ content=_content,
187
+ headers=_headers,
188
+ params=_params,
189
+ )
190
+ path_format_arguments = {
191
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
192
+ }
193
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
194
+
195
+ _decompress = kwargs.pop("decompress", True)
196
+ _stream = True
197
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
198
+ _request, stream=_stream, **kwargs
199
+ )
200
+
201
+ response = pipeline_response.http_response
202
+
203
+ if response.status_code not in [200, 201]:
204
+ try:
205
+ await response.read() # Load the body in memory and close the socket
206
+ except (StreamConsumedError, StreamClosedError):
207
+ pass
208
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
209
+ error = _failsafe_deserialize(
210
+ _models.CloudError,
211
+ response,
212
+ )
213
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
214
+
215
+ response_headers = {}
216
+ if response.status_code == 201:
217
+ response_headers["Azure-AsyncOperation"] = self._deserialize(
218
+ "str", response.headers.get("Azure-AsyncOperation")
219
+ )
220
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
221
+
222
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
223
+
224
+ if cls:
225
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
226
+
227
+ return deserialized # type: ignore
228
+
229
+ @overload
230
+ async def begin_create_or_update(
231
+ self,
232
+ resource_group_name: str,
233
+ azure_traffic_collector_name: str,
234
+ parameters: _models.AzureTrafficCollector,
235
+ *,
236
+ content_type: str = "application/json",
237
+ **kwargs: Any
238
+ ) -> AsyncLROPoller[_models.AzureTrafficCollector]:
239
+ """Creates or updates a Azure Traffic Collector resource.
240
+
241
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
242
+ Required.
243
+ :type resource_group_name: str
244
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
245
+ :type azure_traffic_collector_name: str
246
+ :param parameters: The parameters to provide for the created Azure Traffic Collector. Required.
247
+ :type parameters: ~azure.mgmt.networkfunction.models.AzureTrafficCollector
248
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
249
+ Default value is "application/json".
250
+ :paramtype content_type: str
251
+ :return: An instance of AsyncLROPoller that returns AzureTrafficCollector. The
252
+ AzureTrafficCollector is compatible with MutableMapping
253
+ :rtype:
254
+ ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.AzureTrafficCollector]
255
+ :raises ~azure.core.exceptions.HttpResponseError:
256
+ """
257
+
258
+ @overload
259
+ async def begin_create_or_update(
260
+ self,
261
+ resource_group_name: str,
262
+ azure_traffic_collector_name: str,
263
+ parameters: JSON,
264
+ *,
265
+ content_type: str = "application/json",
266
+ **kwargs: Any
267
+ ) -> AsyncLROPoller[_models.AzureTrafficCollector]:
268
+ """Creates or updates a Azure Traffic Collector resource.
269
+
270
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
271
+ Required.
272
+ :type resource_group_name: str
273
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
274
+ :type azure_traffic_collector_name: str
275
+ :param parameters: The parameters to provide for the created Azure Traffic Collector. Required.
276
+ :type parameters: JSON
277
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
278
+ Default value is "application/json".
279
+ :paramtype content_type: str
280
+ :return: An instance of AsyncLROPoller that returns AzureTrafficCollector. The
281
+ AzureTrafficCollector is compatible with MutableMapping
282
+ :rtype:
283
+ ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.AzureTrafficCollector]
284
+ :raises ~azure.core.exceptions.HttpResponseError:
285
+ """
286
+
287
+ @overload
288
+ async def begin_create_or_update(
289
+ self,
290
+ resource_group_name: str,
291
+ azure_traffic_collector_name: str,
292
+ parameters: IO[bytes],
293
+ *,
294
+ content_type: str = "application/json",
295
+ **kwargs: Any
296
+ ) -> AsyncLROPoller[_models.AzureTrafficCollector]:
297
+ """Creates or updates a Azure Traffic Collector resource.
298
+
299
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
300
+ Required.
301
+ :type resource_group_name: str
302
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
303
+ :type azure_traffic_collector_name: str
304
+ :param parameters: The parameters to provide for the created Azure Traffic Collector. Required.
305
+ :type parameters: IO[bytes]
306
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
307
+ Default value is "application/json".
308
+ :paramtype content_type: str
309
+ :return: An instance of AsyncLROPoller that returns AzureTrafficCollector. The
310
+ AzureTrafficCollector is compatible with MutableMapping
311
+ :rtype:
312
+ ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.AzureTrafficCollector]
313
+ :raises ~azure.core.exceptions.HttpResponseError:
314
+ """
315
+
316
+ @distributed_trace_async
317
+ async def begin_create_or_update(
318
+ self,
319
+ resource_group_name: str,
320
+ azure_traffic_collector_name: str,
321
+ parameters: Union[_models.AzureTrafficCollector, JSON, IO[bytes]],
322
+ **kwargs: Any
323
+ ) -> AsyncLROPoller[_models.AzureTrafficCollector]:
324
+ """Creates or updates a Azure Traffic Collector resource.
325
+
326
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
327
+ Required.
328
+ :type resource_group_name: str
329
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
330
+ :type azure_traffic_collector_name: str
331
+ :param parameters: The parameters to provide for the created Azure Traffic Collector. Is one of
332
+ the following types: AzureTrafficCollector, JSON, IO[bytes] Required.
333
+ :type parameters: ~azure.mgmt.networkfunction.models.AzureTrafficCollector or JSON or IO[bytes]
334
+ :return: An instance of AsyncLROPoller that returns AzureTrafficCollector. The
335
+ AzureTrafficCollector is compatible with MutableMapping
336
+ :rtype:
337
+ ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.AzureTrafficCollector]
338
+ :raises ~azure.core.exceptions.HttpResponseError:
339
+ """
340
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
341
+ _params = kwargs.pop("params", {}) or {}
342
+
343
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
344
+ cls: ClsType[_models.AzureTrafficCollector] = kwargs.pop("cls", None)
345
+ polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
346
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
347
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
348
+ if cont_token is None:
349
+ raw_result = await self._create_or_update_initial(
350
+ resource_group_name=resource_group_name,
351
+ azure_traffic_collector_name=azure_traffic_collector_name,
352
+ parameters=parameters,
353
+ content_type=content_type,
354
+ cls=lambda x, y, z: x,
355
+ headers=_headers,
356
+ params=_params,
357
+ **kwargs
358
+ )
359
+ await raw_result.http_response.read() # type: ignore
360
+ kwargs.pop("error_map", None)
361
+
362
+ def get_long_running_output(pipeline_response):
363
+ response = pipeline_response.http_response
364
+ deserialized = _deserialize(_models.AzureTrafficCollector, response.json())
365
+ if cls:
366
+ return cls(pipeline_response, deserialized, {}) # type: ignore
367
+ return deserialized
368
+
369
+ path_format_arguments = {
370
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
371
+ }
372
+
373
+ if polling is True:
374
+ polling_method: AsyncPollingMethod = cast(
375
+ AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
376
+ )
377
+ elif polling is False:
378
+ polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
379
+ else:
380
+ polling_method = polling
381
+ if cont_token:
382
+ return AsyncLROPoller[_models.AzureTrafficCollector].from_continuation_token(
383
+ polling_method=polling_method,
384
+ continuation_token=cont_token,
385
+ client=self._client,
386
+ deserialization_callback=get_long_running_output,
387
+ )
388
+ return AsyncLROPoller[_models.AzureTrafficCollector](
389
+ self._client, raw_result, get_long_running_output, polling_method # type: ignore
390
+ )
391
+
392
+ @overload
393
+ async def update_tags(
394
+ self,
395
+ resource_group_name: str,
396
+ azure_traffic_collector_name: str,
397
+ parameters: _models.TagsObject,
398
+ *,
399
+ content_type: str = "application/json",
400
+ **kwargs: Any
401
+ ) -> _models.AzureTrafficCollector:
402
+ """Updates the specified Azure Traffic Collector tags.
403
+
404
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
405
+ Required.
406
+ :type resource_group_name: str
407
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
408
+ :type azure_traffic_collector_name: str
409
+ :param parameters: Parameters supplied to update Azure Traffic Collector tags. Required.
410
+ :type parameters: ~azure.mgmt.networkfunction.models.TagsObject
411
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
412
+ Default value is "application/json".
413
+ :paramtype content_type: str
414
+ :return: AzureTrafficCollector. The AzureTrafficCollector is compatible with MutableMapping
415
+ :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector
416
+ :raises ~azure.core.exceptions.HttpResponseError:
417
+ """
418
+
419
+ @overload
420
+ async def update_tags(
421
+ self,
422
+ resource_group_name: str,
423
+ azure_traffic_collector_name: str,
424
+ parameters: JSON,
425
+ *,
426
+ content_type: str = "application/json",
427
+ **kwargs: Any
428
+ ) -> _models.AzureTrafficCollector:
429
+ """Updates the specified Azure Traffic Collector tags.
430
+
431
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
432
+ Required.
433
+ :type resource_group_name: str
434
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
435
+ :type azure_traffic_collector_name: str
436
+ :param parameters: Parameters supplied to update Azure Traffic Collector tags. Required.
437
+ :type parameters: JSON
438
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
439
+ Default value is "application/json".
440
+ :paramtype content_type: str
441
+ :return: AzureTrafficCollector. The AzureTrafficCollector is compatible with MutableMapping
442
+ :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector
443
+ :raises ~azure.core.exceptions.HttpResponseError:
444
+ """
445
+
446
+ @overload
447
+ async def update_tags(
448
+ self,
449
+ resource_group_name: str,
450
+ azure_traffic_collector_name: str,
451
+ parameters: IO[bytes],
452
+ *,
453
+ content_type: str = "application/json",
454
+ **kwargs: Any
455
+ ) -> _models.AzureTrafficCollector:
456
+ """Updates the specified Azure Traffic Collector tags.
457
+
458
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
459
+ Required.
460
+ :type resource_group_name: str
461
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
462
+ :type azure_traffic_collector_name: str
463
+ :param parameters: Parameters supplied to update Azure Traffic Collector tags. Required.
464
+ :type parameters: IO[bytes]
465
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
466
+ Default value is "application/json".
467
+ :paramtype content_type: str
468
+ :return: AzureTrafficCollector. The AzureTrafficCollector is compatible with MutableMapping
469
+ :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector
470
+ :raises ~azure.core.exceptions.HttpResponseError:
471
+ """
472
+
473
+ @distributed_trace_async
474
+ async def update_tags(
475
+ self,
476
+ resource_group_name: str,
477
+ azure_traffic_collector_name: str,
478
+ parameters: Union[_models.TagsObject, JSON, IO[bytes]],
479
+ **kwargs: Any
480
+ ) -> _models.AzureTrafficCollector:
481
+ """Updates the specified Azure Traffic Collector tags.
482
+
483
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
484
+ Required.
485
+ :type resource_group_name: str
486
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
487
+ :type azure_traffic_collector_name: str
488
+ :param parameters: Parameters supplied to update Azure Traffic Collector tags. Is one of the
489
+ following types: TagsObject, JSON, IO[bytes] Required.
490
+ :type parameters: ~azure.mgmt.networkfunction.models.TagsObject or JSON or IO[bytes]
491
+ :return: AzureTrafficCollector. The AzureTrafficCollector is compatible with MutableMapping
492
+ :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector
493
+ :raises ~azure.core.exceptions.HttpResponseError:
494
+ """
495
+ error_map: MutableMapping = {
496
+ 401: ClientAuthenticationError,
497
+ 404: ResourceNotFoundError,
498
+ 409: ResourceExistsError,
499
+ 304: ResourceNotModifiedError,
500
+ }
501
+ error_map.update(kwargs.pop("error_map", {}) or {})
502
+
503
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
504
+ _params = kwargs.pop("params", {}) or {}
505
+
506
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
507
+ cls: ClsType[_models.AzureTrafficCollector] = kwargs.pop("cls", None)
508
+
509
+ content_type = content_type or "application/json"
510
+ _content = None
511
+ if isinstance(parameters, (IOBase, bytes)):
512
+ _content = parameters
513
+ else:
514
+ _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
515
+
516
+ _request = build_azure_traffic_collectors_update_tags_request(
517
+ resource_group_name=resource_group_name,
518
+ azure_traffic_collector_name=azure_traffic_collector_name,
519
+ subscription_id=self._config.subscription_id,
520
+ content_type=content_type,
521
+ api_version=self._config.api_version,
522
+ content=_content,
523
+ headers=_headers,
524
+ params=_params,
525
+ )
526
+ path_format_arguments = {
527
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
528
+ }
529
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
530
+
531
+ _decompress = kwargs.pop("decompress", True)
532
+ _stream = kwargs.pop("stream", False)
533
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
534
+ _request, stream=_stream, **kwargs
535
+ )
536
+
537
+ response = pipeline_response.http_response
538
+
539
+ if response.status_code not in [200]:
540
+ if _stream:
541
+ try:
542
+ await response.read() # Load the body in memory and close the socket
543
+ except (StreamConsumedError, StreamClosedError):
544
+ pass
545
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
546
+ error = _failsafe_deserialize(
547
+ _models.CloudError,
548
+ response,
549
+ )
550
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
551
+
552
+ if _stream:
553
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
554
+ else:
555
+ deserialized = _deserialize(_models.AzureTrafficCollector, response.json())
556
+
557
+ if cls:
558
+ return cls(pipeline_response, deserialized, {}) # type: ignore
559
+
560
+ return deserialized # type: ignore
561
+
562
+ async def _delete_initial(
563
+ self, resource_group_name: str, azure_traffic_collector_name: str, **kwargs: Any
564
+ ) -> AsyncIterator[bytes]:
565
+ error_map: MutableMapping = {
566
+ 401: ClientAuthenticationError,
567
+ 404: ResourceNotFoundError,
568
+ 409: ResourceExistsError,
569
+ 304: ResourceNotModifiedError,
570
+ }
571
+ error_map.update(kwargs.pop("error_map", {}) or {})
572
+
573
+ _headers = kwargs.pop("headers", {}) or {}
574
+ _params = kwargs.pop("params", {}) or {}
575
+
576
+ cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
577
+
578
+ _request = build_azure_traffic_collectors_delete_request(
579
+ resource_group_name=resource_group_name,
580
+ azure_traffic_collector_name=azure_traffic_collector_name,
581
+ subscription_id=self._config.subscription_id,
582
+ api_version=self._config.api_version,
583
+ headers=_headers,
584
+ params=_params,
585
+ )
586
+ path_format_arguments = {
587
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
588
+ }
589
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
590
+
591
+ _decompress = kwargs.pop("decompress", True)
592
+ _stream = True
593
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
594
+ _request, stream=_stream, **kwargs
595
+ )
596
+
597
+ response = pipeline_response.http_response
598
+
599
+ if response.status_code not in [200, 202, 204]:
600
+ try:
601
+ await response.read() # Load the body in memory and close the socket
602
+ except (StreamConsumedError, StreamClosedError):
603
+ pass
604
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
605
+ error = _failsafe_deserialize(
606
+ _models.CloudError,
607
+ response,
608
+ )
609
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
610
+
611
+ response_headers = {}
612
+ if response.status_code == 202:
613
+ response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
614
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
615
+
616
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
617
+
618
+ if cls:
619
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
620
+
621
+ return deserialized # type: ignore
622
+
623
+ @distributed_trace_async
624
+ async def begin_delete(
625
+ self, resource_group_name: str, azure_traffic_collector_name: str, **kwargs: Any
626
+ ) -> AsyncLROPoller[None]:
627
+ """Deletes a specified Azure Traffic Collector resource.
628
+
629
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
630
+ Required.
631
+ :type resource_group_name: str
632
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
633
+ :type azure_traffic_collector_name: str
634
+ :return: An instance of AsyncLROPoller that returns None
635
+ :rtype: ~azure.core.polling.AsyncLROPoller[None]
636
+ :raises ~azure.core.exceptions.HttpResponseError:
637
+ """
638
+ _headers = kwargs.pop("headers", {}) or {}
639
+ _params = kwargs.pop("params", {}) or {}
640
+
641
+ cls: ClsType[None] = kwargs.pop("cls", None)
642
+ polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
643
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
644
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
645
+ if cont_token is None:
646
+ raw_result = await self._delete_initial(
647
+ resource_group_name=resource_group_name,
648
+ azure_traffic_collector_name=azure_traffic_collector_name,
649
+ cls=lambda x, y, z: x,
650
+ headers=_headers,
651
+ params=_params,
652
+ **kwargs
653
+ )
654
+ await raw_result.http_response.read() # type: ignore
655
+ kwargs.pop("error_map", None)
656
+
657
+ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
658
+ if cls:
659
+ return cls(pipeline_response, None, {}) # type: ignore
660
+
661
+ path_format_arguments = {
662
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
663
+ }
664
+
665
+ if polling is True:
666
+ polling_method: AsyncPollingMethod = cast(
667
+ AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
668
+ )
669
+ elif polling is False:
670
+ polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
671
+ else:
672
+ polling_method = polling
673
+ if cont_token:
674
+ return AsyncLROPoller[None].from_continuation_token(
675
+ polling_method=polling_method,
676
+ continuation_token=cont_token,
677
+ client=self._client,
678
+ deserialization_callback=get_long_running_output,
679
+ )
680
+ return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
681
+
682
+
683
+ class CollectorPoliciesOperations:
684
+ """
685
+ .. warning::
686
+ **DO NOT** instantiate this class directly.
687
+
688
+ Instead, you should access the following operations through
689
+ :class:`~azure.mgmt.networkfunction.aio.TrafficCollectorMgmtClient`'s
690
+ :attr:`collector_policies` attribute.
691
+ """
692
+
693
+ def __init__(self, *args, **kwargs) -> None:
694
+ input_args = list(args)
695
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
696
+ self._config: TrafficCollectorMgmtClientConfiguration = (
697
+ input_args.pop(0) if input_args else kwargs.pop("config")
698
+ )
699
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
700
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
701
+
702
+ @distributed_trace_async
703
+ async def get(
704
+ self, resource_group_name: str, azure_traffic_collector_name: str, collector_policy_name: str, **kwargs: Any
705
+ ) -> _models.CollectorPolicy:
706
+ """Gets the collector policy in a specified Traffic Collector.
707
+
708
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
709
+ Required.
710
+ :type resource_group_name: str
711
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
712
+ :type azure_traffic_collector_name: str
713
+ :param collector_policy_name: Collector Policy Name. Required.
714
+ :type collector_policy_name: str
715
+ :return: CollectorPolicy. The CollectorPolicy is compatible with MutableMapping
716
+ :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy
717
+ :raises ~azure.core.exceptions.HttpResponseError:
718
+ """
719
+ error_map: MutableMapping = {
720
+ 401: ClientAuthenticationError,
721
+ 404: ResourceNotFoundError,
722
+ 409: ResourceExistsError,
723
+ 304: ResourceNotModifiedError,
724
+ }
725
+ error_map.update(kwargs.pop("error_map", {}) or {})
726
+
727
+ _headers = kwargs.pop("headers", {}) or {}
728
+ _params = kwargs.pop("params", {}) or {}
729
+
730
+ cls: ClsType[_models.CollectorPolicy] = kwargs.pop("cls", None)
731
+
732
+ _request = build_collector_policies_get_request(
733
+ resource_group_name=resource_group_name,
734
+ azure_traffic_collector_name=azure_traffic_collector_name,
735
+ collector_policy_name=collector_policy_name,
736
+ subscription_id=self._config.subscription_id,
737
+ api_version=self._config.api_version,
738
+ headers=_headers,
739
+ params=_params,
740
+ )
741
+ path_format_arguments = {
742
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
743
+ }
744
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
745
+
746
+ _decompress = kwargs.pop("decompress", True)
747
+ _stream = kwargs.pop("stream", False)
748
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
749
+ _request, stream=_stream, **kwargs
750
+ )
751
+
752
+ response = pipeline_response.http_response
753
+
754
+ if response.status_code not in [200]:
755
+ if _stream:
756
+ try:
757
+ await response.read() # Load the body in memory and close the socket
758
+ except (StreamConsumedError, StreamClosedError):
759
+ pass
760
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
761
+ error = _failsafe_deserialize(
762
+ _models.CloudError,
763
+ response,
764
+ )
765
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
766
+
767
+ if _stream:
768
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
769
+ else:
770
+ deserialized = _deserialize(_models.CollectorPolicy, response.json())
771
+
772
+ if cls:
773
+ return cls(pipeline_response, deserialized, {}) # type: ignore
774
+
775
+ return deserialized # type: ignore
776
+
777
+ async def _create_or_update_initial(
778
+ self,
779
+ resource_group_name: str,
780
+ azure_traffic_collector_name: str,
781
+ collector_policy_name: str,
782
+ parameters: Union[_models.CollectorPolicy, JSON, IO[bytes]],
783
+ **kwargs: Any
784
+ ) -> AsyncIterator[bytes]:
785
+ error_map: MutableMapping = {
786
+ 401: ClientAuthenticationError,
787
+ 404: ResourceNotFoundError,
788
+ 409: ResourceExistsError,
789
+ 304: ResourceNotModifiedError,
790
+ }
791
+ error_map.update(kwargs.pop("error_map", {}) or {})
792
+
793
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
794
+ _params = kwargs.pop("params", {}) or {}
795
+
796
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
797
+ cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
798
+
799
+ content_type = content_type or "application/json"
800
+ _content = None
801
+ if isinstance(parameters, (IOBase, bytes)):
802
+ _content = parameters
803
+ else:
804
+ _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
805
+
806
+ _request = build_collector_policies_create_or_update_request(
807
+ resource_group_name=resource_group_name,
808
+ azure_traffic_collector_name=azure_traffic_collector_name,
809
+ collector_policy_name=collector_policy_name,
810
+ subscription_id=self._config.subscription_id,
811
+ content_type=content_type,
812
+ api_version=self._config.api_version,
813
+ content=_content,
814
+ headers=_headers,
815
+ params=_params,
816
+ )
817
+ path_format_arguments = {
818
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
819
+ }
820
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
821
+
822
+ _decompress = kwargs.pop("decompress", True)
823
+ _stream = True
824
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
825
+ _request, stream=_stream, **kwargs
826
+ )
827
+
828
+ response = pipeline_response.http_response
829
+
830
+ if response.status_code not in [200, 201]:
831
+ try:
832
+ await response.read() # Load the body in memory and close the socket
833
+ except (StreamConsumedError, StreamClosedError):
834
+ pass
835
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
836
+ error = _failsafe_deserialize(
837
+ _models.CloudError,
838
+ response,
839
+ )
840
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
841
+
842
+ response_headers = {}
843
+ if response.status_code == 201:
844
+ response_headers["Azure-AsyncOperation"] = self._deserialize(
845
+ "str", response.headers.get("Azure-AsyncOperation")
846
+ )
847
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
848
+
849
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
850
+
851
+ if cls:
852
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
853
+
854
+ return deserialized # type: ignore
855
+
856
+ @overload
857
+ async def begin_create_or_update(
858
+ self,
859
+ resource_group_name: str,
860
+ azure_traffic_collector_name: str,
861
+ collector_policy_name: str,
862
+ parameters: _models.CollectorPolicy,
863
+ *,
864
+ content_type: str = "application/json",
865
+ **kwargs: Any
866
+ ) -> AsyncLROPoller[_models.CollectorPolicy]:
867
+ """Creates or updates a Collector Policy resource.
868
+
869
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
870
+ Required.
871
+ :type resource_group_name: str
872
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
873
+ :type azure_traffic_collector_name: str
874
+ :param collector_policy_name: Collector Policy Name. Required.
875
+ :type collector_policy_name: str
876
+ :param parameters: The parameters to provide for the created Collector Policy. Required.
877
+ :type parameters: ~azure.mgmt.networkfunction.models.CollectorPolicy
878
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
879
+ Default value is "application/json".
880
+ :paramtype content_type: str
881
+ :return: An instance of AsyncLROPoller that returns CollectorPolicy. The CollectorPolicy is
882
+ compatible with MutableMapping
883
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.CollectorPolicy]
884
+ :raises ~azure.core.exceptions.HttpResponseError:
885
+ """
886
+
887
+ @overload
888
+ async def begin_create_or_update(
889
+ self,
890
+ resource_group_name: str,
891
+ azure_traffic_collector_name: str,
892
+ collector_policy_name: str,
893
+ parameters: JSON,
894
+ *,
895
+ content_type: str = "application/json",
896
+ **kwargs: Any
897
+ ) -> AsyncLROPoller[_models.CollectorPolicy]:
898
+ """Creates or updates a Collector Policy resource.
899
+
900
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
901
+ Required.
902
+ :type resource_group_name: str
903
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
904
+ :type azure_traffic_collector_name: str
905
+ :param collector_policy_name: Collector Policy Name. Required.
906
+ :type collector_policy_name: str
907
+ :param parameters: The parameters to provide for the created Collector Policy. Required.
908
+ :type parameters: JSON
909
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
910
+ Default value is "application/json".
911
+ :paramtype content_type: str
912
+ :return: An instance of AsyncLROPoller that returns CollectorPolicy. The CollectorPolicy is
913
+ compatible with MutableMapping
914
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.CollectorPolicy]
915
+ :raises ~azure.core.exceptions.HttpResponseError:
916
+ """
917
+
918
+ @overload
919
+ async def begin_create_or_update(
920
+ self,
921
+ resource_group_name: str,
922
+ azure_traffic_collector_name: str,
923
+ collector_policy_name: str,
924
+ parameters: IO[bytes],
925
+ *,
926
+ content_type: str = "application/json",
927
+ **kwargs: Any
928
+ ) -> AsyncLROPoller[_models.CollectorPolicy]:
929
+ """Creates or updates a Collector Policy resource.
930
+
931
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
932
+ Required.
933
+ :type resource_group_name: str
934
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
935
+ :type azure_traffic_collector_name: str
936
+ :param collector_policy_name: Collector Policy Name. Required.
937
+ :type collector_policy_name: str
938
+ :param parameters: The parameters to provide for the created Collector Policy. Required.
939
+ :type parameters: IO[bytes]
940
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
941
+ Default value is "application/json".
942
+ :paramtype content_type: str
943
+ :return: An instance of AsyncLROPoller that returns CollectorPolicy. The CollectorPolicy is
944
+ compatible with MutableMapping
945
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.CollectorPolicy]
946
+ :raises ~azure.core.exceptions.HttpResponseError:
947
+ """
948
+
949
+ @distributed_trace_async
950
+ async def begin_create_or_update(
951
+ self,
952
+ resource_group_name: str,
953
+ azure_traffic_collector_name: str,
954
+ collector_policy_name: str,
955
+ parameters: Union[_models.CollectorPolicy, JSON, IO[bytes]],
956
+ **kwargs: Any
957
+ ) -> AsyncLROPoller[_models.CollectorPolicy]:
958
+ """Creates or updates a Collector Policy resource.
959
+
960
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
961
+ Required.
962
+ :type resource_group_name: str
963
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
964
+ :type azure_traffic_collector_name: str
965
+ :param collector_policy_name: Collector Policy Name. Required.
966
+ :type collector_policy_name: str
967
+ :param parameters: The parameters to provide for the created Collector Policy. Is one of the
968
+ following types: CollectorPolicy, JSON, IO[bytes] Required.
969
+ :type parameters: ~azure.mgmt.networkfunction.models.CollectorPolicy or JSON or IO[bytes]
970
+ :return: An instance of AsyncLROPoller that returns CollectorPolicy. The CollectorPolicy is
971
+ compatible with MutableMapping
972
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.CollectorPolicy]
973
+ :raises ~azure.core.exceptions.HttpResponseError:
974
+ """
975
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
976
+ _params = kwargs.pop("params", {}) or {}
977
+
978
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
979
+ cls: ClsType[_models.CollectorPolicy] = kwargs.pop("cls", None)
980
+ polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
981
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
982
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
983
+ if cont_token is None:
984
+ raw_result = await self._create_or_update_initial(
985
+ resource_group_name=resource_group_name,
986
+ azure_traffic_collector_name=azure_traffic_collector_name,
987
+ collector_policy_name=collector_policy_name,
988
+ parameters=parameters,
989
+ content_type=content_type,
990
+ cls=lambda x, y, z: x,
991
+ headers=_headers,
992
+ params=_params,
993
+ **kwargs
994
+ )
995
+ await raw_result.http_response.read() # type: ignore
996
+ kwargs.pop("error_map", None)
997
+
998
+ def get_long_running_output(pipeline_response):
999
+ response = pipeline_response.http_response
1000
+ deserialized = _deserialize(_models.CollectorPolicy, response.json())
1001
+ if cls:
1002
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1003
+ return deserialized
1004
+
1005
+ path_format_arguments = {
1006
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
1007
+ }
1008
+
1009
+ if polling is True:
1010
+ polling_method: AsyncPollingMethod = cast(
1011
+ AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
1012
+ )
1013
+ elif polling is False:
1014
+ polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
1015
+ else:
1016
+ polling_method = polling
1017
+ if cont_token:
1018
+ return AsyncLROPoller[_models.CollectorPolicy].from_continuation_token(
1019
+ polling_method=polling_method,
1020
+ continuation_token=cont_token,
1021
+ client=self._client,
1022
+ deserialization_callback=get_long_running_output,
1023
+ )
1024
+ return AsyncLROPoller[_models.CollectorPolicy](
1025
+ self._client, raw_result, get_long_running_output, polling_method # type: ignore
1026
+ )
1027
+
1028
+ @overload
1029
+ async def update_tags(
1030
+ self,
1031
+ resource_group_name: str,
1032
+ azure_traffic_collector_name: str,
1033
+ collector_policy_name: str,
1034
+ parameters: _models.TagsObject,
1035
+ *,
1036
+ content_type: str = "application/json",
1037
+ **kwargs: Any
1038
+ ) -> _models.CollectorPolicy:
1039
+ """Updates the specified Collector Policy tags.
1040
+
1041
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1042
+ Required.
1043
+ :type resource_group_name: str
1044
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
1045
+ :type azure_traffic_collector_name: str
1046
+ :param collector_policy_name: Collector Policy Name. Required.
1047
+ :type collector_policy_name: str
1048
+ :param parameters: The resource properties to be updated. Required.
1049
+ :type parameters: ~azure.mgmt.networkfunction.models.TagsObject
1050
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1051
+ Default value is "application/json".
1052
+ :paramtype content_type: str
1053
+ :return: CollectorPolicy. The CollectorPolicy is compatible with MutableMapping
1054
+ :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy
1055
+ :raises ~azure.core.exceptions.HttpResponseError:
1056
+ """
1057
+
1058
+ @overload
1059
+ async def update_tags(
1060
+ self,
1061
+ resource_group_name: str,
1062
+ azure_traffic_collector_name: str,
1063
+ collector_policy_name: str,
1064
+ parameters: JSON,
1065
+ *,
1066
+ content_type: str = "application/json",
1067
+ **kwargs: Any
1068
+ ) -> _models.CollectorPolicy:
1069
+ """Updates the specified Collector Policy tags.
1070
+
1071
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1072
+ Required.
1073
+ :type resource_group_name: str
1074
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
1075
+ :type azure_traffic_collector_name: str
1076
+ :param collector_policy_name: Collector Policy Name. Required.
1077
+ :type collector_policy_name: str
1078
+ :param parameters: The resource properties to be updated. Required.
1079
+ :type parameters: JSON
1080
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1081
+ Default value is "application/json".
1082
+ :paramtype content_type: str
1083
+ :return: CollectorPolicy. The CollectorPolicy is compatible with MutableMapping
1084
+ :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy
1085
+ :raises ~azure.core.exceptions.HttpResponseError:
1086
+ """
1087
+
1088
+ @overload
1089
+ async def update_tags(
1090
+ self,
1091
+ resource_group_name: str,
1092
+ azure_traffic_collector_name: str,
1093
+ collector_policy_name: str,
1094
+ parameters: IO[bytes],
1095
+ *,
1096
+ content_type: str = "application/json",
1097
+ **kwargs: Any
1098
+ ) -> _models.CollectorPolicy:
1099
+ """Updates the specified Collector Policy tags.
1100
+
1101
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1102
+ Required.
1103
+ :type resource_group_name: str
1104
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
1105
+ :type azure_traffic_collector_name: str
1106
+ :param collector_policy_name: Collector Policy Name. Required.
1107
+ :type collector_policy_name: str
1108
+ :param parameters: The resource properties to be updated. Required.
1109
+ :type parameters: IO[bytes]
1110
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
1111
+ Default value is "application/json".
1112
+ :paramtype content_type: str
1113
+ :return: CollectorPolicy. The CollectorPolicy is compatible with MutableMapping
1114
+ :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy
1115
+ :raises ~azure.core.exceptions.HttpResponseError:
1116
+ """
1117
+
1118
+ @distributed_trace_async
1119
+ async def update_tags(
1120
+ self,
1121
+ resource_group_name: str,
1122
+ azure_traffic_collector_name: str,
1123
+ collector_policy_name: str,
1124
+ parameters: Union[_models.TagsObject, JSON, IO[bytes]],
1125
+ **kwargs: Any
1126
+ ) -> _models.CollectorPolicy:
1127
+ """Updates the specified Collector Policy tags.
1128
+
1129
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1130
+ Required.
1131
+ :type resource_group_name: str
1132
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
1133
+ :type azure_traffic_collector_name: str
1134
+ :param collector_policy_name: Collector Policy Name. Required.
1135
+ :type collector_policy_name: str
1136
+ :param parameters: The resource properties to be updated. Is one of the following types:
1137
+ TagsObject, JSON, IO[bytes] Required.
1138
+ :type parameters: ~azure.mgmt.networkfunction.models.TagsObject or JSON or IO[bytes]
1139
+ :return: CollectorPolicy. The CollectorPolicy is compatible with MutableMapping
1140
+ :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy
1141
+ :raises ~azure.core.exceptions.HttpResponseError:
1142
+ """
1143
+ error_map: MutableMapping = {
1144
+ 401: ClientAuthenticationError,
1145
+ 404: ResourceNotFoundError,
1146
+ 409: ResourceExistsError,
1147
+ 304: ResourceNotModifiedError,
1148
+ }
1149
+ error_map.update(kwargs.pop("error_map", {}) or {})
1150
+
1151
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1152
+ _params = kwargs.pop("params", {}) or {}
1153
+
1154
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1155
+ cls: ClsType[_models.CollectorPolicy] = kwargs.pop("cls", None)
1156
+
1157
+ content_type = content_type or "application/json"
1158
+ _content = None
1159
+ if isinstance(parameters, (IOBase, bytes)):
1160
+ _content = parameters
1161
+ else:
1162
+ _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
1163
+
1164
+ _request = build_collector_policies_update_tags_request(
1165
+ resource_group_name=resource_group_name,
1166
+ azure_traffic_collector_name=azure_traffic_collector_name,
1167
+ collector_policy_name=collector_policy_name,
1168
+ subscription_id=self._config.subscription_id,
1169
+ content_type=content_type,
1170
+ api_version=self._config.api_version,
1171
+ content=_content,
1172
+ headers=_headers,
1173
+ params=_params,
1174
+ )
1175
+ path_format_arguments = {
1176
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
1177
+ }
1178
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1179
+
1180
+ _decompress = kwargs.pop("decompress", True)
1181
+ _stream = kwargs.pop("stream", False)
1182
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1183
+ _request, stream=_stream, **kwargs
1184
+ )
1185
+
1186
+ response = pipeline_response.http_response
1187
+
1188
+ if response.status_code not in [200]:
1189
+ if _stream:
1190
+ try:
1191
+ await response.read() # Load the body in memory and close the socket
1192
+ except (StreamConsumedError, StreamClosedError):
1193
+ pass
1194
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1195
+ error = _failsafe_deserialize(
1196
+ _models.CloudError,
1197
+ response,
1198
+ )
1199
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1200
+
1201
+ if _stream:
1202
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
1203
+ else:
1204
+ deserialized = _deserialize(_models.CollectorPolicy, response.json())
1205
+
1206
+ if cls:
1207
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1208
+
1209
+ return deserialized # type: ignore
1210
+
1211
+ async def _delete_initial(
1212
+ self, resource_group_name: str, azure_traffic_collector_name: str, collector_policy_name: str, **kwargs: Any
1213
+ ) -> AsyncIterator[bytes]:
1214
+ error_map: MutableMapping = {
1215
+ 401: ClientAuthenticationError,
1216
+ 404: ResourceNotFoundError,
1217
+ 409: ResourceExistsError,
1218
+ 304: ResourceNotModifiedError,
1219
+ }
1220
+ error_map.update(kwargs.pop("error_map", {}) or {})
1221
+
1222
+ _headers = kwargs.pop("headers", {}) or {}
1223
+ _params = kwargs.pop("params", {}) or {}
1224
+
1225
+ cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
1226
+
1227
+ _request = build_collector_policies_delete_request(
1228
+ resource_group_name=resource_group_name,
1229
+ azure_traffic_collector_name=azure_traffic_collector_name,
1230
+ collector_policy_name=collector_policy_name,
1231
+ subscription_id=self._config.subscription_id,
1232
+ api_version=self._config.api_version,
1233
+ headers=_headers,
1234
+ params=_params,
1235
+ )
1236
+ path_format_arguments = {
1237
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
1238
+ }
1239
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1240
+
1241
+ _decompress = kwargs.pop("decompress", True)
1242
+ _stream = True
1243
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1244
+ _request, stream=_stream, **kwargs
1245
+ )
1246
+
1247
+ response = pipeline_response.http_response
1248
+
1249
+ if response.status_code not in [200, 202, 204]:
1250
+ try:
1251
+ await response.read() # Load the body in memory and close the socket
1252
+ except (StreamConsumedError, StreamClosedError):
1253
+ pass
1254
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1255
+ error = _failsafe_deserialize(
1256
+ _models.CloudError,
1257
+ response,
1258
+ )
1259
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1260
+
1261
+ response_headers = {}
1262
+ if response.status_code == 202:
1263
+ response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
1264
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
1265
+
1266
+ deserialized = response.iter_bytes() if _decompress else response.iter_raw()
1267
+
1268
+ if cls:
1269
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
1270
+
1271
+ return deserialized # type: ignore
1272
+
1273
+ @distributed_trace_async
1274
+ async def begin_delete(
1275
+ self, resource_group_name: str, azure_traffic_collector_name: str, collector_policy_name: str, **kwargs: Any
1276
+ ) -> AsyncLROPoller[None]:
1277
+ """Deletes a specified Collector Policy resource.
1278
+
1279
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1280
+ Required.
1281
+ :type resource_group_name: str
1282
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
1283
+ :type azure_traffic_collector_name: str
1284
+ :param collector_policy_name: Collector Policy Name. Required.
1285
+ :type collector_policy_name: str
1286
+ :return: An instance of AsyncLROPoller that returns None
1287
+ :rtype: ~azure.core.polling.AsyncLROPoller[None]
1288
+ :raises ~azure.core.exceptions.HttpResponseError:
1289
+ """
1290
+ _headers = kwargs.pop("headers", {}) or {}
1291
+ _params = kwargs.pop("params", {}) or {}
1292
+
1293
+ cls: ClsType[None] = kwargs.pop("cls", None)
1294
+ polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
1295
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
1296
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
1297
+ if cont_token is None:
1298
+ raw_result = await self._delete_initial(
1299
+ resource_group_name=resource_group_name,
1300
+ azure_traffic_collector_name=azure_traffic_collector_name,
1301
+ collector_policy_name=collector_policy_name,
1302
+ cls=lambda x, y, z: x,
1303
+ headers=_headers,
1304
+ params=_params,
1305
+ **kwargs
1306
+ )
1307
+ await raw_result.http_response.read() # type: ignore
1308
+ kwargs.pop("error_map", None)
1309
+
1310
+ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
1311
+ if cls:
1312
+ return cls(pipeline_response, None, {}) # type: ignore
1313
+
1314
+ path_format_arguments = {
1315
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
1316
+ }
1317
+
1318
+ if polling is True:
1319
+ polling_method: AsyncPollingMethod = cast(
1320
+ AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
1321
+ )
1322
+ elif polling is False:
1323
+ polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
1324
+ else:
1325
+ polling_method = polling
1326
+ if cont_token:
1327
+ return AsyncLROPoller[None].from_continuation_token(
1328
+ polling_method=polling_method,
1329
+ continuation_token=cont_token,
1330
+ client=self._client,
1331
+ deserialization_callback=get_long_running_output,
1332
+ )
1333
+ return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
1334
+
1335
+ @distributed_trace
1336
+ def list(
1337
+ self, resource_group_name: str, azure_traffic_collector_name: str, **kwargs: Any
1338
+ ) -> AsyncItemPaged["_models.CollectorPolicy"]:
1339
+ """Return list of Collector policies in a Azure Traffic Collector.
1340
+
1341
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1342
+ Required.
1343
+ :type resource_group_name: str
1344
+ :param azure_traffic_collector_name: Azure Traffic Collector name. Required.
1345
+ :type azure_traffic_collector_name: str
1346
+ :return: An iterator like instance of CollectorPolicy
1347
+ :rtype:
1348
+ ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.CollectorPolicy]
1349
+ :raises ~azure.core.exceptions.HttpResponseError:
1350
+ """
1351
+ _headers = kwargs.pop("headers", {}) or {}
1352
+ _params = kwargs.pop("params", {}) or {}
1353
+
1354
+ cls: ClsType[List[_models.CollectorPolicy]] = kwargs.pop("cls", None)
1355
+
1356
+ error_map: MutableMapping = {
1357
+ 401: ClientAuthenticationError,
1358
+ 404: ResourceNotFoundError,
1359
+ 409: ResourceExistsError,
1360
+ 304: ResourceNotModifiedError,
1361
+ }
1362
+ error_map.update(kwargs.pop("error_map", {}) or {})
1363
+
1364
+ def prepare_request(next_link=None):
1365
+ if not next_link:
1366
+
1367
+ _request = build_collector_policies_list_request(
1368
+ resource_group_name=resource_group_name,
1369
+ azure_traffic_collector_name=azure_traffic_collector_name,
1370
+ subscription_id=self._config.subscription_id,
1371
+ api_version=self._config.api_version,
1372
+ headers=_headers,
1373
+ params=_params,
1374
+ )
1375
+ path_format_arguments = {
1376
+ "endpoint": self._serialize.url(
1377
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1378
+ ),
1379
+ }
1380
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1381
+
1382
+ else:
1383
+ # make call to next link with the client's api-version
1384
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1385
+ _next_request_params = case_insensitive_dict(
1386
+ {
1387
+ key: [urllib.parse.quote(v) for v in value]
1388
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1389
+ }
1390
+ )
1391
+ _next_request_params["api-version"] = self._config.api_version
1392
+ _request = HttpRequest(
1393
+ "GET",
1394
+ urllib.parse.urljoin(next_link, _parsed_next_link.path),
1395
+ headers=_headers,
1396
+ params=_next_request_params,
1397
+ )
1398
+ path_format_arguments = {
1399
+ "endpoint": self._serialize.url(
1400
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1401
+ ),
1402
+ }
1403
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1404
+
1405
+ return _request
1406
+
1407
+ async def extract_data(pipeline_response):
1408
+ deserialized = pipeline_response.http_response.json()
1409
+ list_of_elem = _deserialize(
1410
+ List[_models.CollectorPolicy],
1411
+ deserialized.get("value", []),
1412
+ )
1413
+ if cls:
1414
+ list_of_elem = cls(list_of_elem) # type: ignore
1415
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1416
+
1417
+ async def get_next(next_link=None):
1418
+ _request = prepare_request(next_link)
1419
+
1420
+ _stream = False
1421
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1422
+ _request, stream=_stream, **kwargs
1423
+ )
1424
+ response = pipeline_response.http_response
1425
+
1426
+ if response.status_code not in [200]:
1427
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1428
+ error = _failsafe_deserialize(
1429
+ _models.CloudError,
1430
+ response,
1431
+ )
1432
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1433
+
1434
+ return pipeline_response
1435
+
1436
+ return AsyncItemPaged(get_next, extract_data)
1437
+
1438
+
1439
+ class NetworkFunctionOperations:
1440
+ """
1441
+ .. warning::
1442
+ **DO NOT** instantiate this class directly.
1443
+
1444
+ Instead, you should access the following operations through
1445
+ :class:`~azure.mgmt.networkfunction.aio.TrafficCollectorMgmtClient`'s
1446
+ :attr:`network_function` attribute.
1447
+ """
1448
+
1449
+ def __init__(self, *args, **kwargs) -> None:
1450
+ input_args = list(args)
1451
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
1452
+ self._config: TrafficCollectorMgmtClientConfiguration = (
1453
+ input_args.pop(0) if input_args else kwargs.pop("config")
1454
+ )
1455
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
1456
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1457
+
1458
+ @distributed_trace
1459
+ def list_operations(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]:
1460
+ """Lists all of the available NetworkFunction Rest API operations.
1461
+
1462
+ :return: An iterator like instance of Operation
1463
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.Operation]
1464
+ :raises ~azure.core.exceptions.HttpResponseError:
1465
+ """
1466
+ _headers = kwargs.pop("headers", {}) or {}
1467
+ _params = kwargs.pop("params", {}) or {}
1468
+
1469
+ cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None)
1470
+
1471
+ error_map: MutableMapping = {
1472
+ 401: ClientAuthenticationError,
1473
+ 404: ResourceNotFoundError,
1474
+ 409: ResourceExistsError,
1475
+ 304: ResourceNotModifiedError,
1476
+ }
1477
+ error_map.update(kwargs.pop("error_map", {}) or {})
1478
+
1479
+ def prepare_request(next_link=None):
1480
+ if not next_link:
1481
+
1482
+ _request = build_network_function_list_operations_request(
1483
+ api_version=self._config.api_version,
1484
+ headers=_headers,
1485
+ params=_params,
1486
+ )
1487
+ path_format_arguments = {
1488
+ "endpoint": self._serialize.url(
1489
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1490
+ ),
1491
+ }
1492
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1493
+
1494
+ else:
1495
+ # make call to next link with the client's api-version
1496
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1497
+ _next_request_params = case_insensitive_dict(
1498
+ {
1499
+ key: [urllib.parse.quote(v) for v in value]
1500
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1501
+ }
1502
+ )
1503
+ _next_request_params["api-version"] = self._config.api_version
1504
+ _request = HttpRequest(
1505
+ "GET",
1506
+ urllib.parse.urljoin(next_link, _parsed_next_link.path),
1507
+ headers=_headers,
1508
+ params=_next_request_params,
1509
+ )
1510
+ path_format_arguments = {
1511
+ "endpoint": self._serialize.url(
1512
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1513
+ ),
1514
+ }
1515
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1516
+
1517
+ return _request
1518
+
1519
+ async def extract_data(pipeline_response):
1520
+ deserialized = pipeline_response.http_response.json()
1521
+ list_of_elem = _deserialize(
1522
+ List[_models.Operation],
1523
+ deserialized.get("value", []),
1524
+ )
1525
+ if cls:
1526
+ list_of_elem = cls(list_of_elem) # type: ignore
1527
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1528
+
1529
+ async def get_next(next_link=None):
1530
+ _request = prepare_request(next_link)
1531
+
1532
+ _stream = False
1533
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1534
+ _request, stream=_stream, **kwargs
1535
+ )
1536
+ response = pipeline_response.http_response
1537
+
1538
+ if response.status_code not in [200]:
1539
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1540
+ error = _failsafe_deserialize(
1541
+ _models.CloudError,
1542
+ response,
1543
+ )
1544
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1545
+
1546
+ return pipeline_response
1547
+
1548
+ return AsyncItemPaged(get_next, extract_data)
1549
+
1550
+
1551
+ class AzureTrafficCollectorsByResourceGroupOperations: # pylint: disable=name-too-long
1552
+ """
1553
+ .. warning::
1554
+ **DO NOT** instantiate this class directly.
1555
+
1556
+ Instead, you should access the following operations through
1557
+ :class:`~azure.mgmt.networkfunction.aio.TrafficCollectorMgmtClient`'s
1558
+ :attr:`azure_traffic_collectors_by_resource_group` attribute.
1559
+ """
1560
+
1561
+ def __init__(self, *args, **kwargs) -> None:
1562
+ input_args = list(args)
1563
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
1564
+ self._config: TrafficCollectorMgmtClientConfiguration = (
1565
+ input_args.pop(0) if input_args else kwargs.pop("config")
1566
+ )
1567
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
1568
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1569
+
1570
+ @distributed_trace
1571
+ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AzureTrafficCollector"]:
1572
+ """Return list of Azure Traffic Collectors in a Resource Group.
1573
+
1574
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1575
+ Required.
1576
+ :type resource_group_name: str
1577
+ :return: An iterator like instance of AzureTrafficCollector
1578
+ :rtype:
1579
+ ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.AzureTrafficCollector]
1580
+ :raises ~azure.core.exceptions.HttpResponseError:
1581
+ """
1582
+ _headers = kwargs.pop("headers", {}) or {}
1583
+ _params = kwargs.pop("params", {}) or {}
1584
+
1585
+ cls: ClsType[List[_models.AzureTrafficCollector]] = kwargs.pop("cls", None)
1586
+
1587
+ error_map: MutableMapping = {
1588
+ 401: ClientAuthenticationError,
1589
+ 404: ResourceNotFoundError,
1590
+ 409: ResourceExistsError,
1591
+ 304: ResourceNotModifiedError,
1592
+ }
1593
+ error_map.update(kwargs.pop("error_map", {}) or {})
1594
+
1595
+ def prepare_request(next_link=None):
1596
+ if not next_link:
1597
+
1598
+ _request = build_azure_traffic_collectors_by_resource_group_list_request(
1599
+ resource_group_name=resource_group_name,
1600
+ subscription_id=self._config.subscription_id,
1601
+ api_version=self._config.api_version,
1602
+ headers=_headers,
1603
+ params=_params,
1604
+ )
1605
+ path_format_arguments = {
1606
+ "endpoint": self._serialize.url(
1607
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1608
+ ),
1609
+ }
1610
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1611
+
1612
+ else:
1613
+ # make call to next link with the client's api-version
1614
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1615
+ _next_request_params = case_insensitive_dict(
1616
+ {
1617
+ key: [urllib.parse.quote(v) for v in value]
1618
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1619
+ }
1620
+ )
1621
+ _next_request_params["api-version"] = self._config.api_version
1622
+ _request = HttpRequest(
1623
+ "GET",
1624
+ urllib.parse.urljoin(next_link, _parsed_next_link.path),
1625
+ headers=_headers,
1626
+ params=_next_request_params,
1627
+ )
1628
+ path_format_arguments = {
1629
+ "endpoint": self._serialize.url(
1630
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1631
+ ),
1632
+ }
1633
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1634
+
1635
+ return _request
1636
+
1637
+ async def extract_data(pipeline_response):
1638
+ deserialized = pipeline_response.http_response.json()
1639
+ list_of_elem = _deserialize(
1640
+ List[_models.AzureTrafficCollector],
1641
+ deserialized.get("value", []),
1642
+ )
1643
+ if cls:
1644
+ list_of_elem = cls(list_of_elem) # type: ignore
1645
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1646
+
1647
+ async def get_next(next_link=None):
1648
+ _request = prepare_request(next_link)
1649
+
1650
+ _stream = False
1651
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1652
+ _request, stream=_stream, **kwargs
1653
+ )
1654
+ response = pipeline_response.http_response
1655
+
1656
+ if response.status_code not in [200]:
1657
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1658
+ error = _failsafe_deserialize(
1659
+ _models.CloudError,
1660
+ response,
1661
+ )
1662
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1663
+
1664
+ return pipeline_response
1665
+
1666
+ return AsyncItemPaged(get_next, extract_data)
1667
+
1668
+
1669
+ class AzureTrafficCollectorsBySubscriptionOperations: # pylint: disable=name-too-long
1670
+ """
1671
+ .. warning::
1672
+ **DO NOT** instantiate this class directly.
1673
+
1674
+ Instead, you should access the following operations through
1675
+ :class:`~azure.mgmt.networkfunction.aio.TrafficCollectorMgmtClient`'s
1676
+ :attr:`azure_traffic_collectors_by_subscription` attribute.
1677
+ """
1678
+
1679
+ def __init__(self, *args, **kwargs) -> None:
1680
+ input_args = list(args)
1681
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
1682
+ self._config: TrafficCollectorMgmtClientConfiguration = (
1683
+ input_args.pop(0) if input_args else kwargs.pop("config")
1684
+ )
1685
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
1686
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1687
+
1688
+ @distributed_trace
1689
+ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.AzureTrafficCollector"]:
1690
+ """Return list of Azure Traffic Collectors in a subscription.
1691
+
1692
+ :return: An iterator like instance of AzureTrafficCollector
1693
+ :rtype:
1694
+ ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.AzureTrafficCollector]
1695
+ :raises ~azure.core.exceptions.HttpResponseError:
1696
+ """
1697
+ _headers = kwargs.pop("headers", {}) or {}
1698
+ _params = kwargs.pop("params", {}) or {}
1699
+
1700
+ cls: ClsType[List[_models.AzureTrafficCollector]] = kwargs.pop("cls", None)
1701
+
1702
+ error_map: MutableMapping = {
1703
+ 401: ClientAuthenticationError,
1704
+ 404: ResourceNotFoundError,
1705
+ 409: ResourceExistsError,
1706
+ 304: ResourceNotModifiedError,
1707
+ }
1708
+ error_map.update(kwargs.pop("error_map", {}) or {})
1709
+
1710
+ def prepare_request(next_link=None):
1711
+ if not next_link:
1712
+
1713
+ _request = build_azure_traffic_collectors_by_subscription_list_request(
1714
+ subscription_id=self._config.subscription_id,
1715
+ api_version=self._config.api_version,
1716
+ headers=_headers,
1717
+ params=_params,
1718
+ )
1719
+ path_format_arguments = {
1720
+ "endpoint": self._serialize.url(
1721
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1722
+ ),
1723
+ }
1724
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1725
+
1726
+ else:
1727
+ # make call to next link with the client's api-version
1728
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1729
+ _next_request_params = case_insensitive_dict(
1730
+ {
1731
+ key: [urllib.parse.quote(v) for v in value]
1732
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1733
+ }
1734
+ )
1735
+ _next_request_params["api-version"] = self._config.api_version
1736
+ _request = HttpRequest(
1737
+ "GET",
1738
+ urllib.parse.urljoin(next_link, _parsed_next_link.path),
1739
+ headers=_headers,
1740
+ params=_next_request_params,
1741
+ )
1742
+ path_format_arguments = {
1743
+ "endpoint": self._serialize.url(
1744
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1745
+ ),
1746
+ }
1747
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1748
+
1749
+ return _request
1750
+
1751
+ async def extract_data(pipeline_response):
1752
+ deserialized = pipeline_response.http_response.json()
1753
+ list_of_elem = _deserialize(
1754
+ List[_models.AzureTrafficCollector],
1755
+ deserialized.get("value", []),
1756
+ )
1757
+ if cls:
1758
+ list_of_elem = cls(list_of_elem) # type: ignore
1759
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1760
+
1761
+ async def get_next(next_link=None):
1762
+ _request = prepare_request(next_link)
1763
+
1764
+ _stream = False
1765
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1766
+ _request, stream=_stream, **kwargs
1767
+ )
1768
+ response = pipeline_response.http_response
1769
+
1770
+ if response.status_code not in [200]:
1771
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1772
+ error = _failsafe_deserialize(
1773
+ _models.CloudError,
1774
+ response,
1775
+ )
1776
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1777
+
1778
+ return pipeline_response
1779
+
1780
+ return AsyncItemPaged(get_next, extract_data)