From 6c563c39c2fdc22048d7bb0493842a3ccb224853 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 16 May 2022 03:53:39 +0000 Subject: [PATCH] CodeGen from PR 18927 in Azure/azure-rest-api-specs Azure Traffic Collector changes (#18927) * Azure Traffic Collector changes * spell check and prettier fix * avocado, model validation fixes * lint fixes * lint fixes for array item id * undo arrayitem lint fixes * Update readme.md * Update readme.python.md * updated swagger * updated swagger * updated swagger * updated swagger * updated swagger Co-authored-by: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> --- .../azure-mgmt-networkfunction/CHANGELOG.md | 5 + .../azure-mgmt-networkfunction/LICENSE | 21 + .../azure-mgmt-networkfunction/MANIFEST.in | 7 + .../azure-mgmt-networkfunction/README.md | 30 + .../azure-mgmt-networkfunction/_meta.json | 11 + .../azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/networkfunction/__init__.py | 18 + .../_azure_traffic_collector.py | 114 +++ .../mgmt/networkfunction/_configuration.py | 73 ++ .../azure/mgmt/networkfunction/_metadata.json | 106 +++ .../azure/mgmt/networkfunction/_patch.py | 31 + .../azure/mgmt/networkfunction/_vendor.py | 27 + .../azure/mgmt/networkfunction/_version.py | 9 + .../mgmt/networkfunction/aio/__init__.py | 15 + .../aio/_azure_traffic_collector.py | 112 +++ .../networkfunction/aio/_configuration.py | 72 ++ .../azure/mgmt/networkfunction/aio/_patch.py | 31 + .../aio/operations/__init__.py | 21 + ...collectors_by_resource_group_operations.py | 123 +++ ...c_collectors_by_subscription_operations.py | 118 +++ .../_azure_traffic_collectors_operations.py | 419 +++++++++ .../_collector_policies_operations.py | 443 ++++++++++ .../_network_function_operations.py | 115 +++ .../mgmt/networkfunction/models/__init__.py | 65 ++ .../models/_azure_traffic_collector_enums.py | 54 ++ .../networkfunction/models/_models_py3.py | 835 ++++++++++++++++++ .../networkfunction/operations/__init__.py | 21 + ...collectors_by_resource_group_operations.py | 160 ++++ ...c_collectors_by_subscription_operations.py | 153 ++++ .../_azure_traffic_collectors_operations.py | 582 ++++++++++++ .../_collector_policies_operations.py | 604 +++++++++++++ .../_network_function_operations.py | 143 +++ .../azure/mgmt/networkfunction/py.typed | 1 + .../sdk_packaging.toml | 9 + .../azure-mgmt-networkfunction/setup.py | 78 ++ sdk/networkfunction/ci.yml | 33 + 37 files changed, 4661 insertions(+) create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/CHANGELOG.md create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/LICENSE create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/MANIFEST.in create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/README.md create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/_meta.json create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_azure_traffic_collector.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_configuration.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_metadata.json create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_patch.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_vendor.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_version.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_azure_traffic_collector.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_configuration.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_patch.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_resource_group_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_subscription_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_collector_policies_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_network_function_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_azure_traffic_collector_enums.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_models_py3.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/__init__.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_resource_group_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_subscription_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_collector_policies_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_network_function_operations.py create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/py.typed create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/sdk_packaging.toml create mode 100644 sdk/networkfunction/azure-mgmt-networkfunction/setup.py create mode 100644 sdk/networkfunction/ci.yml diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/CHANGELOG.md b/sdk/networkfunction/azure-mgmt-networkfunction/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/LICENSE b/sdk/networkfunction/azure-mgmt-networkfunction/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/MANIFEST.in b/sdk/networkfunction/azure-mgmt-networkfunction/MANIFEST.in new file mode 100644 index 000000000000..cf182308b926 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/MANIFEST.in @@ -0,0 +1,7 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/networkfunction/py.typed diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/README.md b/sdk/networkfunction/azure-mgmt-networkfunction/README.md new file mode 100644 index 000000000000..dcd874c86b44 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-networkfunction%2FREADME.png) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/_meta.json b/sdk/networkfunction/azure-mgmt-networkfunction/_meta.json new file mode 100644 index 000000000000..11d942723ebf --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "2f47130d8fb333f55596ca9d149fbdceaff6f4be", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/networkfunction/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/networkfunction/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/__init__.py new file mode 100644 index 000000000000..a1bdeec00bdb --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_traffic_collector import AzureTrafficCollector +from ._version import VERSION + +__version__ = VERSION +__all__ = ['AzureTrafficCollector'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_azure_traffic_collector.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_azure_traffic_collector.py new file mode 100644 index 000000000000..e62f035850e5 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_azure_traffic_collector.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import AzureTrafficCollectorConfiguration +from .operations import AzureTrafficCollectorsByResourceGroupOperations, AzureTrafficCollectorsBySubscriptionOperations, AzureTrafficCollectorsOperations, CollectorPoliciesOperations, NetworkFunctionOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class AzureTrafficCollector: + """Azure Traffic Collector service. + + :ivar network_function: NetworkFunctionOperations operations + :vartype network_function: azure.mgmt.networkfunction.operations.NetworkFunctionOperations + :ivar azure_traffic_collectors_by_subscription: AzureTrafficCollectorsBySubscriptionOperations + operations + :vartype azure_traffic_collectors_by_subscription: + azure.mgmt.networkfunction.operations.AzureTrafficCollectorsBySubscriptionOperations + :ivar azure_traffic_collectors_by_resource_group: + AzureTrafficCollectorsByResourceGroupOperations operations + :vartype azure_traffic_collectors_by_resource_group: + azure.mgmt.networkfunction.operations.AzureTrafficCollectorsByResourceGroupOperations + :ivar azure_traffic_collectors: AzureTrafficCollectorsOperations operations + :vartype azure_traffic_collectors: + azure.mgmt.networkfunction.operations.AzureTrafficCollectorsOperations + :ivar collector_policies: CollectorPoliciesOperations operations + :vartype collector_policies: azure.mgmt.networkfunction.operations.CollectorPoliciesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Azure Subscription ID. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureTrafficCollectorConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.network_function = NetworkFunctionOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_traffic_collectors_by_subscription = AzureTrafficCollectorsBySubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_traffic_collectors_by_resource_group = AzureTrafficCollectorsByResourceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_traffic_collectors = AzureTrafficCollectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.collector_policies = CollectorPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureTrafficCollector + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_configuration.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_configuration.py new file mode 100644 index 000000000000..ac2cfc22e804 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AzureTrafficCollectorConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AzureTrafficCollector. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Azure Subscription ID. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureTrafficCollectorConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-networkfunction/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_metadata.json b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_metadata.json new file mode 100644 index 000000000000..21e0ac8e1d7c --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_metadata.json @@ -0,0 +1,106 @@ +{ + "chosen_version": "2022-05-01", + "total_api_version_list": ["2022-05-01"], + "client": { + "name": "AzureTrafficCollector", + "filename": "_azure_traffic_collector", + "description": "Azure Traffic Collector service.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureTrafficCollectorConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureTrafficCollectorConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Azure Subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure Subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "network_function": "NetworkFunctionOperations", + "azure_traffic_collectors_by_subscription": "AzureTrafficCollectorsBySubscriptionOperations", + "azure_traffic_collectors_by_resource_group": "AzureTrafficCollectorsByResourceGroupOperations", + "azure_traffic_collectors": "AzureTrafficCollectorsOperations", + "collector_policies": "CollectorPoliciesOperations" + } +} \ No newline at end of file diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_patch.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_vendor.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_version.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/__init__.py new file mode 100644 index 000000000000..5c2036ef9f6e --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_traffic_collector import AzureTrafficCollector +__all__ = ['AzureTrafficCollector'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_azure_traffic_collector.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_azure_traffic_collector.py new file mode 100644 index 000000000000..818113acd393 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_azure_traffic_collector.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import AzureTrafficCollectorConfiguration +from .operations import AzureTrafficCollectorsByResourceGroupOperations, AzureTrafficCollectorsBySubscriptionOperations, AzureTrafficCollectorsOperations, CollectorPoliciesOperations, NetworkFunctionOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AzureTrafficCollector: + """Azure Traffic Collector service. + + :ivar network_function: NetworkFunctionOperations operations + :vartype network_function: azure.mgmt.networkfunction.aio.operations.NetworkFunctionOperations + :ivar azure_traffic_collectors_by_subscription: AzureTrafficCollectorsBySubscriptionOperations + operations + :vartype azure_traffic_collectors_by_subscription: + azure.mgmt.networkfunction.aio.operations.AzureTrafficCollectorsBySubscriptionOperations + :ivar azure_traffic_collectors_by_resource_group: + AzureTrafficCollectorsByResourceGroupOperations operations + :vartype azure_traffic_collectors_by_resource_group: + azure.mgmt.networkfunction.aio.operations.AzureTrafficCollectorsByResourceGroupOperations + :ivar azure_traffic_collectors: AzureTrafficCollectorsOperations operations + :vartype azure_traffic_collectors: + azure.mgmt.networkfunction.aio.operations.AzureTrafficCollectorsOperations + :ivar collector_policies: CollectorPoliciesOperations operations + :vartype collector_policies: + azure.mgmt.networkfunction.aio.operations.CollectorPoliciesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Azure Subscription ID. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureTrafficCollectorConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.network_function = NetworkFunctionOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_traffic_collectors_by_subscription = AzureTrafficCollectorsBySubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_traffic_collectors_by_resource_group = AzureTrafficCollectorsByResourceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_traffic_collectors = AzureTrafficCollectorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.collector_policies = CollectorPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureTrafficCollector": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_configuration.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_configuration.py new file mode 100644 index 000000000000..67404ec36f3c --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AzureTrafficCollectorConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AzureTrafficCollector. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Azure Subscription ID. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureTrafficCollectorConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-networkfunction/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_patch.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/__init__.py new file mode 100644 index 000000000000..ff37491c638e --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._network_function_operations import NetworkFunctionOperations +from ._azure_traffic_collectors_by_subscription_operations import AzureTrafficCollectorsBySubscriptionOperations +from ._azure_traffic_collectors_by_resource_group_operations import AzureTrafficCollectorsByResourceGroupOperations +from ._azure_traffic_collectors_operations import AzureTrafficCollectorsOperations +from ._collector_policies_operations import CollectorPoliciesOperations + +__all__ = [ + 'NetworkFunctionOperations', + 'AzureTrafficCollectorsBySubscriptionOperations', + 'AzureTrafficCollectorsByResourceGroupOperations', + 'AzureTrafficCollectorsOperations', + 'CollectorPoliciesOperations', +] diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_resource_group_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_resource_group_operations.py new file mode 100644 index 000000000000..6b8c04788551 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_resource_group_operations.py @@ -0,0 +1,123 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_traffic_collectors_by_resource_group_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureTrafficCollectorsByResourceGroupOperations: + """AzureTrafficCollectorsByResourceGroupOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AzureTrafficCollectorListResult"]: + """Return list of Azure Traffic Collectors in a Resource Group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureTrafficCollectorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.AzureTrafficCollectorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollectorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureTrafficCollectorListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_subscription_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_subscription_operations.py new file mode 100644 index 000000000000..a5cf04926c06 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_by_subscription_operations.py @@ -0,0 +1,118 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_traffic_collectors_by_subscription_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureTrafficCollectorsBySubscriptionOperations: + """AzureTrafficCollectorsBySubscriptionOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.AzureTrafficCollectorListResult"]: + """Return list of Azure Traffic Collectors in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureTrafficCollectorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.AzureTrafficCollectorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollectorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureTrafficCollectorListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.NetworkFunction/azureTrafficCollectors"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_operations.py new file mode 100644 index 000000000000..d6c87df11bcb --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_azure_traffic_collectors_operations.py @@ -0,0 +1,419 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_traffic_collectors_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_update_tags_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureTrafficCollectorsOperations: + """AzureTrafficCollectorsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> "_models.AzureTrafficCollector": + """Gets the specified Azure Traffic Collector in a specified resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureTrafficCollector, or the result of cls(response) + :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + collector_policies: Optional[List["_models.CollectorPolicy"]] = None, + virtual_hub: Optional["_models.ResourceReference"] = None, + **kwargs: Any + ) -> "_models.AzureTrafficCollector": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _parameters = _models.AzureTrafficCollector(location=location, tags=tags, collector_policies=collector_policies, virtual_hub=virtual_hub) + _json = self._serialize.body(_parameters, 'AzureTrafficCollector') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + collector_policies: Optional[List["_models.CollectorPolicy"]] = None, + virtual_hub: Optional["_models.ResourceReference"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.AzureTrafficCollector"]: + """Creates or updates a Azure Traffic Collector resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param location: Resource location. Default value is None. + :type location: str + :param tags: Resource tags. Default value is None. + :type tags: dict[str, str] + :param collector_policies: Collector Policies for Azure Traffic Collector. Default value is + None. + :type collector_policies: list[~azure.mgmt.networkfunction.models.CollectorPolicy] + :param virtual_hub: The virtualHub to which the Azure Traffic Collector belongs. Default value + is None. + :type virtual_hub: ~azure.mgmt.networkfunction.models.ResourceReference + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AzureTrafficCollector or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.AzureTrafficCollector] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + location=location, + tags=tags, + collector_policies=collector_policies, + virtual_hub=virtual_hub, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a specified Azure Traffic Collector resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.AzureTrafficCollector": + """Updates the specified Azure Traffic Collector tags. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param parameters: Parameters supplied to update Azure Traffic Collector tags. + :type parameters: ~azure.mgmt.networkfunction.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureTrafficCollector, or the result of cls(response) + :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_collector_policies_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_collector_policies_operations.py new file mode 100644 index 000000000000..95103cf8de4f --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_collector_policies_operations.py @@ -0,0 +1,443 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._collector_policies_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CollectorPoliciesOperations: + """CollectorPoliciesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.CollectorPolicyListResult"]: + """Return list of Collector policies in a Azure Traffic Collector. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CollectorPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.CollectorPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CollectorPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any + ) -> "_models.CollectorPolicy": + """Gets the collector policy in a specified Traffic Collector. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param collector_policy_name: Collector Policy Name. + :type collector_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CollectorPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + ingestion_policy: Optional["_models.IngestionPolicyPropertiesFormat"] = None, + emission_policies: Optional[List["_models.EmissionPoliciesPropertiesFormat"]] = None, + **kwargs: Any + ) -> "_models.CollectorPolicy": + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _parameters = _models.CollectorPolicy(ingestion_policy=ingestion_policy, emission_policies=emission_policies) + _json = self._serialize.body(_parameters, 'CollectorPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + ingestion_policy: Optional["_models.IngestionPolicyPropertiesFormat"] = None, + emission_policies: Optional[List["_models.EmissionPoliciesPropertiesFormat"]] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.CollectorPolicy"]: + """Creates or updates a Collector Policy resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param collector_policy_name: Collector Policy Name. + :type collector_policy_name: str + :param ingestion_policy: Ingestion policies. Default value is None. + :type ingestion_policy: ~azure.mgmt.networkfunction.models.IngestionPolicyPropertiesFormat + :param emission_policies: Emission policies. Default value is None. + :type emission_policies: + list[~azure.mgmt.networkfunction.models.EmissionPoliciesPropertiesFormat] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CollectorPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.networkfunction.models.CollectorPolicy] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicy"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + ingestion_policy=ingestion_policy, + emission_policies=emission_policies, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a specified Collector Policy resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param collector_policy_name: Collector Policy Name. + :type collector_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_network_function_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_network_function_operations.py new file mode 100644 index 000000000000..6733dcf11fb3 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/aio/operations/_network_function_operations.py @@ -0,0 +1,115 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._network_function_operations import build_list_operations_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class NetworkFunctionOperations: + """NetworkFunctionOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists all of the available NetworkFunction Rest API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.networkfunction.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.NetworkFunction/operations"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/__init__.py new file mode 100644 index 000000000000..1eeb3f35ef00 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/__init__.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AzureTrafficCollector +from ._models_py3 import AzureTrafficCollectorListResult +from ._models_py3 import CloudErrorBody +from ._models_py3 import CollectorPolicy +from ._models_py3 import CollectorPolicyListResult +from ._models_py3 import CollectorPolicySystemData +from ._models_py3 import EmissionPoliciesPropertiesFormat +from ._models_py3 import EmissionPolicyDestination +from ._models_py3 import IngestionPolicyPropertiesFormat +from ._models_py3 import IngestionSourcesPropertiesFormat +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import ResourceReference +from ._models_py3 import SystemData +from ._models_py3 import TagsObject +from ._models_py3 import TrackedResource +from ._models_py3 import TrackedResourceSystemData + + +from ._azure_traffic_collector_enums import ( + CreatedByType, + DestinationType, + EmissionType, + IngestionType, + ProvisioningState, + SourceType, +) + +__all__ = [ + 'AzureTrafficCollector', + 'AzureTrafficCollectorListResult', + 'CloudErrorBody', + 'CollectorPolicy', + 'CollectorPolicyListResult', + 'CollectorPolicySystemData', + 'EmissionPoliciesPropertiesFormat', + 'EmissionPolicyDestination', + 'IngestionPolicyPropertiesFormat', + 'IngestionSourcesPropertiesFormat', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'ResourceReference', + 'SystemData', + 'TagsObject', + 'TrackedResource', + 'TrackedResourceSystemData', + 'CreatedByType', + 'DestinationType', + 'EmissionType', + 'IngestionType', + 'ProvisioningState', + 'SourceType', +] diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_azure_traffic_collector_enums.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_azure_traffic_collector_enums.py new file mode 100644 index 000000000000..b4e5e5269261 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_azure_traffic_collector_enums.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DestinationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Emission destination type. + """ + + AZURE_MONITOR = "AzureMonitor" + +class EmissionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Emission format type. + """ + + IPFIX = "IPFIX" + +class IngestionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The ingestion type. + """ + + IPFIX = "IPFIX" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The current provisioning state. + """ + + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + DELETING = "Deleting" + FAILED = "Failed" + +class SourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Ingestion source type. + """ + + RESOURCE = "Resource" diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_models_py3.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_models_py3.py new file mode 100644 index 000000000000..9781b35cd7ce --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/models/_models_py3.py @@ -0,0 +1,835 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +import msrest.serialization + +from ._azure_traffic_collector_enums import * + + +class TrackedResource(msrest.serialization.Model): + """Common resource representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.networkfunction.models.TrackedResourceSystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'TrackedResourceSystemData'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(TrackedResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + + +class AzureTrafficCollector(TrackedResource): + """Azure Traffic Collector resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.networkfunction.models.TrackedResourceSystemData + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar collector_policies: Collector Policies for Azure Traffic Collector. + :vartype collector_policies: list[~azure.mgmt.networkfunction.models.CollectorPolicy] + :ivar virtual_hub: The virtualHub to which the Azure Traffic Collector belongs. + :vartype virtual_hub: ~azure.mgmt.networkfunction.models.ResourceReference + :ivar provisioning_state: The provisioning state of the application rule collection resource. + Possible values include: "Succeeded", "Updating", "Deleting", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.networkfunction.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'etag': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'system_data': {'key': 'systemData', 'type': 'TrackedResourceSystemData'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'collector_policies': {'key': 'properties.collectorPolicies', 'type': '[CollectorPolicy]'}, + 'virtual_hub': {'key': 'properties.virtualHub', 'type': 'ResourceReference'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + collector_policies: Optional[List["CollectorPolicy"]] = None, + virtual_hub: Optional["ResourceReference"] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword collector_policies: Collector Policies for Azure Traffic Collector. + :paramtype collector_policies: list[~azure.mgmt.networkfunction.models.CollectorPolicy] + :keyword virtual_hub: The virtualHub to which the Azure Traffic Collector belongs. + :paramtype virtual_hub: ~azure.mgmt.networkfunction.models.ResourceReference + """ + super(AzureTrafficCollector, self).__init__(location=location, tags=tags, **kwargs) + self.etag = None + self.collector_policies = collector_policies + self.virtual_hub = virtual_hub + self.provisioning_state = None + + +class AzureTrafficCollectorListResult(msrest.serialization.Model): + """Response for the ListTrafficCollectors API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of Traffic Collector resources. + :vartype value: list[~azure.mgmt.networkfunction.models.AzureTrafficCollector] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AzureTrafficCollector]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AzureTrafficCollector"]] = None, + **kwargs + ): + """ + :keyword value: A list of Traffic Collector resources. + :paramtype value: list[~azure.mgmt.networkfunction.models.AzureTrafficCollector] + """ + super(AzureTrafficCollectorListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.networkfunction.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.networkfunction.models.CloudErrorBody] + """ + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class ProxyResource(msrest.serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar type: Azure resource type. + :vartype type: str + :ivar name: Azure resource name. + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + + +class CollectorPolicy(ProxyResource): + """Collector policy resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar type: Azure resource type. + :vartype type: str + :ivar name: Azure resource name. + :vartype name: str + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.networkfunction.models.CollectorPolicySystemData + :ivar ingestion_policy: Ingestion policies. + :vartype ingestion_policy: ~azure.mgmt.networkfunction.models.IngestionPolicyPropertiesFormat + :ivar emission_policies: Emission policies. + :vartype emission_policies: + list[~azure.mgmt.networkfunction.models.EmissionPoliciesPropertiesFormat] + :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", + "Updating", "Deleting", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.networkfunction.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'etag': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'CollectorPolicySystemData'}, + 'ingestion_policy': {'key': 'properties.ingestionPolicy', 'type': 'IngestionPolicyPropertiesFormat'}, + 'emission_policies': {'key': 'properties.emissionPolicies', 'type': '[EmissionPoliciesPropertiesFormat]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + ingestion_policy: Optional["IngestionPolicyPropertiesFormat"] = None, + emission_policies: Optional[List["EmissionPoliciesPropertiesFormat"]] = None, + **kwargs + ): + """ + :keyword ingestion_policy: Ingestion policies. + :paramtype ingestion_policy: ~azure.mgmt.networkfunction.models.IngestionPolicyPropertiesFormat + :keyword emission_policies: Emission policies. + :paramtype emission_policies: + list[~azure.mgmt.networkfunction.models.EmissionPoliciesPropertiesFormat] + """ + super(CollectorPolicy, self).__init__(**kwargs) + self.etag = None + self.system_data = None + self.ingestion_policy = ingestion_policy + self.emission_policies = emission_policies + self.provisioning_state = None + + +class CollectorPolicyListResult(msrest.serialization.Model): + """Response for the ListCollectorPolicies API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of collection policies. + :vartype value: list[~azure.mgmt.networkfunction.models.CollectorPolicy] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CollectorPolicy]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CollectorPolicy"]] = None, + **kwargs + ): + """ + :keyword value: A list of collection policies. + :paramtype value: list[~azure.mgmt.networkfunction.models.CollectorPolicy] + """ + super(CollectorPolicyListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + + +class CollectorPolicySystemData(SystemData): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + """ + super(CollectorPolicySystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, **kwargs) + + +class EmissionPoliciesPropertiesFormat(msrest.serialization.Model): + """Emission policy properties. + + :ivar emission_type: Emission format type. Possible values include: "IPFIX". + :vartype emission_type: str or ~azure.mgmt.networkfunction.models.EmissionType + :ivar emission_destinations: Emission policy destinations. + :vartype emission_destinations: + list[~azure.mgmt.networkfunction.models.EmissionPolicyDestination] + """ + + _attribute_map = { + 'emission_type': {'key': 'emissionType', 'type': 'str'}, + 'emission_destinations': {'key': 'emissionDestinations', 'type': '[EmissionPolicyDestination]'}, + } + + def __init__( + self, + *, + emission_type: Optional[Union[str, "EmissionType"]] = None, + emission_destinations: Optional[List["EmissionPolicyDestination"]] = None, + **kwargs + ): + """ + :keyword emission_type: Emission format type. Possible values include: "IPFIX". + :paramtype emission_type: str or ~azure.mgmt.networkfunction.models.EmissionType + :keyword emission_destinations: Emission policy destinations. + :paramtype emission_destinations: + list[~azure.mgmt.networkfunction.models.EmissionPolicyDestination] + """ + super(EmissionPoliciesPropertiesFormat, self).__init__(**kwargs) + self.emission_type = emission_type + self.emission_destinations = emission_destinations + + +class EmissionPolicyDestination(msrest.serialization.Model): + """Emission policy destination properties. + + :ivar destination_type: Emission destination type. Possible values include: "AzureMonitor". + :vartype destination_type: str or ~azure.mgmt.networkfunction.models.DestinationType + """ + + _attribute_map = { + 'destination_type': {'key': 'destinationType', 'type': 'str'}, + } + + def __init__( + self, + *, + destination_type: Optional[Union[str, "DestinationType"]] = None, + **kwargs + ): + """ + :keyword destination_type: Emission destination type. Possible values include: "AzureMonitor". + :paramtype destination_type: str or ~azure.mgmt.networkfunction.models.DestinationType + """ + super(EmissionPolicyDestination, self).__init__(**kwargs) + self.destination_type = destination_type + + +class IngestionPolicyPropertiesFormat(msrest.serialization.Model): + """Ingestion Policy properties. + + :ivar ingestion_type: The ingestion type. Possible values include: "IPFIX". + :vartype ingestion_type: str or ~azure.mgmt.networkfunction.models.IngestionType + :ivar ingestion_sources: Ingestion Sources. + :vartype ingestion_sources: + list[~azure.mgmt.networkfunction.models.IngestionSourcesPropertiesFormat] + """ + + _attribute_map = { + 'ingestion_type': {'key': 'ingestionType', 'type': 'str'}, + 'ingestion_sources': {'key': 'ingestionSources', 'type': '[IngestionSourcesPropertiesFormat]'}, + } + + def __init__( + self, + *, + ingestion_type: Optional[Union[str, "IngestionType"]] = None, + ingestion_sources: Optional[List["IngestionSourcesPropertiesFormat"]] = None, + **kwargs + ): + """ + :keyword ingestion_type: The ingestion type. Possible values include: "IPFIX". + :paramtype ingestion_type: str or ~azure.mgmt.networkfunction.models.IngestionType + :keyword ingestion_sources: Ingestion Sources. + :paramtype ingestion_sources: + list[~azure.mgmt.networkfunction.models.IngestionSourcesPropertiesFormat] + """ + super(IngestionPolicyPropertiesFormat, self).__init__(**kwargs) + self.ingestion_type = ingestion_type + self.ingestion_sources = ingestion_sources + + +class IngestionSourcesPropertiesFormat(msrest.serialization.Model): + """Ingestion policy properties. + + :ivar source_type: Ingestion source type. Possible values include: "Resource". + :vartype source_type: str or ~azure.mgmt.networkfunction.models.SourceType + :ivar resource_id: Resource ID. + :vartype resource_id: str + """ + + _attribute_map = { + 'source_type': {'key': 'sourceType', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + source_type: Optional[Union[str, "SourceType"]] = None, + resource_id: Optional[str] = None, + **kwargs + ): + """ + :keyword source_type: Ingestion source type. Possible values include: "Resource". + :paramtype source_type: str or ~azure.mgmt.networkfunction.models.SourceType + :keyword resource_id: Resource ID. + :paramtype resource_id: str + """ + super(IngestionSourcesPropertiesFormat, self).__init__(**kwargs) + self.source_type = source_type + self.resource_id = resource_id + + +class Operation(msrest.serialization.Model): + """Azure Traffic Collector REST API operation definition. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.networkfunction.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = False, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.networkfunction.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ + super(Operation, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + + +class OperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Service provider: Microsoft NetworkFunction. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft NetworkFunction. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed etc. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Azure Traffic Collector operations. It contains a list of operations and a URL link to get the next set of results. + + :ivar value: List of operations supported by the Azure Traffic Collector resource provider. + :vartype value: list[~azure.mgmt.networkfunction.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: List of operations supported by the Azure Traffic Collector resource provider. + :paramtype value: list[~azure.mgmt.networkfunction.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceReference(msrest.serialization.Model): + """Resource reference properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ResourceReference, self).__init__(**kwargs) + self.id = None + + +class TagsObject(msrest.serialization.Model): + """Tags object for patch operations. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(TagsObject, self).__init__(**kwargs) + self.tags = tags + + +class TrackedResourceSystemData(SystemData): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.networkfunction.models.CreatedByType + """ + super(TrackedResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, **kwargs) diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/__init__.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/__init__.py new file mode 100644 index 000000000000..ff37491c638e --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._network_function_operations import NetworkFunctionOperations +from ._azure_traffic_collectors_by_subscription_operations import AzureTrafficCollectorsBySubscriptionOperations +from ._azure_traffic_collectors_by_resource_group_operations import AzureTrafficCollectorsByResourceGroupOperations +from ._azure_traffic_collectors_operations import AzureTrafficCollectorsOperations +from ._collector_policies_operations import CollectorPoliciesOperations + +__all__ = [ + 'NetworkFunctionOperations', + 'AzureTrafficCollectorsBySubscriptionOperations', + 'AzureTrafficCollectorsByResourceGroupOperations', + 'AzureTrafficCollectorsOperations', + 'CollectorPoliciesOperations', +] diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_resource_group_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_resource_group_operations.py new file mode 100644 index 000000000000..115a47ef73da --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_resource_group_operations.py @@ -0,0 +1,160 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AzureTrafficCollectorsByResourceGroupOperations(object): + """AzureTrafficCollectorsByResourceGroupOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AzureTrafficCollectorListResult"]: + """Return list of Azure Traffic Collectors in a Resource Group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureTrafficCollectorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.networkfunction.models.AzureTrafficCollectorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollectorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureTrafficCollectorListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_subscription_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_subscription_operations.py new file mode 100644 index 000000000000..404c4649806e --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_by_subscription_operations.py @@ -0,0 +1,153 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.NetworkFunction/azureTrafficCollectors") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AzureTrafficCollectorsBySubscriptionOperations(object): + """AzureTrafficCollectorsBySubscriptionOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.AzureTrafficCollectorListResult"]: + """Return list of Azure Traffic Collectors in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureTrafficCollectorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.networkfunction.models.AzureTrafficCollectorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollectorListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureTrafficCollectorListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.NetworkFunction/azureTrafficCollectors"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_operations.py new file mode 100644 index 000000000000..81e16b21e02d --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_azure_traffic_collectors_operations.py @@ -0,0 +1,582 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class AzureTrafficCollectorsOperations(object): + """AzureTrafficCollectorsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> "_models.AzureTrafficCollector": + """Gets the specified Azure Traffic Collector in a specified resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureTrafficCollector, or the result of cls(response) + :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + collector_policies: Optional[List["_models.CollectorPolicy"]] = None, + virtual_hub: Optional["_models.ResourceReference"] = None, + **kwargs: Any + ) -> "_models.AzureTrafficCollector": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _parameters = _models.AzureTrafficCollector(location=location, tags=tags, collector_policies=collector_policies, virtual_hub=virtual_hub) + _json = self._serialize.body(_parameters, 'AzureTrafficCollector') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + collector_policies: Optional[List["_models.CollectorPolicy"]] = None, + virtual_hub: Optional["_models.ResourceReference"] = None, + **kwargs: Any + ) -> LROPoller["_models.AzureTrafficCollector"]: + """Creates or updates a Azure Traffic Collector resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param location: Resource location. Default value is None. + :type location: str + :param tags: Resource tags. Default value is None. + :type tags: dict[str, str] + :param collector_policies: Collector Policies for Azure Traffic Collector. Default value is + None. + :type collector_policies: list[~azure.mgmt.networkfunction.models.CollectorPolicy] + :param virtual_hub: The virtualHub to which the Azure Traffic Collector belongs. Default value + is None. + :type virtual_hub: ~azure.mgmt.networkfunction.models.ResourceReference + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AzureTrafficCollector or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.networkfunction.models.AzureTrafficCollector] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + location=location, + tags=tags, + collector_policies=collector_policies, + virtual_hub=virtual_hub, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a specified Azure Traffic Collector resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + parameters: "_models.TagsObject", + **kwargs: Any + ) -> "_models.AzureTrafficCollector": + """Updates the specified Azure Traffic Collector tags. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param parameters: Parameters supplied to update Azure Traffic Collector tags. + :type parameters: ~azure.mgmt.networkfunction.models.TagsObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureTrafficCollector, or the result of cls(response) + :rtype: ~azure.mgmt.networkfunction.models.AzureTrafficCollector + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureTrafficCollector"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AzureTrafficCollector', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}"} # type: ignore + diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_collector_policies_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_collector_policies_operations.py new file mode 100644 index 000000000000..2028967d063f --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_collector_policies_operations.py @@ -0,0 +1,604 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + "collectorPolicyName": _SERIALIZER.url("collector_policy_name", collector_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + "collectorPolicyName": _SERIALIZER.url("collector_policy_name", collector_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + subscription_id: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "azureTrafficCollectorName": _SERIALIZER.url("azure_traffic_collector_name", azure_traffic_collector_name, 'str'), + "collectorPolicyName": _SERIALIZER.url("collector_policy_name", collector_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class CollectorPoliciesOperations(object): + """CollectorPoliciesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + **kwargs: Any + ) -> Iterable["_models.CollectorPolicyListResult"]: + """Return list of Collector policies in a Azure Traffic Collector. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CollectorPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.networkfunction.models.CollectorPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CollectorPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any + ) -> "_models.CollectorPolicy": + """Gets the collector policy in a specified Traffic Collector. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param collector_policy_name: Collector Policy Name. + :type collector_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CollectorPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.networkfunction.models.CollectorPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + ingestion_policy: Optional["_models.IngestionPolicyPropertiesFormat"] = None, + emission_policies: Optional[List["_models.EmissionPoliciesPropertiesFormat"]] = None, + **kwargs: Any + ) -> "_models.CollectorPolicy": + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _parameters = _models.CollectorPolicy(ingestion_policy=ingestion_policy, emission_policies=emission_policies) + _json = self._serialize.body(_parameters, 'CollectorPolicy') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + ingestion_policy: Optional["_models.IngestionPolicyPropertiesFormat"] = None, + emission_policies: Optional[List["_models.EmissionPoliciesPropertiesFormat"]] = None, + **kwargs: Any + ) -> LROPoller["_models.CollectorPolicy"]: + """Creates or updates a Collector Policy resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param collector_policy_name: Collector Policy Name. + :type collector_policy_name: str + :param ingestion_policy: Ingestion policies. Default value is None. + :type ingestion_policy: ~azure.mgmt.networkfunction.models.IngestionPolicyPropertiesFormat + :param emission_policies: Emission policies. Default value is None. + :type emission_policies: + list[~azure.mgmt.networkfunction.models.EmissionPoliciesPropertiesFormat] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CollectorPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.networkfunction.models.CollectorPolicy] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CollectorPolicy"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + ingestion_policy=ingestion_policy, + emission_policies=emission_policies, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('CollectorPolicy', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + azure_traffic_collector_name: str, + collector_policy_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a specified Collector Policy resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param azure_traffic_collector_name: Azure Traffic Collector name. + :type azure_traffic_collector_name: str + :param collector_policy_name: Collector Policy Name. + :type collector_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + azure_traffic_collector_name=azure_traffic_collector_name, + collector_policy_name=collector_policy_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkFunction/azureTrafficCollectors/{azureTrafficCollectorName}/collectorPolicies/{collectorPolicyName}"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_network_function_operations.py b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_network_function_operations.py new file mode 100644 index 000000000000..b1ab143bbdfb --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/operations/_network_function_operations.py @@ -0,0 +1,143 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_operations_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.NetworkFunction/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class NetworkFunctionOperations(object): + """NetworkFunctionOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.networkfunction.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_operations( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists all of the available NetworkFunction Rest API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.networkfunction.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_operations_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': "/providers/Microsoft.NetworkFunction/operations"} # type: ignore diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/py.typed b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/azure/mgmt/networkfunction/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/sdk_packaging.toml b/sdk/networkfunction/azure-mgmt-networkfunction/sdk_packaging.toml new file mode 100644 index 000000000000..c73a0d2ec3e9 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-networkfunction" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/networkfunction/azure-mgmt-networkfunction/setup.py b/sdk/networkfunction/azure-mgmt-networkfunction/setup.py new file mode 100644 index 000000000000..d44dcfd927b3 --- /dev/null +++ b/sdk/networkfunction/azure-mgmt-networkfunction/setup.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-networkfunction" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/networkfunction/ci.yml b/sdk/networkfunction/ci.yml new file mode 100644 index 000000000000..f31a4ae7c5f6 --- /dev/null +++ b/sdk/networkfunction/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/networkfunction/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/networkfunction/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: networkfunction + Artifacts: + - name: azure-mgmt-networkfunction + safeName: azuremgmtnetworkfunction