diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/CHANGELOG.md b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/LICENSE b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/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/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/MANIFEST.in b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/MANIFEST.in new file mode 100644 index 000000000000..898194624431 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/MANIFEST.in @@ -0,0 +1,8 @@ +include _meta.json +recursive-include tests *.py *.json +recursive-include samples *.py *.md +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/paloaltonetworksngfw/py.typed diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/README.md b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/README.md new file mode 100644 index 000000000000..d81092ced492 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/README.md @@ -0,0 +1,64 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.7+. +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_ + +## Getting started + +### Prerequisites + +- Python 3.7+ is required to use this package. +- [Azure subscription](https://azure.microsoft.com/free/) + +### Install the package + +```bash +pip install azure-mgmt-paloaltonetworksngfw +pip install azure-identity +``` + +### Authentication + +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` for Azure client secret. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, client can be authenticated by following code: + +```python +from azure.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworksngfw import +import os + +sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") +client = (credential=DefaultAzureCredential(), subscription_id=sub_id) +``` + +## Examples + +Code samples for this package can be found at: +- [Search MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +## Troubleshooting + +## Next steps + +## 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-paloaltonetworksngfw%2FREADME.png) diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/_meta.json b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/_meta.json new file mode 100644 index 000000000000..e87f6c9f0133 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "2bd9b148ec4232e878641ccbb2bdde671e575add", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", + "use": [ + "@autorest/python@6.4.6", + "@autorest/modelerfour@4.24.3" + ], + "autorest_command": "autorest specification/paloaltonetworks/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.4.6 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "readme": "specification/paloaltonetworks/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/__init__.py new file mode 100644 index 000000000000..d11a9719d50b --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/__init__.py @@ -0,0 +1,26 @@ +# 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 ._palo_alto_networks_ngfw_mgmt_client import PaloAltoNetworksNgfwMgmtClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "PaloAltoNetworksNgfwMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_configuration.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_configuration.py new file mode 100644 index 000000000000..5ed11705ad5d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_configuration.py @@ -0,0 +1,66 @@ +# 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 PaloAltoNetworksNgfwMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for PaloAltoNetworksNgfwMgmtClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-29-preview". 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(PaloAltoNetworksNgfwMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2022-08-29-preview") + + 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-paloaltonetworks/{}".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.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/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_palo_alto_networks_ngfw_mgmt_client.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_palo_alto_networks_ngfw_mgmt_client.py new file mode 100644 index 000000000000..a1ae544873e7 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_palo_alto_networks_ngfw_mgmt_client.py @@ -0,0 +1,164 @@ +# 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 azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from ._configuration import PaloAltoNetworksNgfwMgmtClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + CertificateObjectGlobalRulestackOperations, + CertificateObjectLocalRulestackOperations, + FirewallsOperations, + FqdnListGlobalRulestackOperations, + FqdnListLocalRulestackOperations, + GlobalRulestackOperations, + LocalRulesOperations, + LocalRulestacksOperations, + Operations, + PostRulesOperations, + PreRulesOperations, + PrefixListGlobalRulestackOperations, + PrefixListLocalRulestackOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class PaloAltoNetworksNgfwMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """PaloAltoNetworksNgfwMgmtClient. + + :ivar global_rulestack: GlobalRulestackOperations operations + :vartype global_rulestack: azure.mgmt.paloaltonetworks.operations.GlobalRulestackOperations + :ivar certificate_object_global_rulestack: CertificateObjectGlobalRulestackOperations + operations + :vartype certificate_object_global_rulestack: + azure.mgmt.paloaltonetworks.operations.CertificateObjectGlobalRulestackOperations + :ivar fqdn_list_global_rulestack: FqdnListGlobalRulestackOperations operations + :vartype fqdn_list_global_rulestack: + azure.mgmt.paloaltonetworks.operations.FqdnListGlobalRulestackOperations + :ivar post_rules: PostRulesOperations operations + :vartype post_rules: azure.mgmt.paloaltonetworks.operations.PostRulesOperations + :ivar prefix_list_global_rulestack: PrefixListGlobalRulestackOperations operations + :vartype prefix_list_global_rulestack: + azure.mgmt.paloaltonetworks.operations.PrefixListGlobalRulestackOperations + :ivar pre_rules: PreRulesOperations operations + :vartype pre_rules: azure.mgmt.paloaltonetworks.operations.PreRulesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.paloaltonetworks.operations.Operations + :ivar firewalls: FirewallsOperations operations + :vartype firewalls: azure.mgmt.paloaltonetworks.operations.FirewallsOperations + :ivar local_rulestacks: LocalRulestacksOperations operations + :vartype local_rulestacks: azure.mgmt.paloaltonetworks.operations.LocalRulestacksOperations + :ivar certificate_object_local_rulestack: CertificateObjectLocalRulestackOperations operations + :vartype certificate_object_local_rulestack: + azure.mgmt.paloaltonetworks.operations.CertificateObjectLocalRulestackOperations + :ivar fqdn_list_local_rulestack: FqdnListLocalRulestackOperations operations + :vartype fqdn_list_local_rulestack: + azure.mgmt.paloaltonetworks.operations.FqdnListLocalRulestackOperations + :ivar local_rules: LocalRulesOperations operations + :vartype local_rules: azure.mgmt.paloaltonetworks.operations.LocalRulesOperations + :ivar prefix_list_local_rulestack: PrefixListLocalRulestackOperations operations + :vartype prefix_list_local_rulestack: + azure.mgmt.paloaltonetworks.operations.PrefixListLocalRulestackOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :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-08-29-preview". 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 = PaloAltoNetworksNgfwMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client: ARMPipelineClient = 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.global_rulestack = GlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificate_object_global_rulestack = CertificateObjectGlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.fqdn_list_global_rulestack = FqdnListGlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.post_rules = PostRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.prefix_list_global_rulestack = PrefixListGlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.pre_rules = PreRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.firewalls = FirewallsOperations(self._client, self._config, self._serialize, self._deserialize) + self.local_rulestacks = LocalRulestacksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificate_object_local_rulestack = CertificateObjectLocalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.fqdn_list_local_rulestack = FqdnListLocalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_rules = LocalRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.prefix_list_local_rulestack = PrefixListLocalRulestackOperations( + 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/dpcodegen/python/send_request + + :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) -> None: + self._client.close() + + def __enter__(self) -> "PaloAltoNetworksNgfwMgmtClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_patch.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_serialization.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_serialization.py new file mode 100644 index 000000000000..842ae727fbbc --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_serialization.py @@ -0,0 +1,1996 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str + unicode_str = str + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Dict[str, Any] = {} + for k in kwargs: + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to azure from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is AzureCoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_vendor.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# 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 List, cast + +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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_version.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/_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/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/__init__.py new file mode 100644 index 000000000000..dbb1355bf320 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/__init__.py @@ -0,0 +1,23 @@ +# 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 ._palo_alto_networks_ngfw_mgmt_client import PaloAltoNetworksNgfwMgmtClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "PaloAltoNetworksNgfwMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_configuration.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_configuration.py new file mode 100644 index 000000000000..5a530bc5b491 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_configuration.py @@ -0,0 +1,66 @@ +# 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 PaloAltoNetworksNgfwMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for PaloAltoNetworksNgfwMgmtClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-29-preview". 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(PaloAltoNetworksNgfwMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2022-08-29-preview") + + 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-paloaltonetworks/{}".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/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_palo_alto_networks_ngfw_mgmt_client.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_palo_alto_networks_ngfw_mgmt_client.py new file mode 100644 index 000000000000..ce27fee92c1d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_palo_alto_networks_ngfw_mgmt_client.py @@ -0,0 +1,164 @@ +# 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 azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import PaloAltoNetworksNgfwMgmtClientConfiguration +from .operations import ( + CertificateObjectGlobalRulestackOperations, + CertificateObjectLocalRulestackOperations, + FirewallsOperations, + FqdnListGlobalRulestackOperations, + FqdnListLocalRulestackOperations, + GlobalRulestackOperations, + LocalRulesOperations, + LocalRulestacksOperations, + Operations, + PostRulesOperations, + PreRulesOperations, + PrefixListGlobalRulestackOperations, + PrefixListLocalRulestackOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class PaloAltoNetworksNgfwMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """PaloAltoNetworksNgfwMgmtClient. + + :ivar global_rulestack: GlobalRulestackOperations operations + :vartype global_rulestack: azure.mgmt.paloaltonetworks.aio.operations.GlobalRulestackOperations + :ivar certificate_object_global_rulestack: CertificateObjectGlobalRulestackOperations + operations + :vartype certificate_object_global_rulestack: + azure.mgmt.paloaltonetworks.aio.operations.CertificateObjectGlobalRulestackOperations + :ivar fqdn_list_global_rulestack: FqdnListGlobalRulestackOperations operations + :vartype fqdn_list_global_rulestack: + azure.mgmt.paloaltonetworks.aio.operations.FqdnListGlobalRulestackOperations + :ivar post_rules: PostRulesOperations operations + :vartype post_rules: azure.mgmt.paloaltonetworks.aio.operations.PostRulesOperations + :ivar prefix_list_global_rulestack: PrefixListGlobalRulestackOperations operations + :vartype prefix_list_global_rulestack: + azure.mgmt.paloaltonetworks.aio.operations.PrefixListGlobalRulestackOperations + :ivar pre_rules: PreRulesOperations operations + :vartype pre_rules: azure.mgmt.paloaltonetworks.aio.operations.PreRulesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.paloaltonetworks.aio.operations.Operations + :ivar firewalls: FirewallsOperations operations + :vartype firewalls: azure.mgmt.paloaltonetworks.aio.operations.FirewallsOperations + :ivar local_rulestacks: LocalRulestacksOperations operations + :vartype local_rulestacks: azure.mgmt.paloaltonetworks.aio.operations.LocalRulestacksOperations + :ivar certificate_object_local_rulestack: CertificateObjectLocalRulestackOperations operations + :vartype certificate_object_local_rulestack: + azure.mgmt.paloaltonetworks.aio.operations.CertificateObjectLocalRulestackOperations + :ivar fqdn_list_local_rulestack: FqdnListLocalRulestackOperations operations + :vartype fqdn_list_local_rulestack: + azure.mgmt.paloaltonetworks.aio.operations.FqdnListLocalRulestackOperations + :ivar local_rules: LocalRulesOperations operations + :vartype local_rules: azure.mgmt.paloaltonetworks.aio.operations.LocalRulesOperations + :ivar prefix_list_local_rulestack: PrefixListLocalRulestackOperations operations + :vartype prefix_list_local_rulestack: + azure.mgmt.paloaltonetworks.aio.operations.PrefixListLocalRulestackOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :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-08-29-preview". 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 = PaloAltoNetworksNgfwMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client: AsyncARMPipelineClient = 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.global_rulestack = GlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificate_object_global_rulestack = CertificateObjectGlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.fqdn_list_global_rulestack = FqdnListGlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.post_rules = PostRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.prefix_list_global_rulestack = PrefixListGlobalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.pre_rules = PreRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.firewalls = FirewallsOperations(self._client, self._config, self._serialize, self._deserialize) + self.local_rulestacks = LocalRulestacksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificate_object_local_rulestack = CertificateObjectLocalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.fqdn_list_local_rulestack = FqdnListLocalRulestackOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_rules = LocalRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.prefix_list_local_rulestack = PrefixListLocalRulestackOperations( + 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/dpcodegen/python/send_request + + :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) -> "PaloAltoNetworksNgfwMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_patch.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/__init__.py new file mode 100644 index 000000000000..05124829938e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/__init__.py @@ -0,0 +1,43 @@ +# 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 ._global_rulestack_operations import GlobalRulestackOperations +from ._certificate_object_global_rulestack_operations import CertificateObjectGlobalRulestackOperations +from ._fqdn_list_global_rulestack_operations import FqdnListGlobalRulestackOperations +from ._post_rules_operations import PostRulesOperations +from ._prefix_list_global_rulestack_operations import PrefixListGlobalRulestackOperations +from ._pre_rules_operations import PreRulesOperations +from ._operations import Operations +from ._firewalls_operations import FirewallsOperations +from ._local_rulestacks_operations import LocalRulestacksOperations +from ._certificate_object_local_rulestack_operations import CertificateObjectLocalRulestackOperations +from ._fqdn_list_local_rulestack_operations import FqdnListLocalRulestackOperations +from ._local_rules_operations import LocalRulesOperations +from ._prefix_list_local_rulestack_operations import PrefixListLocalRulestackOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "GlobalRulestackOperations", + "CertificateObjectGlobalRulestackOperations", + "FqdnListGlobalRulestackOperations", + "PostRulesOperations", + "PrefixListGlobalRulestackOperations", + "PreRulesOperations", + "Operations", + "FirewallsOperations", + "LocalRulestacksOperations", + "CertificateObjectLocalRulestackOperations", + "FqdnListLocalRulestackOperations", + "LocalRulesOperations", + "PrefixListLocalRulestackOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_certificate_object_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_certificate_object_global_rulestack_operations.py new file mode 100644 index 000000000000..679b5e2ac34d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_certificate_object_global_rulestack_operations.py @@ -0,0 +1,553 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._certificate_object_global_rulestack_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificateObjectGlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`certificate_object_global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, global_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateObjectGlobalRulestackResource"]: + """List CertificateObjectGlobalRulestackResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateObjectGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("CertificateObjectGlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates"} + + @distributed_trace_async + async def get( + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.CertificateObjectGlobalRulestackResource: + """Get a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateObjectGlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + async def _create_or_update_initial( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectGlobalRulestackResource, IO], + **kwargs: Any + ) -> _models.CertificateObjectGlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "CertificateObjectGlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: _models.CertificateObjectGlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateObjectGlobalRulestackResource]: + """Create a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 + CertificateObjectGlobalRulestackResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateObjectGlobalRulestackResource]: + """Create a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 + CertificateObjectGlobalRulestackResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectGlobalRulestackResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateObjectGlobalRulestackResource]: + """Create a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Is either a + CertificateObjectGlobalRulestackResource type or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 + CertificateObjectGlobalRulestackResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + @distributed_trace_async + async def begin_delete(self, global_rulestack_name: str, name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_certificate_object_local_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_certificate_object_local_rulestack_operations.py new file mode 100644 index 000000000000..51c52f0585ac --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_certificate_object_local_rulestack_operations.py @@ -0,0 +1,589 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._certificate_object_local_rulestack_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_local_rulestacks_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificateObjectLocalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`certificate_object_local_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CertificateObjectLocalRulestackResource"]: + """List CertificateObjectLocalRulestackResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateObjectLocalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectLocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("CertificateObjectLocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.CertificateObjectLocalRulestackResource: + """Get a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateObjectLocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectLocalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectLocalRulestackResource, IO], + **kwargs: Any + ) -> _models.CertificateObjectLocalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectLocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "CertificateObjectLocalRulestackResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: _models.CertificateObjectLocalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateObjectLocalRulestackResource]: + """Create a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 + CertificateObjectLocalRulestackResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateObjectLocalRulestackResource]: + """Create a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 + CertificateObjectLocalRulestackResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectLocalRulestackResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CertificateObjectLocalRulestackResource]: + """Create a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Is either a + CertificateObjectLocalRulestackResource type or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 + CertificateObjectLocalRulestackResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectLocalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_firewalls_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_firewalls_operations.py new file mode 100644 index 000000000000..9e3378628add --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_firewalls_operations.py @@ -0,0 +1,1123 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._firewalls_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_global_rulestack_request, + build_get_log_profile_request, + build_get_request, + build_get_support_info_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_save_log_profile_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FirewallsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`firewalls` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.FirewallResource"]: + """List FirewallResource resources by subscription ID. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FirewallResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FirewallResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/firewalls" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FirewallResource"]: + """List FirewallResource resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 FirewallResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FirewallResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, firewall_name: str, **kwargs: Any) -> _models.FirewallResource: + """Get a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + async def _create_or_update_initial( + self, resource_group_name: str, firewall_name: str, resource: Union[_models.FirewallResource, IO], **kwargs: Any + ) -> _models.FirewallResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "FirewallResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + firewall_name: str, + resource: _models.FirewallResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallResource]: + """Create a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 FirewallResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + firewall_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallResource]: + """Create a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 FirewallResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, firewall_name: str, resource: Union[_models.FirewallResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallResource]: + """Create a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param resource: Resource create parameters. Is either a FirewallResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FirewallResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 FirewallResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("FirewallResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @overload + async def update( + self, + resource_group_name: str, + firewall_name: str, + properties: _models.FirewallResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallResource: + """Update a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.FirewallResourceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + firewall_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallResource: + """Update a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + firewall_name: str, + properties: Union[_models.FirewallResourceUpdate, IO], + **kwargs: Any + ) -> _models.FirewallResource: + """Update a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param properties: The resource properties to be updated. Is either a FirewallResourceUpdate + type or a IO type. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.FirewallResourceUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "FirewallResourceUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, firewall_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, firewall_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + firewall_name=firewall_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @distributed_trace_async + async def get_global_rulestack( + self, resource_group_name: str, firewall_name: str, **kwargs: Any + ) -> _models.GlobalRulestackInfo: + """Get Global Rulestack associated with the Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackInfo or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalRulestackInfo] = kwargs.pop("cls", None) + + request = build_get_global_rulestack_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_global_rulestack.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GlobalRulestackInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_global_rulestack.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getGlobalRulestack" + } + + @distributed_trace_async + async def get_log_profile(self, resource_group_name: str, firewall_name: str, **kwargs: Any) -> _models.LogSettings: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogSettings or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LogSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LogSettings] = kwargs.pop("cls", None) + + request = build_get_log_profile_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_log_profile.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_log_profile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getLogProfile" + } + + @distributed_trace_async + async def get_support_info( + self, resource_group_name: str, firewall_name: str, email: Optional[str] = None, **kwargs: Any + ) -> _models.SupportInfo: + """support info for firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param email: email address on behalf of which this API called. Default value is None. + :type email: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportInfo or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SupportInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SupportInfo] = kwargs.pop("cls", None) + + request = build_get_support_info_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + email=email, + api_version=api_version, + template_url=self.get_support_info.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_support_info.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getSupportInfo" + } + + @overload + async def save_log_profile( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + firewall_name: str, + log_settings: Optional[_models.LogSettings] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param log_settings: Default value is None. + :type log_settings: ~azure.mgmt.paloaltonetworks.models.LogSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def save_log_profile( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + firewall_name: str, + log_settings: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param log_settings: Default value is None. + :type log_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def save_log_profile( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + firewall_name: str, + log_settings: Optional[Union[_models.LogSettings, IO]] = None, + **kwargs: Any + ) -> None: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param log_settings: Is either a LogSettings type or a IO type. Default value is None. + :type log_settings: ~azure.mgmt.paloaltonetworks.models.LogSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(log_settings, (IO, bytes)): + _content = log_settings + else: + if log_settings is not None: + _json = self._serialize.body(log_settings, "LogSettings") + else: + _json = None + + request = build_save_log_profile_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.save_log_profile.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + save_log_profile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/saveLogProfile" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_fqdn_list_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_fqdn_list_global_rulestack_operations.py new file mode 100644 index 000000000000..fe4d6c6a17d8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_fqdn_list_global_rulestack_operations.py @@ -0,0 +1,552 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._fqdn_list_global_rulestack_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FqdnListGlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`fqdn_list_global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, global_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FqdnListGlobalRulestackResource"]: + """List FqdnListGlobalRulestackResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FqdnListGlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListGlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FqdnListGlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists"} + + @distributed_trace_async + async def get( + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.FqdnListGlobalRulestackResource: + """Get a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FqdnListGlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListGlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + async def _create_or_update_initial( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListGlobalRulestackResource, IO], + **kwargs: Any + ) -> _models.FqdnListGlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListGlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "FqdnListGlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: _models.FqdnListGlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FqdnListGlobalRulestackResource]: + """Create a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListGlobalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FqdnListGlobalRulestackResource]: + """Create a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListGlobalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListGlobalRulestackResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FqdnListGlobalRulestackResource]: + """Create a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Is either a FqdnListGlobalRulestackResource type + or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 FqdnListGlobalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListGlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + @distributed_trace_async + async def begin_delete(self, global_rulestack_name: str, name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_fqdn_list_local_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_fqdn_list_local_rulestack_operations.py new file mode 100644 index 000000000000..6c198eca6248 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_fqdn_list_local_rulestack_operations.py @@ -0,0 +1,588 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._fqdn_list_local_rulestack_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_local_rulestacks_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FqdnListLocalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`fqdn_list_local_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FqdnListLocalRulestackResource"]: + """List FqdnListLocalRulestackResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FqdnListLocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListLocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FqdnListLocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.FqdnListLocalRulestackResource: + """Get a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FqdnListLocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListLocalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListLocalRulestackResource, IO], + **kwargs: Any + ) -> _models.FqdnListLocalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListLocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "FqdnListLocalRulestackResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: _models.FqdnListLocalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FqdnListLocalRulestackResource]: + """Create a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListLocalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FqdnListLocalRulestackResource]: + """Create a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListLocalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListLocalRulestackResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FqdnListLocalRulestackResource]: + """Create a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Is either a FqdnListLocalRulestackResource type or + a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 FqdnListLocalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListLocalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_global_rulestack_operations.py new file mode 100644 index 000000000000..009fa12f17b8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_global_rulestack_operations.py @@ -0,0 +1,1275 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._global_rulestack_operations import ( + build_commit_request, + build_create_or_update_request, + build_delete_request, + build_get_change_log_request, + build_get_request, + build_list_advanced_security_objects_request, + build_list_app_ids_request, + build_list_countries_request, + build_list_firewalls_request, + build_list_predefined_url_categories_request, + build_list_request, + build_list_security_services_request, + build_revert_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.GlobalRulestackResource"]: + """List GlobalRulestackResource resources by Tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("GlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks"} + + @distributed_trace_async + async def get(self, global_rulestack_name: str, **kwargs: Any) -> _models.GlobalRulestackResource: + """Get a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + async def _create_or_update_initial( + self, global_rulestack_name: str, resource: Union[_models.GlobalRulestackResource, IO], **kwargs: Any + ) -> _models.GlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "GlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}" + } + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + resource: _models.GlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalRulestackResource]: + """Create a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 GlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, global_rulestack_name: str, resource: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalRulestackResource]: + """Create a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 GlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, global_rulestack_name: str, resource: Union[_models.GlobalRulestackResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalRulestackResource]: + """Create a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param resource: Resource create parameters. Is either a GlobalRulestackResource type or a IO + type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 GlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}" + } + + @overload + async def update( + self, + global_rulestack_name: str, + properties: _models.GlobalRulestackResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GlobalRulestackResource: + """Update a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResourceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, global_rulestack_name: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.GlobalRulestackResource: + """Update a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, global_rulestack_name: str, properties: Union[_models.GlobalRulestackResourceUpdate, IO], **kwargs: Any + ) -> _models.GlobalRulestackResource: + """Update a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param properties: The resource properties to be updated. Is either a + GlobalRulestackResourceUpdate type or a IO type. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResourceUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "GlobalRulestackResourceUpdate") + + request = build_update_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + @distributed_trace_async + async def begin_delete(self, global_rulestack_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + async def _commit_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_commit_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self._commit_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _commit_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/commit" + } + + @distributed_trace_async + async def begin_commit(self, global_rulestack_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Commit rulestack configuration. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._commit_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_commit.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/commit" + } + + @distributed_trace_async + async def get_change_log(self, global_rulestack_name: str, **kwargs: Any) -> _models.Changelog: + """Get changelog. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Changelog or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.Changelog + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Changelog] = kwargs.pop("cls", None) + + request = build_get_change_log_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.get_change_log.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Changelog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_change_log.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/getChangeLog" + } + + @distributed_trace_async + async def list_advanced_security_objects( + self, + global_rulestack_name: str, + type: Union[str, _models.AdvSecurityObjectTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.AdvSecurityObjectListResponse: + """Get the list of advanced security objects. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param type: Known values are: "urlCustom" and "feeds". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvSecurityObjectListResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvSecurityObjectListResponse] = kwargs.pop("cls", None) + + request = build_list_advanced_security_objects_request( + global_rulestack_name=global_rulestack_name, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_advanced_security_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvSecurityObjectListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_advanced_security_objects.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listAdvancedSecurityObjects" + } + + @distributed_trace_async + async def list_app_ids( + self, + global_rulestack_name: str, + app_id_version: Optional[str] = None, + app_prefix: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.ListAppIdResponse: + """List of AppIds for GlobalRulestack ApiVersion. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param app_id_version: Default value is None. + :type app_id_version: str + :param app_prefix: Default value is None. + :type app_prefix: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListAppIdResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListAppIdResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListAppIdResponse] = kwargs.pop("cls", None) + + request = build_list_app_ids_request( + global_rulestack_name=global_rulestack_name, + app_id_version=app_id_version, + app_prefix=app_prefix, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_app_ids.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAppIdResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_app_ids.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listAppIds" + } + + @distributed_trace_async + async def list_countries( + self, global_rulestack_name: str, skip: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> _models.CountriesResponse: + """List of countries for Rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CountriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CountriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CountriesResponse] = kwargs.pop("cls", None) + + request = build_list_countries_request( + global_rulestack_name=global_rulestack_name, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_countries.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CountriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_countries.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listCountries" + } + + @distributed_trace_async + async def list_firewalls(self, global_rulestack_name: str, **kwargs: Any) -> _models.ListFirewallsResponse: + """List of Firewalls associated with Rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListFirewallsResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListFirewallsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListFirewallsResponse] = kwargs.pop("cls", None) + + request = build_list_firewalls_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list_firewalls.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListFirewallsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_firewalls.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listFirewalls" + } + + @distributed_trace_async + async def list_predefined_url_categories( + self, global_rulestack_name: str, skip: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> _models.PredefinedUrlCategoriesResponse: + """List predefined URL categories for rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PredefinedUrlCategoriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PredefinedUrlCategoriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PredefinedUrlCategoriesResponse] = kwargs.pop("cls", None) + + request = build_list_predefined_url_categories_request( + global_rulestack_name=global_rulestack_name, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_predefined_url_categories.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredefinedUrlCategoriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_predefined_url_categories.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listPredefinedUrlCategories" + } + + @distributed_trace_async + async def list_security_services( + self, + global_rulestack_name: str, + type: Union[str, _models.SecurityServicesTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.SecurityServicesResponse: + """List the security services for rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param type: Known values are: "antiSpyware", "antiVirus", "ipsVulnerability", "urlFiltering", + "fileBlocking", and "dnsSubscription". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.SecurityServicesTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityServicesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SecurityServicesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecurityServicesResponse] = kwargs.pop("cls", None) + + request = build_list_security_services_request( + global_rulestack_name=global_rulestack_name, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_security_services.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityServicesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_security_services.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listSecurityServices" + } + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, **kwargs: Any + ) -> None: + """Revert rulestack configuration. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revert_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.revert.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revert.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/revert"} diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_local_rules_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_local_rules_operations.py new file mode 100644 index 000000000000..05cf89d87225 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_local_rules_operations.py @@ -0,0 +1,814 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._local_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_counters_request, + build_get_request, + build_list_by_local_rulestacks_request, + build_refresh_counters_request, + build_reset_counters_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LocalRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`local_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LocalRulesResource"]: + """List LocalRulesResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocalRulesResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulesResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("LocalRulesResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, local_rulestack_name: str, priority: str, **kwargs: Any + ) -> _models.LocalRulesResource: + """Get a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulesResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulesResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulesResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: Union[_models.LocalRulesResource, IO], + **kwargs: Any + ) -> _models.LocalRulesResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulesResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "LocalRulesResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: _models.LocalRulesResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LocalRulesResource]: + """Create a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulesResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LocalRulesResource]: + """Create a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: Union[_models.LocalRulesResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LocalRulesResource]: + """Create a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Is either a LocalRulesResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulesResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 LocalRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulesResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, priority: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, priority: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + @distributed_trace_async + async def get_counters( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + firewall_name: Optional[str] = None, + **kwargs: Any + ) -> _models.RuleCounter: + """Get counters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounter or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounter] = kwargs.pop("cls", None) + + request = build_get_counters_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.get_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounter", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_counters.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/getCounters" + } + + @distributed_trace_async + async def refresh_counters( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + firewall_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """Refresh counters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_counters_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.refresh_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + refresh_counters.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/refreshCounters" + } + + @distributed_trace_async + async def reset_counters( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + firewall_name: Optional[str] = None, + **kwargs: Any + ) -> _models.RuleCounterReset: + """Reset counters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounterReset or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounterReset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounterReset] = kwargs.pop("cls", None) + + request = build_reset_counters_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.reset_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounterReset", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + reset_counters.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/resetCounters" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_local_rulestacks_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_local_rulestacks_operations.py new file mode 100644 index 000000000000..751f88897acb --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_local_rulestacks_operations.py @@ -0,0 +1,1578 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._local_rulestacks_operations import ( + build_commit_request, + build_create_or_update_request, + build_delete_request, + build_get_change_log_request, + build_get_request, + build_get_support_info_request, + build_list_advanced_security_objects_request, + build_list_app_ids_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_countries_request, + build_list_firewalls_request, + build_list_predefined_url_categories_request, + build_list_security_services_request, + build_revert_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LocalRulestacksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`local_rulestacks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.LocalRulestackResource"]: + """List LocalRulestackResource resources by subscription ID. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("LocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LocalRulestackResource"]: + """List LocalRulestackResource resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("LocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> _models.LocalRulestackResource: + """Get a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: Union[_models.LocalRulestackResource, IO], + **kwargs: Any + ) -> _models.LocalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "LocalRulestackResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: _models.LocalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LocalRulestackResource]: + """Create a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulestackResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LocalRulestackResource]: + """Create a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulestackResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: Union[_models.LocalRulestackResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LocalRulestackResource]: + """Create a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param resource: Resource create parameters. Is either a LocalRulestackResource type or a IO + type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 LocalRulestackResource or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + @overload + async def update( + self, + resource_group_name: str, + local_rulestack_name: str, + properties: _models.LocalRulestackResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalRulestackResource: + """Update a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResourceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + local_rulestack_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalRulestackResource: + """Update a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + local_rulestack_name: str, + properties: Union[_models.LocalRulestackResourceUpdate, IO], + **kwargs: Any + ) -> _models.LocalRulestackResource: + """Update a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param properties: The resource properties to be updated. Is either a + LocalRulestackResourceUpdate type or a IO type. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResourceUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalRulestackResourceUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + async def _commit_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_commit_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._commit_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _commit_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/commit" + } + + @distributed_trace_async + async def begin_commit( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Commit rulestack configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._commit_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_commit.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/commit" + } + + @distributed_trace_async + async def get_change_log( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> _models.Changelog: + """Get changelog. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Changelog or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.Changelog + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Changelog] = kwargs.pop("cls", None) + + request = build_get_change_log_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_change_log.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Changelog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_change_log.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getChangeLog" + } + + @distributed_trace_async + async def get_support_info( + self, resource_group_name: str, local_rulestack_name: str, email: Optional[str] = None, **kwargs: Any + ) -> _models.SupportInfo: + """support info for rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param email: email address on behalf of which this API called. Default value is None. + :type email: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportInfo or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SupportInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SupportInfo] = kwargs.pop("cls", None) + + request = build_get_support_info_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + email=email, + api_version=api_version, + template_url=self.get_support_info.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_support_info.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getSupportInfo" + } + + @distributed_trace_async + async def list_advanced_security_objects( + self, + resource_group_name: str, + local_rulestack_name: str, + type: Union[str, _models.AdvSecurityObjectTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.AdvSecurityObjectListResponse: + """Get the list of advanced security objects. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param type: Known values are: "urlCustom" and "feeds". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvSecurityObjectListResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvSecurityObjectListResponse] = kwargs.pop("cls", None) + + request = build_list_advanced_security_objects_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_advanced_security_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvSecurityObjectListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_advanced_security_objects.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAdvancedSecurityObjects" + } + + @distributed_trace_async + async def list_app_ids( + self, + resource_group_name: str, + local_rulestack_name: str, + app_id_version: Optional[str] = None, + app_prefix: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.ListAppIdResponse: + """List of AppIds for LocalRulestack ApiVersion. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param app_id_version: Default value is None. + :type app_id_version: str + :param app_prefix: Default value is None. + :type app_prefix: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListAppIdResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListAppIdResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListAppIdResponse] = kwargs.pop("cls", None) + + request = build_list_app_ids_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + app_id_version=app_id_version, + app_prefix=app_prefix, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_app_ids.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAppIdResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_app_ids.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAppIds" + } + + @distributed_trace_async + async def list_countries( + self, + resource_group_name: str, + local_rulestack_name: str, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.CountriesResponse: + """List of countries for Rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CountriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CountriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CountriesResponse] = kwargs.pop("cls", None) + + request = build_list_countries_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_countries.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CountriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_countries.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listCountries" + } + + @distributed_trace_async + async def list_firewalls( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> _models.ListFirewallsResponse: + """List of Firewalls associated with Rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListFirewallsResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListFirewallsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListFirewallsResponse] = kwargs.pop("cls", None) + + request = build_list_firewalls_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_firewalls.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListFirewallsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_firewalls.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listFirewalls" + } + + @distributed_trace_async + async def list_predefined_url_categories( + self, + resource_group_name: str, + local_rulestack_name: str, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.PredefinedUrlCategoriesResponse: + """List predefined URL categories for rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PredefinedUrlCategoriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PredefinedUrlCategoriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PredefinedUrlCategoriesResponse] = kwargs.pop("cls", None) + + request = build_list_predefined_url_categories_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_predefined_url_categories.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredefinedUrlCategoriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_predefined_url_categories.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listPredefinedUrlCategories" + } + + @distributed_trace_async + async def list_security_services( + self, + resource_group_name: str, + local_rulestack_name: str, + type: Union[str, _models.SecurityServicesTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.SecurityServicesResponse: + """List the security services for rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param type: Known values are: "antiSpyware", "antiVirus", "ipsVulnerability", "urlFiltering", + "fileBlocking", and "dnsSubscription". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.SecurityServicesTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityServicesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SecurityServicesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecurityServicesResponse] = kwargs.pop("cls", None) + + request = build_list_security_services_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_security_services.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityServicesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_security_services.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listSecurityServices" + } + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> None: + """Revert rulestack configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revert_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/revert" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_operations.py new file mode 100644 index 000000000000..123739056979 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_operations.py @@ -0,0 +1,133 @@ +# 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 +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """List the operations for the provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/operations"} diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_patch.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_post_rules_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_post_rules_operations.py new file mode 100644 index 000000000000..fa045e0976f3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_post_rules_operations.py @@ -0,0 +1,736 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._post_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_counters_request, + build_get_request, + build_list_request, + build_refresh_counters_request, + build_reset_counters_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PostRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`post_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, global_rulestack_name: str, **kwargs: Any) -> AsyncIterable["_models.PostRulesResource"]: + """List PostRulesResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PostRulesResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PostRulesResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PostRulesResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules"} + + @distributed_trace_async + async def get(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> _models.PostRulesResource: + """Get a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PostRulesResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PostRulesResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PostRulesResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PostRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + async def _create_or_update_initial( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PostRulesResource, IO], **kwargs: Any + ) -> _models.PostRulesResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PostRulesResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PostRulesResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PostRulesResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PostRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: _models.PostRulesResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PostRulesResource]: + """Create a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PostRulesResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PostRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PostRulesResource]: + """Create a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PostRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PostRulesResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.PostRulesResource]: + """Create a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Is either a PostRulesResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PostRulesResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PostRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PostRulesResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + priority=priority, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PostRulesResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + @distributed_trace_async + async def begin_delete(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + @distributed_trace_async + async def get_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounter: + """Get counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounter or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounter] = kwargs.pop("cls", None) + + request = build_get_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.get_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounter", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/getCounters" + } + + @distributed_trace_async + async def refresh_counters( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> None: + """Refresh counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.refresh_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + refresh_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/refreshCounters" + } + + @distributed_trace_async + async def reset_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounterReset: + """Reset counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounterReset or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounterReset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounterReset] = kwargs.pop("cls", None) + + request = build_reset_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.reset_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounterReset", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + reset_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/resetCounters" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_pre_rules_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_pre_rules_operations.py new file mode 100644 index 000000000000..48548a72cada --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_pre_rules_operations.py @@ -0,0 +1,736 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._pre_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_counters_request, + build_get_request, + build_list_request, + build_refresh_counters_request, + build_reset_counters_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PreRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`pre_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, global_rulestack_name: str, **kwargs: Any) -> AsyncIterable["_models.PreRulesResource"]: + """List PreRulesResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PreRulesResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PreRulesResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PreRulesResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules"} + + @distributed_trace_async + async def get(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> _models.PreRulesResource: + """Get a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PreRulesResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PreRulesResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PreRulesResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PreRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + async def _create_or_update_initial( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PreRulesResource, IO], **kwargs: Any + ) -> _models.PreRulesResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreRulesResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PreRulesResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PreRulesResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PreRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: _models.PreRulesResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreRulesResource]: + """Create a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PreRulesResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PreRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PreRulesResource]: + """Create a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PreRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PreRulesResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.PreRulesResource]: + """Create a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Is either a PreRulesResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PreRulesResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PreRulesResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreRulesResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + priority=priority, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PreRulesResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + @distributed_trace_async + async def begin_delete(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + @distributed_trace_async + async def get_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounter: + """Get counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounter or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounter] = kwargs.pop("cls", None) + + request = build_get_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.get_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounter", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/getCounters" + } + + @distributed_trace_async + async def refresh_counters( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> None: + """Refresh counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.refresh_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + refresh_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/refreshCounters" + } + + @distributed_trace_async + async def reset_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounterReset: + """Reset counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounterReset or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounterReset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounterReset] = kwargs.pop("cls", None) + + request = build_reset_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.reset_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounterReset", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + reset_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/resetCounters" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_prefix_list_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_prefix_list_global_rulestack_operations.py new file mode 100644 index 000000000000..ff32a5e118c3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_prefix_list_global_rulestack_operations.py @@ -0,0 +1,552 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._prefix_list_global_rulestack_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrefixListGlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`prefix_list_global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, global_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrefixListGlobalRulestackResource"]: + """List PrefixListGlobalRulestackResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrefixListGlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListGlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PrefixListGlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists"} + + @distributed_trace_async + async def get( + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.PrefixListGlobalRulestackResource: + """Get a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrefixListGlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListGlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + async def _create_or_update_initial( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListGlobalRulestackResource, IO], + **kwargs: Any + ) -> _models.PrefixListGlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListGlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PrefixListGlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: _models.PrefixListGlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrefixListGlobalRulestackResource]: + """Create a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListGlobalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrefixListGlobalRulestackResource]: + """Create a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListGlobalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListGlobalRulestackResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrefixListGlobalRulestackResource]: + """Create a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Is either a PrefixListGlobalRulestackResource type + or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PrefixListGlobalRulestackResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListGlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + @distributed_trace_async + async def begin_delete(self, global_rulestack_name: str, name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_prefix_list_local_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_prefix_list_local_rulestack_operations.py new file mode 100644 index 000000000000..318d0cbea135 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/aio/operations/_prefix_list_local_rulestack_operations.py @@ -0,0 +1,587 @@ +# 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, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +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._prefix_list_local_rulestack_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_local_rulestacks_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrefixListLocalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.aio.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`prefix_list_local_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrefixListResource"]: + """List PrefixListResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrefixListResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PrefixListResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.PrefixListResource: + """Get a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrefixListResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PrefixListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrefixListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListResource, IO], + **kwargs: Any + ) -> _models.PrefixListResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PrefixListResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrefixListResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrefixListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: _models.PrefixListResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrefixListResource]: + """Create a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrefixListResource]: + """Create a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrefixListResource]: + """Create a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Is either a PrefixListResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PrefixListResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrefixListResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/__init__.py new file mode 100644 index 000000000000..b7baa9381843 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/__init__.py @@ -0,0 +1,229 @@ +# 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 AdvSecurityObjectListResponse +from ._models_py3 import AdvSecurityObjectModel +from ._models_py3 import AppSeenData +from ._models_py3 import AppSeenInfo +from ._models_py3 import ApplicationInsights +from ._models_py3 import AzureResourceManagerManagedIdentityProperties +from ._models_py3 import AzureResourceManagerUserAssignedIdentity +from ._models_py3 import Category +from ._models_py3 import CertificateObjectGlobalRulestackResource +from ._models_py3 import CertificateObjectGlobalRulestackResourceListResult +from ._models_py3 import CertificateObjectLocalRulestackResource +from ._models_py3 import CertificateObjectLocalRulestackResourceListResult +from ._models_py3 import Changelog +from ._models_py3 import CountriesResponse +from ._models_py3 import Country +from ._models_py3 import DNSSettings +from ._models_py3 import DestinationAddr +from ._models_py3 import EndpointConfiguration +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import EventHub +from ._models_py3 import FirewallResource +from ._models_py3 import FirewallResourceListResult +from ._models_py3 import FirewallResourceUpdate +from ._models_py3 import FirewallResourceUpdateProperties +from ._models_py3 import FqdnListGlobalRulestackResource +from ._models_py3 import FqdnListGlobalRulestackResourceListResult +from ._models_py3 import FqdnListLocalRulestackResource +from ._models_py3 import FqdnListLocalRulestackResourceListResult +from ._models_py3 import FrontendSetting +from ._models_py3 import GlobalRulestackInfo +from ._models_py3 import GlobalRulestackResource +from ._models_py3 import GlobalRulestackResourceListResult +from ._models_py3 import GlobalRulestackResourceUpdate +from ._models_py3 import GlobalRulestackResourceUpdateProperties +from ._models_py3 import IPAddress +from ._models_py3 import IPAddressSpace +from ._models_py3 import ListAppIdResponse +from ._models_py3 import ListFirewallsResponse +from ._models_py3 import LocalRulesResource +from ._models_py3 import LocalRulesResourceListResult +from ._models_py3 import LocalRulestackResource +from ._models_py3 import LocalRulestackResourceListResult +from ._models_py3 import LocalRulestackResourceUpdate +from ._models_py3 import LocalRulestackResourceUpdateProperties +from ._models_py3 import LogDestination +from ._models_py3 import LogSettings +from ._models_py3 import MarketplaceDetails +from ._models_py3 import MonitorLog +from ._models_py3 import NameDescriptionObject +from ._models_py3 import NetworkProfile +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PanoramaConfig +from ._models_py3 import PlanData +from ._models_py3 import PostRulesResource +from ._models_py3 import PostRulesResourceListResult +from ._models_py3 import PreRulesResource +from ._models_py3 import PreRulesResourceListResult +from ._models_py3 import PredefinedUrlCategoriesResponse +from ._models_py3 import PredefinedUrlCategory +from ._models_py3 import PrefixListGlobalRulestackResource +from ._models_py3 import PrefixListGlobalRulestackResourceListResult +from ._models_py3 import PrefixListResource +from ._models_py3 import PrefixListResourceListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import RuleCounter +from ._models_py3 import RuleCounterReset +from ._models_py3 import RulestackDetails +from ._models_py3 import SecurityServices +from ._models_py3 import SecurityServicesResponse +from ._models_py3 import SecurityServicesTypeList +from ._models_py3 import SourceAddr +from ._models_py3 import StorageAccount +from ._models_py3 import SupportInfo +from ._models_py3 import SystemData +from ._models_py3 import TagInfo +from ._models_py3 import TrackedResource +from ._models_py3 import VnetConfiguration +from ._models_py3 import VwanConfiguration + +from ._palo_alto_networks_ngfw_mgmt_client_enums import ActionEnum +from ._palo_alto_networks_ngfw_mgmt_client_enums import ActionType +from ._palo_alto_networks_ngfw_mgmt_client_enums import AdvSecurityObjectTypeEnum +from ._palo_alto_networks_ngfw_mgmt_client_enums import BillingCycle +from ._palo_alto_networks_ngfw_mgmt_client_enums import BooleanEnum +from ._palo_alto_networks_ngfw_mgmt_client_enums import CreatedByType +from ._palo_alto_networks_ngfw_mgmt_client_enums import DNSProxy +from ._palo_alto_networks_ngfw_mgmt_client_enums import DecryptionRuleTypeEnum +from ._palo_alto_networks_ngfw_mgmt_client_enums import DefaultMode +from ._palo_alto_networks_ngfw_mgmt_client_enums import EgressNat +from ._palo_alto_networks_ngfw_mgmt_client_enums import EnabledDNSType +from ._palo_alto_networks_ngfw_mgmt_client_enums import LogOption +from ._palo_alto_networks_ngfw_mgmt_client_enums import LogType +from ._palo_alto_networks_ngfw_mgmt_client_enums import ManagedIdentityType +from ._palo_alto_networks_ngfw_mgmt_client_enums import MarketplaceSubscriptionStatus +from ._palo_alto_networks_ngfw_mgmt_client_enums import NetworkType +from ._palo_alto_networks_ngfw_mgmt_client_enums import Origin +from ._palo_alto_networks_ngfw_mgmt_client_enums import ProtocolType +from ._palo_alto_networks_ngfw_mgmt_client_enums import ProvisioningState +from ._palo_alto_networks_ngfw_mgmt_client_enums import ScopeType +from ._palo_alto_networks_ngfw_mgmt_client_enums import SecurityServicesTypeEnum +from ._palo_alto_networks_ngfw_mgmt_client_enums import StateEnum +from ._palo_alto_networks_ngfw_mgmt_client_enums import UsageType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AdvSecurityObjectListResponse", + "AdvSecurityObjectModel", + "AppSeenData", + "AppSeenInfo", + "ApplicationInsights", + "AzureResourceManagerManagedIdentityProperties", + "AzureResourceManagerUserAssignedIdentity", + "Category", + "CertificateObjectGlobalRulestackResource", + "CertificateObjectGlobalRulestackResourceListResult", + "CertificateObjectLocalRulestackResource", + "CertificateObjectLocalRulestackResourceListResult", + "Changelog", + "CountriesResponse", + "Country", + "DNSSettings", + "DestinationAddr", + "EndpointConfiguration", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "EventHub", + "FirewallResource", + "FirewallResourceListResult", + "FirewallResourceUpdate", + "FirewallResourceUpdateProperties", + "FqdnListGlobalRulestackResource", + "FqdnListGlobalRulestackResourceListResult", + "FqdnListLocalRulestackResource", + "FqdnListLocalRulestackResourceListResult", + "FrontendSetting", + "GlobalRulestackInfo", + "GlobalRulestackResource", + "GlobalRulestackResourceListResult", + "GlobalRulestackResourceUpdate", + "GlobalRulestackResourceUpdateProperties", + "IPAddress", + "IPAddressSpace", + "ListAppIdResponse", + "ListFirewallsResponse", + "LocalRulesResource", + "LocalRulesResourceListResult", + "LocalRulestackResource", + "LocalRulestackResourceListResult", + "LocalRulestackResourceUpdate", + "LocalRulestackResourceUpdateProperties", + "LogDestination", + "LogSettings", + "MarketplaceDetails", + "MonitorLog", + "NameDescriptionObject", + "NetworkProfile", + "Operation", + "OperationDisplay", + "OperationListResult", + "PanoramaConfig", + "PlanData", + "PostRulesResource", + "PostRulesResourceListResult", + "PreRulesResource", + "PreRulesResourceListResult", + "PredefinedUrlCategoriesResponse", + "PredefinedUrlCategory", + "PrefixListGlobalRulestackResource", + "PrefixListGlobalRulestackResourceListResult", + "PrefixListResource", + "PrefixListResourceListResult", + "ProxyResource", + "Resource", + "RuleCounter", + "RuleCounterReset", + "RulestackDetails", + "SecurityServices", + "SecurityServicesResponse", + "SecurityServicesTypeList", + "SourceAddr", + "StorageAccount", + "SupportInfo", + "SystemData", + "TagInfo", + "TrackedResource", + "VnetConfiguration", + "VwanConfiguration", + "ActionEnum", + "ActionType", + "AdvSecurityObjectTypeEnum", + "BillingCycle", + "BooleanEnum", + "CreatedByType", + "DNSProxy", + "DecryptionRuleTypeEnum", + "DefaultMode", + "EgressNat", + "EnabledDNSType", + "LogOption", + "LogType", + "ManagedIdentityType", + "MarketplaceSubscriptionStatus", + "NetworkType", + "Origin", + "ProtocolType", + "ProvisioningState", + "ScopeType", + "SecurityServicesTypeEnum", + "StateEnum", + "UsageType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_models_py3.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_models_py3.py new file mode 100644 index 000000000000..e4a2556db798 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_models_py3.py @@ -0,0 +1,4687 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class AdvSecurityObjectListResponse(_serialization.Model): + """advanced security object. + + All required parameters must be populated in order to send to Azure. + + :ivar value: response value. Required. + :vartype value: ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectModel + :ivar next_link: next link. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "AdvSecurityObjectModel"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: "_models.AdvSecurityObjectModel", next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: response value. Required. + :paramtype value: ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectModel + :keyword next_link: next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AdvSecurityObjectModel(_serialization.Model): + """List of custom and predefined url category. + + All required parameters must be populated in order to send to Azure. + + :ivar type: type of object. + :vartype type: str + :ivar entry: URL entry. Required. + :vartype entry: list[~azure.mgmt.paloaltonetworks.models.NameDescriptionObject] + """ + + _validation = { + "entry": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "entry": {"key": "entry", "type": "[NameDescriptionObject]"}, + } + + def __init__( + self, *, entry: List["_models.NameDescriptionObject"], type: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword type: type of object. + :paramtype type: str + :keyword entry: URL entry. Required. + :paramtype entry: list[~azure.mgmt.paloaltonetworks.models.NameDescriptionObject] + """ + super().__init__(**kwargs) + self.type = type + self.entry = entry + + +class ApplicationInsights(_serialization.Model): + """Application Insights key. + + :ivar id: Resource id for Application Insights. + :vartype id: str + :ivar key: Application Insights key. + :vartype key: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "key": {"key": "key", "type": "str"}, + } + + def __init__( + self, *, id: Optional[str] = None, key: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: + """ + :keyword id: Resource id for Application Insights. + :paramtype id: str + :keyword key: Application Insights key. + :paramtype key: str + """ + super().__init__(**kwargs) + self.id = id + self.key = key + + +class AppSeenData(_serialization.Model): + """Data Type for App Seen. + + All required parameters must be populated in order to send to Azure. + + :ivar count: number of rows. Required. + :vartype count: int + :ivar app_seen_list: array of appSeen. Required. + :vartype app_seen_list: list[~azure.mgmt.paloaltonetworks.models.AppSeenInfo] + """ + + _validation = { + "count": {"required": True}, + "app_seen_list": {"required": True}, + } + + _attribute_map = { + "count": {"key": "count", "type": "int"}, + "app_seen_list": {"key": "appSeenList", "type": "[AppSeenInfo]"}, + } + + def __init__(self, *, count: int, app_seen_list: List["_models.AppSeenInfo"], **kwargs: Any) -> None: + """ + :keyword count: number of rows. Required. + :paramtype count: int + :keyword app_seen_list: array of appSeen. Required. + :paramtype app_seen_list: list[~azure.mgmt.paloaltonetworks.models.AppSeenInfo] + """ + super().__init__(**kwargs) + self.count = count + self.app_seen_list = app_seen_list + + +class AppSeenInfo(_serialization.Model): + """Definition for App Seen. + + All required parameters must be populated in order to send to Azure. + + :ivar title: title. Required. + :vartype title: str + :ivar category: category. Required. + :vartype category: str + :ivar sub_category: subCategory. Required. + :vartype sub_category: str + :ivar risk: risk. Required. + :vartype risk: str + :ivar tag: tag. Required. + :vartype tag: str + :ivar technology: technology. Required. + :vartype technology: str + :ivar standard_ports: standardPorts. Required. + :vartype standard_ports: str + """ + + _validation = { + "title": {"required": True}, + "category": {"required": True}, + "sub_category": {"required": True}, + "risk": {"required": True}, + "tag": {"required": True}, + "technology": {"required": True}, + "standard_ports": {"required": True}, + } + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "sub_category": {"key": "subCategory", "type": "str"}, + "risk": {"key": "risk", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "technology": {"key": "technology", "type": "str"}, + "standard_ports": {"key": "standardPorts", "type": "str"}, + } + + def __init__( + self, + *, + title: str, + category: str, + sub_category: str, + risk: str, + tag: str, + technology: str, + standard_ports: str, + **kwargs: Any + ) -> None: + """ + :keyword title: title. Required. + :paramtype title: str + :keyword category: category. Required. + :paramtype category: str + :keyword sub_category: subCategory. Required. + :paramtype sub_category: str + :keyword risk: risk. Required. + :paramtype risk: str + :keyword tag: tag. Required. + :paramtype tag: str + :keyword technology: technology. Required. + :paramtype technology: str + :keyword standard_ports: standardPorts. Required. + :paramtype standard_ports: str + """ + super().__init__(**kwargs) + self.title = title + self.category = category + self.sub_category = sub_category + self.risk = risk + self.tag = tag + self.technology = technology + self.standard_ports = standard_ports + + +class AzureResourceManagerManagedIdentityProperties(_serialization.Model): + """The properties of the managed service identities assigned to this resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar tenant_id: The Active Directory tenant id of the principal. + :vartype tenant_id: str + :ivar principal_id: The active directory identifier of this principal. + :vartype principal_id: str + :ivar type: The type of managed identity assigned to this resource. Required. Known values are: + "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.paloaltonetworks.models.ManagedIdentityType + :ivar user_assigned_identities: The identities assigned to this resource by the user. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerUserAssignedIdentity] + """ + + _validation = { + "tenant_id": {"readonly": True}, + "principal_id": {"readonly": True}, + "type": {"required": True}, + } + + _attribute_map = { + "tenant_id": {"key": "tenantId", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{AzureResourceManagerUserAssignedIdentity}", + }, + } + + def __init__( + self, + *, + type: Union[str, "_models.ManagedIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.AzureResourceManagerUserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of managed identity assigned to this resource. Required. Known values + are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.paloaltonetworks.models.ManagedIdentityType + :keyword user_assigned_identities: The identities assigned to this resource by the user. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerUserAssignedIdentity] + """ + super().__init__(**kwargs) + self.tenant_id = None + self.principal_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class AzureResourceManagerUserAssignedIdentity(_serialization.Model): + """A managed identity assigned by the user. + + :ivar client_id: The active directory client identifier for this principal. + :vartype client_id: str + :ivar principal_id: The active directory identifier for this principal. + :vartype principal_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, principal_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: The active directory client identifier for this principal. + :paramtype client_id: str + :keyword principal_id: The active directory identifier for this principal. + :paramtype principal_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + self.principal_id = principal_id + + +class Category(_serialization.Model): + """URL/EDL to match. + + All required parameters must be populated in order to send to Azure. + + :ivar url_custom: custom URL. Required. + :vartype url_custom: list[str] + :ivar feeds: feed list. Required. + :vartype feeds: list[str] + """ + + _validation = { + "url_custom": {"required": True}, + "feeds": {"required": True}, + } + + _attribute_map = { + "url_custom": {"key": "urlCustom", "type": "[str]"}, + "feeds": {"key": "feeds", "type": "[str]"}, + } + + def __init__(self, *, url_custom: List[str], feeds: List[str], **kwargs: Any) -> None: + """ + :keyword url_custom: custom URL. Required. + :paramtype url_custom: list[str] + :keyword feeds: feed list. Required. + :paramtype feeds: list[str] + """ + super().__init__(**kwargs) + self.url_custom = url_custom + self.feeds = feeds + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + """ + + _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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + """ + + _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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class CertificateObjectGlobalRulestackResource(ProxyResource): + """GlobalRulestack Certificate Object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar certificate_signer_resource_id: Resource Id of certificate signer, to be populated only + when certificateSelfSigned is false. + :vartype certificate_signer_resource_id: str + :ivar certificate_self_signed: use certificate self signed. Required. Known values are: "TRUE" + and "FALSE". + :vartype certificate_self_signed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar audit_comment: comment for this object. + :vartype audit_comment: str + :ivar description: user description for this object. + :vartype description: str + :ivar etag: read only string representing last create or update. + :vartype etag: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "certificate_self_signed": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "certificate_signer_resource_id": {"key": "properties.certificateSignerResourceId", "type": "str"}, + "certificate_self_signed": {"key": "properties.certificateSelfSigned", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "etag": {"key": "properties.etag", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + certificate_self_signed: Union[str, "_models.BooleanEnum"], + certificate_signer_resource_id: Optional[str] = None, + audit_comment: Optional[str] = None, + description: Optional[str] = None, + etag: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword certificate_signer_resource_id: Resource Id of certificate signer, to be populated + only when certificateSelfSigned is false. + :paramtype certificate_signer_resource_id: str + :keyword certificate_self_signed: use certificate self signed. Required. Known values are: + "TRUE" and "FALSE". + :paramtype certificate_self_signed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword audit_comment: comment for this object. + :paramtype audit_comment: str + :keyword description: user description for this object. + :paramtype description: str + :keyword etag: read only string representing last create or update. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.certificate_signer_resource_id = certificate_signer_resource_id + self.certificate_self_signed = certificate_self_signed + self.audit_comment = audit_comment + self.description = description + self.etag = etag + self.provisioning_state = None + + +class CertificateObjectGlobalRulestackResourceListResult(_serialization.Model): + """The response of a CertificateObjectGlobalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: + list[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateObjectGlobalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: List["_models.CertificateObjectGlobalRulestackResource"], + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: + list[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CertificateObjectLocalRulestackResource(ProxyResource): + """LocalRulestack Certificate Object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar certificate_signer_resource_id: Resource Id of certificate signer, to be populated only + when certificateSelfSigned is false. + :vartype certificate_signer_resource_id: str + :ivar certificate_self_signed: use certificate self signed. Required. Known values are: "TRUE" + and "FALSE". + :vartype certificate_self_signed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar audit_comment: comment for this object. + :vartype audit_comment: str + :ivar description: user description for this object. + :vartype description: str + :ivar etag: read only string representing last create or update. + :vartype etag: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "certificate_self_signed": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "certificate_signer_resource_id": {"key": "properties.certificateSignerResourceId", "type": "str"}, + "certificate_self_signed": {"key": "properties.certificateSelfSigned", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "etag": {"key": "properties.etag", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + certificate_self_signed: Union[str, "_models.BooleanEnum"], + certificate_signer_resource_id: Optional[str] = None, + audit_comment: Optional[str] = None, + description: Optional[str] = None, + etag: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword certificate_signer_resource_id: Resource Id of certificate signer, to be populated + only when certificateSelfSigned is false. + :paramtype certificate_signer_resource_id: str + :keyword certificate_self_signed: use certificate self signed. Required. Known values are: + "TRUE" and "FALSE". + :paramtype certificate_self_signed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword audit_comment: comment for this object. + :paramtype audit_comment: str + :keyword description: user description for this object. + :paramtype description: str + :keyword etag: read only string representing last create or update. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.certificate_signer_resource_id = certificate_signer_resource_id + self.certificate_self_signed = certificate_self_signed + self.audit_comment = audit_comment + self.description = description + self.etag = etag + self.provisioning_state = None + + +class CertificateObjectLocalRulestackResourceListResult(_serialization.Model): + """The response of a CertificateObjectLocalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: + list[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateObjectLocalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: List["_models.CertificateObjectLocalRulestackResource"], + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: + list[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Changelog(_serialization.Model): + """Changelog list. + + All required parameters must be populated in order to send to Azure. + + :ivar changes: list of changes. Required. + :vartype changes: list[str] + :ivar last_committed: lastCommitted timestamp. + :vartype last_committed: ~datetime.datetime + :ivar last_modified: lastModified timestamp. + :vartype last_modified: ~datetime.datetime + """ + + _validation = { + "changes": {"required": True}, + } + + _attribute_map = { + "changes": {"key": "changes", "type": "[str]"}, + "last_committed": {"key": "lastCommitted", "type": "iso-8601"}, + "last_modified": {"key": "lastModified", "type": "iso-8601"}, + } + + def __init__( + self, + *, + changes: List[str], + last_committed: Optional[datetime.datetime] = None, + last_modified: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword changes: list of changes. Required. + :paramtype changes: list[str] + :keyword last_committed: lastCommitted timestamp. + :paramtype last_committed: ~datetime.datetime + :keyword last_modified: lastModified timestamp. + :paramtype last_modified: ~datetime.datetime + """ + super().__init__(**kwargs) + self.changes = changes + self.last_committed = last_committed + self.last_modified = last_modified + + +class CountriesResponse(_serialization.Model): + """Countries Response Object. + + All required parameters must be populated in order to send to Azure. + + :ivar value: List of countries. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.Country] + :ivar next_link: next link. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Country]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Country"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: List of countries. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.Country] + :keyword next_link: next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Country(_serialization.Model): + """Country Description. + + All required parameters must be populated in order to send to Azure. + + :ivar code: country code. Required. + :vartype code: str + :ivar description: code description. + :vartype description: str + """ + + _validation = { + "code": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, *, code: str, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: country code. Required. + :paramtype code: str + :keyword description: code description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.code = code + self.description = description + + +class DestinationAddr(_serialization.Model): + """destination address. + + :ivar cidrs: special value 'any'. + :vartype cidrs: list[str] + :ivar countries: list of countries. + :vartype countries: list[str] + :ivar feeds: list of feeds. + :vartype feeds: list[str] + :ivar prefix_lists: prefix list. + :vartype prefix_lists: list[str] + :ivar fqdn_lists: fqdn list. + :vartype fqdn_lists: list[str] + """ + + _attribute_map = { + "cidrs": {"key": "cidrs", "type": "[str]"}, + "countries": {"key": "countries", "type": "[str]"}, + "feeds": {"key": "feeds", "type": "[str]"}, + "prefix_lists": {"key": "prefixLists", "type": "[str]"}, + "fqdn_lists": {"key": "fqdnLists", "type": "[str]"}, + } + + def __init__( + self, + *, + cidrs: Optional[List[str]] = None, + countries: Optional[List[str]] = None, + feeds: Optional[List[str]] = None, + prefix_lists: Optional[List[str]] = None, + fqdn_lists: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword cidrs: special value 'any'. + :paramtype cidrs: list[str] + :keyword countries: list of countries. + :paramtype countries: list[str] + :keyword feeds: list of feeds. + :paramtype feeds: list[str] + :keyword prefix_lists: prefix list. + :paramtype prefix_lists: list[str] + :keyword fqdn_lists: fqdn list. + :paramtype fqdn_lists: list[str] + """ + super().__init__(**kwargs) + self.cidrs = cidrs + self.countries = countries + self.feeds = feeds + self.prefix_lists = prefix_lists + self.fqdn_lists = fqdn_lists + + +class DNSSettings(_serialization.Model): + """DNS Proxy settings for Firewall. + + :ivar enable_dns_proxy: Enable DNS proxy, disabled by default. Known values are: "DISABLED" and + "ENABLED". + :vartype enable_dns_proxy: str or ~azure.mgmt.paloaltonetworks.models.DNSProxy + :ivar enabled_dns_type: Enabled DNS proxy type, disabled by default. Known values are: "CUSTOM" + and "AZURE". + :vartype enabled_dns_type: str or ~azure.mgmt.paloaltonetworks.models.EnabledDNSType + :ivar dns_servers: List of IPs associated with the Firewall. + :vartype dns_servers: list[~azure.mgmt.paloaltonetworks.models.IPAddress] + """ + + _attribute_map = { + "enable_dns_proxy": {"key": "enableDnsProxy", "type": "str"}, + "enabled_dns_type": {"key": "enabledDnsType", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[IPAddress]"}, + } + + def __init__( + self, + *, + enable_dns_proxy: Optional[Union[str, "_models.DNSProxy"]] = None, + enabled_dns_type: Optional[Union[str, "_models.EnabledDNSType"]] = None, + dns_servers: Optional[List["_models.IPAddress"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword enable_dns_proxy: Enable DNS proxy, disabled by default. Known values are: "DISABLED" + and "ENABLED". + :paramtype enable_dns_proxy: str or ~azure.mgmt.paloaltonetworks.models.DNSProxy + :keyword enabled_dns_type: Enabled DNS proxy type, disabled by default. Known values are: + "CUSTOM" and "AZURE". + :paramtype enabled_dns_type: str or ~azure.mgmt.paloaltonetworks.models.EnabledDNSType + :keyword dns_servers: List of IPs associated with the Firewall. + :paramtype dns_servers: list[~azure.mgmt.paloaltonetworks.models.IPAddress] + """ + super().__init__(**kwargs) + self.enable_dns_proxy = enable_dns_proxy + self.enabled_dns_type = enabled_dns_type + self.dns_servers = dns_servers + + +class EndpointConfiguration(_serialization.Model): + """Endpoint Configuration for frontend and backend. + + All required parameters must be populated in order to send to Azure. + + :ivar port: port ID. Required. + :vartype port: str + :ivar address: Address Space. Required. + :vartype address: ~azure.mgmt.paloaltonetworks.models.IPAddress + """ + + _validation = { + "port": {"required": True}, + "address": {"required": True}, + } + + _attribute_map = { + "port": {"key": "port", "type": "str"}, + "address": {"key": "address", "type": "IPAddress"}, + } + + def __init__(self, *, port: str, address: "_models.IPAddress", **kwargs: Any) -> None: + """ + :keyword port: port ID. Required. + :paramtype port: str + :keyword address: Address Space. Required. + :paramtype address: ~azure.mgmt.paloaltonetworks.models.IPAddress + """ + super().__init__(**kwargs) + self.port = port + self.address = address + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.paloaltonetworks.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.paloaltonetworks.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.paloaltonetworks.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.paloaltonetworks.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class EventHub(_serialization.Model): + """EventHub configurations. + + :ivar id: Resource ID of EventHub. + :vartype id: str + :ivar subscription_id: Subscription Id. + :vartype subscription_id: str + :ivar name: EventHub name. + :vartype name: str + :ivar name_space: EventHub namespace. + :vartype name_space: str + :ivar policy_name: EventHub policy name. + :vartype policy_name: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "name_space": {"key": "nameSpace", "type": "str"}, + "policy_name": {"key": "policyName", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + subscription_id: Optional[str] = None, + name: Optional[str] = None, + name_space: Optional[str] = None, + policy_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource ID of EventHub. + :paramtype id: str + :keyword subscription_id: Subscription Id. + :paramtype subscription_id: str + :keyword name: EventHub name. + :paramtype name: str + :keyword name_space: EventHub namespace. + :paramtype name_space: str + :keyword policy_name: EventHub policy name. + :paramtype policy_name: str + """ + super().__init__(**kwargs) + self.id = id + self.subscription_id = subscription_id + self.name = name + self.name_space = name_space + self.policy_name = policy_name + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class FirewallResource(TrackedResource): # pylint: disable=too-many-instance-attributes + """PaloAltoNetworks Firewall. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :ivar pan_etag: panEtag info. + :vartype pan_etag: str + :ivar network_profile: Network settings. Required. + :vartype network_profile: ~azure.mgmt.paloaltonetworks.models.NetworkProfile + :ivar is_panorama_managed: Panorama Managed: Default is False. Default will be CloudSec + managed. Known values are: "TRUE" and "FALSE". + :vartype is_panorama_managed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar panorama_config: Panorama Configuration. + :vartype panorama_config: ~azure.mgmt.paloaltonetworks.models.PanoramaConfig + :ivar associated_rulestack: Associated Rulestack. + :vartype associated_rulestack: ~azure.mgmt.paloaltonetworks.models.RulestackDetails + :ivar dns_settings: DNS settings for Firewall. Required. + :vartype dns_settings: ~azure.mgmt.paloaltonetworks.models.DNSSettings + :ivar front_end_settings: Frontend settings for Firewall. + :vartype front_end_settings: list[~azure.mgmt.paloaltonetworks.models.FrontendSetting] + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + :ivar plan_data: Billing plan information. Required. + :vartype plan_data: ~azure.mgmt.paloaltonetworks.models.PlanData + :ivar marketplace_details: Marketplace details. Required. + :vartype marketplace_details: ~azure.mgmt.paloaltonetworks.models.MarketplaceDetails + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "network_profile": {"required": True}, + "dns_settings": {"required": True}, + "provisioning_state": {"readonly": True}, + "plan_data": {"required": True}, + "marketplace_details": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "AzureResourceManagerManagedIdentityProperties"}, + "pan_etag": {"key": "properties.panEtag", "type": "str"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "is_panorama_managed": {"key": "properties.isPanoramaManaged", "type": "str"}, + "panorama_config": {"key": "properties.panoramaConfig", "type": "PanoramaConfig"}, + "associated_rulestack": {"key": "properties.associatedRulestack", "type": "RulestackDetails"}, + "dns_settings": {"key": "properties.dnsSettings", "type": "DNSSettings"}, + "front_end_settings": {"key": "properties.frontEndSettings", "type": "[FrontendSetting]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "plan_data": {"key": "properties.planData", "type": "PlanData"}, + "marketplace_details": {"key": "properties.marketplaceDetails", "type": "MarketplaceDetails"}, + } + + def __init__( + self, + *, + location: str, + network_profile: "_models.NetworkProfile", + dns_settings: "_models.DNSSettings", + plan_data: "_models.PlanData", + marketplace_details: "_models.MarketplaceDetails", + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.AzureResourceManagerManagedIdentityProperties"] = None, + pan_etag: Optional[str] = None, + is_panorama_managed: Optional[Union[str, "_models.BooleanEnum"]] = None, + panorama_config: Optional["_models.PanoramaConfig"] = None, + associated_rulestack: Optional["_models.RulestackDetails"] = None, + front_end_settings: Optional[List["_models.FrontendSetting"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :keyword pan_etag: panEtag info. + :paramtype pan_etag: str + :keyword network_profile: Network settings. Required. + :paramtype network_profile: ~azure.mgmt.paloaltonetworks.models.NetworkProfile + :keyword is_panorama_managed: Panorama Managed: Default is False. Default will be CloudSec + managed. Known values are: "TRUE" and "FALSE". + :paramtype is_panorama_managed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword panorama_config: Panorama Configuration. + :paramtype panorama_config: ~azure.mgmt.paloaltonetworks.models.PanoramaConfig + :keyword associated_rulestack: Associated Rulestack. + :paramtype associated_rulestack: ~azure.mgmt.paloaltonetworks.models.RulestackDetails + :keyword dns_settings: DNS settings for Firewall. Required. + :paramtype dns_settings: ~azure.mgmt.paloaltonetworks.models.DNSSettings + :keyword front_end_settings: Frontend settings for Firewall. + :paramtype front_end_settings: list[~azure.mgmt.paloaltonetworks.models.FrontendSetting] + :keyword plan_data: Billing plan information. Required. + :paramtype plan_data: ~azure.mgmt.paloaltonetworks.models.PlanData + :keyword marketplace_details: Marketplace details. Required. + :paramtype marketplace_details: ~azure.mgmt.paloaltonetworks.models.MarketplaceDetails + """ + super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.pan_etag = pan_etag + self.network_profile = network_profile + self.is_panorama_managed = is_panorama_managed + self.panorama_config = panorama_config + self.associated_rulestack = associated_rulestack + self.dns_settings = dns_settings + self.front_end_settings = front_end_settings + self.provisioning_state = None + self.plan_data = plan_data + self.marketplace_details = marketplace_details + + +class FirewallResourceListResult(_serialization.Model): + """The response of a FirewallResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FirewallResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.FirewallResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class FirewallResourceUpdate(_serialization.Model): + """The type used for update operations of the FirewallResource. + + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: The updatable properties of the FirewallResource. + :vartype properties: ~azure.mgmt.paloaltonetworks.models.FirewallResourceUpdateProperties + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "AzureResourceManagerManagedIdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "FirewallResourceUpdateProperties"}, + } + + def __init__( + self, + *, + identity: Optional["_models.AzureResourceManagerManagedIdentityProperties"] = None, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.FirewallResourceUpdateProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: The updatable properties of the FirewallResource. + :paramtype properties: ~azure.mgmt.paloaltonetworks.models.FirewallResourceUpdateProperties + """ + super().__init__(**kwargs) + self.identity = identity + self.tags = tags + self.properties = properties + + +class FirewallResourceUpdateProperties(_serialization.Model): + """The updatable properties of the FirewallResource. + + :ivar pan_etag: panEtag info. + :vartype pan_etag: str + :ivar network_profile: Network settings. + :vartype network_profile: ~azure.mgmt.paloaltonetworks.models.NetworkProfile + :ivar is_panorama_managed: Panorama Managed: Default is False. Default will be CloudSec + managed. Known values are: "TRUE" and "FALSE". + :vartype is_panorama_managed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar panorama_config: Panorama Configuration. + :vartype panorama_config: ~azure.mgmt.paloaltonetworks.models.PanoramaConfig + :ivar associated_rulestack: Associated Rulestack. + :vartype associated_rulestack: ~azure.mgmt.paloaltonetworks.models.RulestackDetails + :ivar dns_settings: DNS settings for Firewall. + :vartype dns_settings: ~azure.mgmt.paloaltonetworks.models.DNSSettings + :ivar front_end_settings: Frontend settings for Firewall. + :vartype front_end_settings: list[~azure.mgmt.paloaltonetworks.models.FrontendSetting] + :ivar plan_data: Billing plan information. + :vartype plan_data: ~azure.mgmt.paloaltonetworks.models.PlanData + :ivar marketplace_details: Marketplace details. + :vartype marketplace_details: ~azure.mgmt.paloaltonetworks.models.MarketplaceDetails + """ + + _attribute_map = { + "pan_etag": {"key": "panEtag", "type": "str"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "is_panorama_managed": {"key": "isPanoramaManaged", "type": "str"}, + "panorama_config": {"key": "panoramaConfig", "type": "PanoramaConfig"}, + "associated_rulestack": {"key": "associatedRulestack", "type": "RulestackDetails"}, + "dns_settings": {"key": "dnsSettings", "type": "DNSSettings"}, + "front_end_settings": {"key": "frontEndSettings", "type": "[FrontendSetting]"}, + "plan_data": {"key": "planData", "type": "PlanData"}, + "marketplace_details": {"key": "marketplaceDetails", "type": "MarketplaceDetails"}, + } + + def __init__( + self, + *, + pan_etag: Optional[str] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + is_panorama_managed: Optional[Union[str, "_models.BooleanEnum"]] = None, + panorama_config: Optional["_models.PanoramaConfig"] = None, + associated_rulestack: Optional["_models.RulestackDetails"] = None, + dns_settings: Optional["_models.DNSSettings"] = None, + front_end_settings: Optional[List["_models.FrontendSetting"]] = None, + plan_data: Optional["_models.PlanData"] = None, + marketplace_details: Optional["_models.MarketplaceDetails"] = None, + **kwargs: Any + ) -> None: + """ + :keyword pan_etag: panEtag info. + :paramtype pan_etag: str + :keyword network_profile: Network settings. + :paramtype network_profile: ~azure.mgmt.paloaltonetworks.models.NetworkProfile + :keyword is_panorama_managed: Panorama Managed: Default is False. Default will be CloudSec + managed. Known values are: "TRUE" and "FALSE". + :paramtype is_panorama_managed: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword panorama_config: Panorama Configuration. + :paramtype panorama_config: ~azure.mgmt.paloaltonetworks.models.PanoramaConfig + :keyword associated_rulestack: Associated Rulestack. + :paramtype associated_rulestack: ~azure.mgmt.paloaltonetworks.models.RulestackDetails + :keyword dns_settings: DNS settings for Firewall. + :paramtype dns_settings: ~azure.mgmt.paloaltonetworks.models.DNSSettings + :keyword front_end_settings: Frontend settings for Firewall. + :paramtype front_end_settings: list[~azure.mgmt.paloaltonetworks.models.FrontendSetting] + :keyword plan_data: Billing plan information. + :paramtype plan_data: ~azure.mgmt.paloaltonetworks.models.PlanData + :keyword marketplace_details: Marketplace details. + :paramtype marketplace_details: ~azure.mgmt.paloaltonetworks.models.MarketplaceDetails + """ + super().__init__(**kwargs) + self.pan_etag = pan_etag + self.network_profile = network_profile + self.is_panorama_managed = is_panorama_managed + self.panorama_config = panorama_config + self.associated_rulestack = associated_rulestack + self.dns_settings = dns_settings + self.front_end_settings = front_end_settings + self.plan_data = plan_data + self.marketplace_details = marketplace_details + + +class FqdnListGlobalRulestackResource(ProxyResource): + """GlobalRulestack fqdnList. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar description: fqdn object description. + :vartype description: str + :ivar fqdn_list: fqdn list. Required. + :vartype fqdn_list: list[str] + :ivar etag: etag info. + :vartype etag: str + :ivar audit_comment: comment for this object. + :vartype audit_comment: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "fqdn_list": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "fqdn_list": {"key": "properties.fqdnList", "type": "[str]"}, + "etag": {"key": "properties.etag", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + fqdn_list: List[str], + description: Optional[str] = None, + etag: Optional[str] = None, + audit_comment: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: fqdn object description. + :paramtype description: str + :keyword fqdn_list: fqdn list. Required. + :paramtype fqdn_list: list[str] + :keyword etag: etag info. + :paramtype etag: str + :keyword audit_comment: comment for this object. + :paramtype audit_comment: str + """ + super().__init__(**kwargs) + self.description = description + self.fqdn_list = fqdn_list + self.etag = etag + self.audit_comment = audit_comment + self.provisioning_state = None + + +class FqdnListGlobalRulestackResourceListResult(_serialization.Model): + """The response of a FqdnListGlobalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FqdnListGlobalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.FqdnListGlobalRulestackResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class FqdnListLocalRulestackResource(ProxyResource): + """LocalRulestack fqdnList. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar description: fqdn object description. + :vartype description: str + :ivar fqdn_list: fqdn list. Required. + :vartype fqdn_list: list[str] + :ivar etag: etag info. + :vartype etag: str + :ivar audit_comment: comment for this object. + :vartype audit_comment: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "fqdn_list": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "fqdn_list": {"key": "properties.fqdnList", "type": "[str]"}, + "etag": {"key": "properties.etag", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + fqdn_list: List[str], + description: Optional[str] = None, + etag: Optional[str] = None, + audit_comment: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: fqdn object description. + :paramtype description: str + :keyword fqdn_list: fqdn list. Required. + :paramtype fqdn_list: list[str] + :keyword etag: etag info. + :paramtype etag: str + :keyword audit_comment: comment for this object. + :paramtype audit_comment: str + """ + super().__init__(**kwargs) + self.description = description + self.fqdn_list = fqdn_list + self.etag = etag + self.audit_comment = audit_comment + self.provisioning_state = None + + +class FqdnListLocalRulestackResourceListResult(_serialization.Model): + """The response of a FqdnListLocalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FqdnListLocalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.FqdnListLocalRulestackResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class FrontendSetting(_serialization.Model): + """Frontend setting for Firewall. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Settings name. Required. + :vartype name: str + :ivar protocol: Protocol Type. Required. Known values are: "TCP" and "UDP". + :vartype protocol: str or ~azure.mgmt.paloaltonetworks.models.ProtocolType + :ivar frontend_configuration: Frontend configurations. Required. + :vartype frontend_configuration: ~azure.mgmt.paloaltonetworks.models.EndpointConfiguration + :ivar backend_configuration: Backend configurations. Required. + :vartype backend_configuration: ~azure.mgmt.paloaltonetworks.models.EndpointConfiguration + """ + + _validation = { + "name": {"required": True}, + "protocol": {"required": True}, + "frontend_configuration": {"required": True}, + "backend_configuration": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "protocol": {"key": "protocol", "type": "str"}, + "frontend_configuration": {"key": "frontendConfiguration", "type": "EndpointConfiguration"}, + "backend_configuration": {"key": "backendConfiguration", "type": "EndpointConfiguration"}, + } + + def __init__( + self, + *, + name: str, + protocol: Union[str, "_models.ProtocolType"], + frontend_configuration: "_models.EndpointConfiguration", + backend_configuration: "_models.EndpointConfiguration", + **kwargs: Any + ) -> None: + """ + :keyword name: Settings name. Required. + :paramtype name: str + :keyword protocol: Protocol Type. Required. Known values are: "TCP" and "UDP". + :paramtype protocol: str or ~azure.mgmt.paloaltonetworks.models.ProtocolType + :keyword frontend_configuration: Frontend configurations. Required. + :paramtype frontend_configuration: ~azure.mgmt.paloaltonetworks.models.EndpointConfiguration + :keyword backend_configuration: Backend configurations. Required. + :paramtype backend_configuration: ~azure.mgmt.paloaltonetworks.models.EndpointConfiguration + """ + super().__init__(**kwargs) + self.name = name + self.protocol = protocol + self.frontend_configuration = frontend_configuration + self.backend_configuration = backend_configuration + + +class GlobalRulestackInfo(_serialization.Model): + """PAN Rulestack Describe Object. + + All required parameters must be populated in order to send to Azure. + + :ivar azure_id: rulestack description. Required. + :vartype azure_id: str + """ + + _validation = { + "azure_id": {"required": True}, + } + + _attribute_map = { + "azure_id": {"key": "azureId", "type": "str"}, + } + + def __init__(self, *, azure_id: str, **kwargs: Any) -> None: + """ + :keyword azure_id: rulestack description. Required. + :paramtype azure_id: str + """ + super().__init__(**kwargs) + self.azure_id = azure_id + + +class GlobalRulestackResource(ProxyResource): # pylint: disable=too-many-instance-attributes + """PaloAltoNetworks GlobalRulestack. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar location: Global Location. Required. + :vartype location: str + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :ivar pan_etag: PanEtag info. + :vartype pan_etag: str + :ivar pan_location: Rulestack Location, Required for GlobalRulestacks, Not for LocalRulestacks. + :vartype pan_location: str + :ivar scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :vartype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :ivar associated_subscriptions: subscription scope of global rulestack. + :vartype associated_subscriptions: list[str] + :ivar description: rulestack description. + :vartype description: str + :ivar default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", and + "NONE". + :vartype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :ivar min_app_id_version: minimum version. + :vartype min_app_id_version: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + :ivar security_services: Security Profile. + :vartype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "AzureResourceManagerManagedIdentityProperties"}, + "pan_etag": {"key": "properties.panEtag", "type": "str"}, + "pan_location": {"key": "properties.panLocation", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "associated_subscriptions": {"key": "properties.associatedSubscriptions", "type": "[str]"}, + "description": {"key": "properties.description", "type": "str"}, + "default_mode": {"key": "properties.defaultMode", "type": "str"}, + "min_app_id_version": {"key": "properties.minAppIdVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "security_services": {"key": "properties.securityServices", "type": "SecurityServices"}, + } + + def __init__( + self, + *, + location: str, + identity: Optional["_models.AzureResourceManagerManagedIdentityProperties"] = None, + pan_etag: Optional[str] = None, + pan_location: Optional[str] = None, + scope: Optional[Union[str, "_models.ScopeType"]] = None, + associated_subscriptions: Optional[List[str]] = None, + description: Optional[str] = None, + default_mode: Optional[Union[str, "_models.DefaultMode"]] = None, + min_app_id_version: Optional[str] = None, + security_services: Optional["_models.SecurityServices"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Global Location. Required. + :paramtype location: str + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :keyword pan_etag: PanEtag info. + :paramtype pan_etag: str + :keyword pan_location: Rulestack Location, Required for GlobalRulestacks, Not for + LocalRulestacks. + :paramtype pan_location: str + :keyword scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :paramtype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :keyword associated_subscriptions: subscription scope of global rulestack. + :paramtype associated_subscriptions: list[str] + :keyword description: rulestack description. + :paramtype description: str + :keyword default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", + and "NONE". + :paramtype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :keyword min_app_id_version: minimum version. + :paramtype min_app_id_version: str + :keyword security_services: Security Profile. + :paramtype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + super().__init__(**kwargs) + self.location = location + self.identity = identity + self.pan_etag = pan_etag + self.pan_location = pan_location + self.scope = scope + self.associated_subscriptions = associated_subscriptions + self.description = description + self.default_mode = default_mode + self.min_app_id_version = min_app_id_version + self.provisioning_state = None + self.security_services = security_services + + +class GlobalRulestackResourceListResult(_serialization.Model): + """The response of a GlobalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[GlobalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.GlobalRulestackResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GlobalRulestackResourceUpdate(_serialization.Model): + """The type used for update operations of the GlobalRulestackResource. + + :ivar location: Global Location. + :vartype location: str + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :ivar properties: The updatable properties of the GlobalRulestackResource. + :vartype properties: + ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResourceUpdateProperties + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "AzureResourceManagerManagedIdentityProperties"}, + "properties": {"key": "properties", "type": "GlobalRulestackResourceUpdateProperties"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + identity: Optional["_models.AzureResourceManagerManagedIdentityProperties"] = None, + properties: Optional["_models.GlobalRulestackResourceUpdateProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Global Location. + :paramtype location: str + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :keyword properties: The updatable properties of the GlobalRulestackResource. + :paramtype properties: + ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResourceUpdateProperties + """ + super().__init__(**kwargs) + self.location = location + self.identity = identity + self.properties = properties + + +class GlobalRulestackResourceUpdateProperties(_serialization.Model): + """The updatable properties of the GlobalRulestackResource. + + :ivar pan_etag: PanEtag info. + :vartype pan_etag: str + :ivar pan_location: Rulestack Location, Required for GlobalRulestacks, Not for LocalRulestacks. + :vartype pan_location: str + :ivar scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :vartype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :ivar associated_subscriptions: subscription scope of global rulestack. + :vartype associated_subscriptions: list[str] + :ivar description: rulestack description. + :vartype description: str + :ivar default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", and + "NONE". + :vartype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :ivar min_app_id_version: minimum version. + :vartype min_app_id_version: str + :ivar security_services: Security Profile. + :vartype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + + _attribute_map = { + "pan_etag": {"key": "panEtag", "type": "str"}, + "pan_location": {"key": "panLocation", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "associated_subscriptions": {"key": "associatedSubscriptions", "type": "[str]"}, + "description": {"key": "description", "type": "str"}, + "default_mode": {"key": "defaultMode", "type": "str"}, + "min_app_id_version": {"key": "minAppIdVersion", "type": "str"}, + "security_services": {"key": "securityServices", "type": "SecurityServices"}, + } + + def __init__( + self, + *, + pan_etag: Optional[str] = None, + pan_location: Optional[str] = None, + scope: Optional[Union[str, "_models.ScopeType"]] = None, + associated_subscriptions: Optional[List[str]] = None, + description: Optional[str] = None, + default_mode: Optional[Union[str, "_models.DefaultMode"]] = None, + min_app_id_version: Optional[str] = None, + security_services: Optional["_models.SecurityServices"] = None, + **kwargs: Any + ) -> None: + """ + :keyword pan_etag: PanEtag info. + :paramtype pan_etag: str + :keyword pan_location: Rulestack Location, Required for GlobalRulestacks, Not for + LocalRulestacks. + :paramtype pan_location: str + :keyword scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :paramtype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :keyword associated_subscriptions: subscription scope of global rulestack. + :paramtype associated_subscriptions: list[str] + :keyword description: rulestack description. + :paramtype description: str + :keyword default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", + and "NONE". + :paramtype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :keyword min_app_id_version: minimum version. + :paramtype min_app_id_version: str + :keyword security_services: Security Profile. + :paramtype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + super().__init__(**kwargs) + self.pan_etag = pan_etag + self.pan_location = pan_location + self.scope = scope + self.associated_subscriptions = associated_subscriptions + self.description = description + self.default_mode = default_mode + self.min_app_id_version = min_app_id_version + self.security_services = security_services + + +class IPAddress(_serialization.Model): + """IP Address. + + :ivar resource_id: Resource Id. + :vartype resource_id: str + :ivar address: Address value. + :vartype address: str + """ + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "address": {"key": "address", "type": "str"}, + } + + def __init__(self, *, resource_id: Optional[str] = None, address: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword resource_id: Resource Id. + :paramtype resource_id: str + :keyword address: Address value. + :paramtype address: str + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.address = address + + +class IPAddressSpace(_serialization.Model): + """IP Address Space. + + :ivar resource_id: Resource Id. + :vartype resource_id: str + :ivar address_space: Address Space. + :vartype address_space: str + """ + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "address_space": {"key": "addressSpace", "type": "str"}, + } + + def __init__( + self, *, resource_id: Optional[str] = None, address_space: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword resource_id: Resource Id. + :paramtype resource_id: str + :keyword address_space: Address Space. + :paramtype address_space: str + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.address_space = address_space + + +class ListAppIdResponse(_serialization.Model): + """ListAppIdResponse. + + All required parameters must be populated in order to send to Azure. + + :ivar value: List of AppIds. Required. + :vartype value: list[str] + :ivar next_link: next Link. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: List of AppIds. Required. + :paramtype value: list[str] + :keyword next_link: next Link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ListFirewallsResponse(_serialization.Model): + """List firewalls response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: firewalls list. Required. + :vartype value: list[str] + :ivar next_link: next link. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: firewalls list. Required. + :paramtype value: list[str] + :keyword next_link: next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LocalRulesResource(ProxyResource): # pylint: disable=too-many-instance-attributes + """LocalRulestack rule list. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar etag: etag info. + :vartype etag: str + :ivar rule_name: rule name. Required. + :vartype rule_name: str + :ivar priority: + :vartype priority: int + :ivar description: rule description. + :vartype description: str + :ivar rule_state: state of this rule. Known values are: "DISABLED" and "ENABLED". + :vartype rule_state: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :ivar source: source address. + :vartype source: ~azure.mgmt.paloaltonetworks.models.SourceAddr + :ivar negate_source: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :vartype negate_source: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar destination: destination address. + :vartype destination: ~azure.mgmt.paloaltonetworks.models.DestinationAddr + :ivar negate_destination: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :vartype negate_destination: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar applications: array of rule applications. + :vartype applications: list[str] + :ivar category: rule category. + :vartype category: ~azure.mgmt.paloaltonetworks.models.Category + :ivar protocol: any, application-default, TCP:number, UDP:number. + :vartype protocol: str + :ivar protocol_port_list: prot port list. + :vartype protocol_port_list: list[str] + :ivar inbound_inspection_certificate: inbound Inspection Certificate. + :vartype inbound_inspection_certificate: str + :ivar audit_comment: rule comment. + :vartype audit_comment: str + :ivar action_type: rule action. Known values are: "Allow", "DenySilent", "DenyResetServer", and + "DenyResetBoth". + :vartype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionEnum + :ivar enable_logging: enable or disable logging. Known values are: "DISABLED" and "ENABLED". + :vartype enable_logging: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :ivar decryption_rule_type: enable or disable decryption. Known values are: + "SSLOutboundInspection", "SSLInboundInspection", and "None". + :vartype decryption_rule_type: str or + ~azure.mgmt.paloaltonetworks.models.DecryptionRuleTypeEnum + :ivar tags: tag for rule. + :vartype tags: list[~azure.mgmt.paloaltonetworks.models.TagInfo] + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "rule_name": {"required": True}, + "priority": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "etag": {"key": "properties.etag", "type": "str"}, + "rule_name": {"key": "properties.ruleName", "type": "str"}, + "priority": {"key": "properties.priority", "type": "int"}, + "description": {"key": "properties.description", "type": "str"}, + "rule_state": {"key": "properties.ruleState", "type": "str"}, + "source": {"key": "properties.source", "type": "SourceAddr"}, + "negate_source": {"key": "properties.negateSource", "type": "str"}, + "destination": {"key": "properties.destination", "type": "DestinationAddr"}, + "negate_destination": {"key": "properties.negateDestination", "type": "str"}, + "applications": {"key": "properties.applications", "type": "[str]"}, + "category": {"key": "properties.category", "type": "Category"}, + "protocol": {"key": "properties.protocol", "type": "str"}, + "protocol_port_list": {"key": "properties.protocolPortList", "type": "[str]"}, + "inbound_inspection_certificate": {"key": "properties.inboundInspectionCertificate", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "action_type": {"key": "properties.actionType", "type": "str"}, + "enable_logging": {"key": "properties.enableLogging", "type": "str"}, + "decryption_rule_type": {"key": "properties.decryptionRuleType", "type": "str"}, + "tags": {"key": "properties.tags", "type": "[TagInfo]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + rule_name: str, + etag: Optional[str] = None, + description: Optional[str] = None, + rule_state: Optional[Union[str, "_models.StateEnum"]] = None, + source: Optional["_models.SourceAddr"] = None, + negate_source: Optional[Union[str, "_models.BooleanEnum"]] = None, + destination: Optional["_models.DestinationAddr"] = None, + negate_destination: Optional[Union[str, "_models.BooleanEnum"]] = None, + applications: Optional[List[str]] = None, + category: Optional["_models.Category"] = None, + protocol: str = "application-default", + protocol_port_list: Optional[List[str]] = None, + inbound_inspection_certificate: Optional[str] = None, + audit_comment: Optional[str] = None, + action_type: Optional[Union[str, "_models.ActionEnum"]] = None, + enable_logging: Optional[Union[str, "_models.StateEnum"]] = None, + decryption_rule_type: Optional[Union[str, "_models.DecryptionRuleTypeEnum"]] = None, + tags: Optional[List["_models.TagInfo"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword etag: etag info. + :paramtype etag: str + :keyword rule_name: rule name. Required. + :paramtype rule_name: str + :keyword description: rule description. + :paramtype description: str + :keyword rule_state: state of this rule. Known values are: "DISABLED" and "ENABLED". + :paramtype rule_state: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :keyword source: source address. + :paramtype source: ~azure.mgmt.paloaltonetworks.models.SourceAddr + :keyword negate_source: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :paramtype negate_source: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword destination: destination address. + :paramtype destination: ~azure.mgmt.paloaltonetworks.models.DestinationAddr + :keyword negate_destination: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :paramtype negate_destination: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword applications: array of rule applications. + :paramtype applications: list[str] + :keyword category: rule category. + :paramtype category: ~azure.mgmt.paloaltonetworks.models.Category + :keyword protocol: any, application-default, TCP:number, UDP:number. + :paramtype protocol: str + :keyword protocol_port_list: prot port list. + :paramtype protocol_port_list: list[str] + :keyword inbound_inspection_certificate: inbound Inspection Certificate. + :paramtype inbound_inspection_certificate: str + :keyword audit_comment: rule comment. + :paramtype audit_comment: str + :keyword action_type: rule action. Known values are: "Allow", "DenySilent", "DenyResetServer", + and "DenyResetBoth". + :paramtype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionEnum + :keyword enable_logging: enable or disable logging. Known values are: "DISABLED" and "ENABLED". + :paramtype enable_logging: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :keyword decryption_rule_type: enable or disable decryption. Known values are: + "SSLOutboundInspection", "SSLInboundInspection", and "None". + :paramtype decryption_rule_type: str or + ~azure.mgmt.paloaltonetworks.models.DecryptionRuleTypeEnum + :keyword tags: tag for rule. + :paramtype tags: list[~azure.mgmt.paloaltonetworks.models.TagInfo] + """ + super().__init__(**kwargs) + self.etag = etag + self.rule_name = rule_name + self.priority = None + self.description = description + self.rule_state = rule_state + self.source = source + self.negate_source = negate_source + self.destination = destination + self.negate_destination = negate_destination + self.applications = applications + self.category = category + self.protocol = protocol + self.protocol_port_list = protocol_port_list + self.inbound_inspection_certificate = inbound_inspection_certificate + self.audit_comment = audit_comment + self.action_type = action_type + self.enable_logging = enable_logging + self.decryption_rule_type = decryption_rule_type + self.tags = tags + self.provisioning_state = None + + +class LocalRulesResourceListResult(_serialization.Model): + """The response of a LocalRulesResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[LocalRulesResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.LocalRulesResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LocalRulestackResource(TrackedResource): # pylint: disable=too-many-instance-attributes + """PaloAltoNetworks LocalRulestack. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :ivar pan_etag: PanEtag info. + :vartype pan_etag: str + :ivar pan_location: Rulestack Location, Required for GlobalRulestacks, Not for LocalRulestacks. + :vartype pan_location: str + :ivar scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :vartype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :ivar associated_subscriptions: subscription scope of global rulestack. + :vartype associated_subscriptions: list[str] + :ivar description: rulestack description. + :vartype description: str + :ivar default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", and + "NONE". + :vartype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :ivar min_app_id_version: minimum version. + :vartype min_app_id_version: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + :ivar security_services: Security Profile. + :vartype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "AzureResourceManagerManagedIdentityProperties"}, + "pan_etag": {"key": "properties.panEtag", "type": "str"}, + "pan_location": {"key": "properties.panLocation", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "associated_subscriptions": {"key": "properties.associatedSubscriptions", "type": "[str]"}, + "description": {"key": "properties.description", "type": "str"}, + "default_mode": {"key": "properties.defaultMode", "type": "str"}, + "min_app_id_version": {"key": "properties.minAppIdVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "security_services": {"key": "properties.securityServices", "type": "SecurityServices"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.AzureResourceManagerManagedIdentityProperties"] = None, + pan_etag: Optional[str] = None, + pan_location: Optional[str] = None, + scope: Optional[Union[str, "_models.ScopeType"]] = None, + associated_subscriptions: Optional[List[str]] = None, + description: Optional[str] = None, + default_mode: Optional[Union[str, "_models.DefaultMode"]] = None, + min_app_id_version: Optional[str] = None, + security_services: Optional["_models.SecurityServices"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :keyword pan_etag: PanEtag info. + :paramtype pan_etag: str + :keyword pan_location: Rulestack Location, Required for GlobalRulestacks, Not for + LocalRulestacks. + :paramtype pan_location: str + :keyword scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :paramtype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :keyword associated_subscriptions: subscription scope of global rulestack. + :paramtype associated_subscriptions: list[str] + :keyword description: rulestack description. + :paramtype description: str + :keyword default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", + and "NONE". + :paramtype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :keyword min_app_id_version: minimum version. + :paramtype min_app_id_version: str + :keyword security_services: Security Profile. + :paramtype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.pan_etag = pan_etag + self.pan_location = pan_location + self.scope = scope + self.associated_subscriptions = associated_subscriptions + self.description = description + self.default_mode = default_mode + self.min_app_id_version = min_app_id_version + self.provisioning_state = None + self.security_services = security_services + + +class LocalRulestackResourceListResult(_serialization.Model): + """The response of a LocalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[LocalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.LocalRulestackResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LocalRulestackResourceUpdate(_serialization.Model): + """The type used for update operations of the LocalRulestackResource. + + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: The updatable properties of the LocalRulestackResource. + :vartype properties: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResourceUpdateProperties + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "AzureResourceManagerManagedIdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "LocalRulestackResourceUpdateProperties"}, + } + + def __init__( + self, + *, + identity: Optional["_models.AzureResourceManagerManagedIdentityProperties"] = None, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.LocalRulestackResourceUpdateProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: + ~azure.mgmt.paloaltonetworks.models.AzureResourceManagerManagedIdentityProperties + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: The updatable properties of the LocalRulestackResource. + :paramtype properties: + ~azure.mgmt.paloaltonetworks.models.LocalRulestackResourceUpdateProperties + """ + super().__init__(**kwargs) + self.identity = identity + self.tags = tags + self.properties = properties + + +class LocalRulestackResourceUpdateProperties(_serialization.Model): + """The updatable properties of the LocalRulestackResource. + + :ivar pan_etag: PanEtag info. + :vartype pan_etag: str + :ivar pan_location: Rulestack Location, Required for GlobalRulestacks, Not for LocalRulestacks. + :vartype pan_location: str + :ivar scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :vartype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :ivar associated_subscriptions: subscription scope of global rulestack. + :vartype associated_subscriptions: list[str] + :ivar description: rulestack description. + :vartype description: str + :ivar default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", and + "NONE". + :vartype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :ivar min_app_id_version: minimum version. + :vartype min_app_id_version: str + :ivar security_services: Security Profile. + :vartype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + + _attribute_map = { + "pan_etag": {"key": "panEtag", "type": "str"}, + "pan_location": {"key": "panLocation", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "associated_subscriptions": {"key": "associatedSubscriptions", "type": "[str]"}, + "description": {"key": "description", "type": "str"}, + "default_mode": {"key": "defaultMode", "type": "str"}, + "min_app_id_version": {"key": "minAppIdVersion", "type": "str"}, + "security_services": {"key": "securityServices", "type": "SecurityServices"}, + } + + def __init__( + self, + *, + pan_etag: Optional[str] = None, + pan_location: Optional[str] = None, + scope: Optional[Union[str, "_models.ScopeType"]] = None, + associated_subscriptions: Optional[List[str]] = None, + description: Optional[str] = None, + default_mode: Optional[Union[str, "_models.DefaultMode"]] = None, + min_app_id_version: Optional[str] = None, + security_services: Optional["_models.SecurityServices"] = None, + **kwargs: Any + ) -> None: + """ + :keyword pan_etag: PanEtag info. + :paramtype pan_etag: str + :keyword pan_location: Rulestack Location, Required for GlobalRulestacks, Not for + LocalRulestacks. + :paramtype pan_location: str + :keyword scope: Rulestack Type. Known values are: "LOCAL" and "GLOBAL". + :paramtype scope: str or ~azure.mgmt.paloaltonetworks.models.ScopeType + :keyword associated_subscriptions: subscription scope of global rulestack. + :paramtype associated_subscriptions: list[str] + :keyword description: rulestack description. + :paramtype description: str + :keyword default_mode: Mode for default rules creation. Known values are: "IPS", "FIREWALL", + and "NONE". + :paramtype default_mode: str or ~azure.mgmt.paloaltonetworks.models.DefaultMode + :keyword min_app_id_version: minimum version. + :paramtype min_app_id_version: str + :keyword security_services: Security Profile. + :paramtype security_services: ~azure.mgmt.paloaltonetworks.models.SecurityServices + """ + super().__init__(**kwargs) + self.pan_etag = pan_etag + self.pan_location = pan_location + self.scope = scope + self.associated_subscriptions = associated_subscriptions + self.description = description + self.default_mode = default_mode + self.min_app_id_version = min_app_id_version + self.security_services = security_services + + +class LogDestination(_serialization.Model): + """Log Destination. + + :ivar storage_configurations: Storage account configurations. + :vartype storage_configurations: ~azure.mgmt.paloaltonetworks.models.StorageAccount + :ivar event_hub_configurations: Event Hub configurations. + :vartype event_hub_configurations: ~azure.mgmt.paloaltonetworks.models.EventHub + :ivar monitor_configurations: Monitor Log configurations. + :vartype monitor_configurations: ~azure.mgmt.paloaltonetworks.models.MonitorLog + """ + + _attribute_map = { + "storage_configurations": {"key": "storageConfigurations", "type": "StorageAccount"}, + "event_hub_configurations": {"key": "eventHubConfigurations", "type": "EventHub"}, + "monitor_configurations": {"key": "monitorConfigurations", "type": "MonitorLog"}, + } + + def __init__( + self, + *, + storage_configurations: Optional["_models.StorageAccount"] = None, + event_hub_configurations: Optional["_models.EventHub"] = None, + monitor_configurations: Optional["_models.MonitorLog"] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage_configurations: Storage account configurations. + :paramtype storage_configurations: ~azure.mgmt.paloaltonetworks.models.StorageAccount + :keyword event_hub_configurations: Event Hub configurations. + :paramtype event_hub_configurations: ~azure.mgmt.paloaltonetworks.models.EventHub + :keyword monitor_configurations: Monitor Log configurations. + :paramtype monitor_configurations: ~azure.mgmt.paloaltonetworks.models.MonitorLog + """ + super().__init__(**kwargs) + self.storage_configurations = storage_configurations + self.event_hub_configurations = event_hub_configurations + self.monitor_configurations = monitor_configurations + + +class LogSettings(_serialization.Model): + """Log Settings for Firewall. + + :ivar log_type: One of possible log type. Known values are: "TRAFFIC", "THREAT", "DECRYPTION", + "WILDFIRE", "DLP", and "AUDIT". + :vartype log_type: str or ~azure.mgmt.paloaltonetworks.models.LogType + :ivar log_option: Log option SAME/INDIVIDUAL. Known values are: "SAME_DESTINATION" and + "INDIVIDUAL_DESTINATION". + :vartype log_option: str or ~azure.mgmt.paloaltonetworks.models.LogOption + :ivar application_insights: Application Insight details. + :vartype application_insights: ~azure.mgmt.paloaltonetworks.models.ApplicationInsights + :ivar common_destination: Common destination configurations. + :vartype common_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + :ivar traffic_log_destination: Traffic destination configurations. + :vartype traffic_log_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + :ivar threat_log_destination: Threat destination configurations. + :vartype threat_log_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + :ivar decrypt_log_destination: Decrypt destination configurations. + :vartype decrypt_log_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + """ + + _attribute_map = { + "log_type": {"key": "logType", "type": "str"}, + "log_option": {"key": "logOption", "type": "str"}, + "application_insights": {"key": "applicationInsights", "type": "ApplicationInsights"}, + "common_destination": {"key": "commonDestination", "type": "LogDestination"}, + "traffic_log_destination": {"key": "trafficLogDestination", "type": "LogDestination"}, + "threat_log_destination": {"key": "threatLogDestination", "type": "LogDestination"}, + "decrypt_log_destination": {"key": "decryptLogDestination", "type": "LogDestination"}, + } + + def __init__( + self, + *, + log_type: Optional[Union[str, "_models.LogType"]] = None, + log_option: Optional[Union[str, "_models.LogOption"]] = None, + application_insights: Optional["_models.ApplicationInsights"] = None, + common_destination: Optional["_models.LogDestination"] = None, + traffic_log_destination: Optional["_models.LogDestination"] = None, + threat_log_destination: Optional["_models.LogDestination"] = None, + decrypt_log_destination: Optional["_models.LogDestination"] = None, + **kwargs: Any + ) -> None: + """ + :keyword log_type: One of possible log type. Known values are: "TRAFFIC", "THREAT", + "DECRYPTION", "WILDFIRE", "DLP", and "AUDIT". + :paramtype log_type: str or ~azure.mgmt.paloaltonetworks.models.LogType + :keyword log_option: Log option SAME/INDIVIDUAL. Known values are: "SAME_DESTINATION" and + "INDIVIDUAL_DESTINATION". + :paramtype log_option: str or ~azure.mgmt.paloaltonetworks.models.LogOption + :keyword application_insights: Application Insight details. + :paramtype application_insights: ~azure.mgmt.paloaltonetworks.models.ApplicationInsights + :keyword common_destination: Common destination configurations. + :paramtype common_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + :keyword traffic_log_destination: Traffic destination configurations. + :paramtype traffic_log_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + :keyword threat_log_destination: Threat destination configurations. + :paramtype threat_log_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + :keyword decrypt_log_destination: Decrypt destination configurations. + :paramtype decrypt_log_destination: ~azure.mgmt.paloaltonetworks.models.LogDestination + """ + super().__init__(**kwargs) + self.log_type = log_type + self.log_option = log_option + self.application_insights = application_insights + self.common_destination = common_destination + self.traffic_log_destination = traffic_log_destination + self.threat_log_destination = threat_log_destination + self.decrypt_log_destination = decrypt_log_destination + + +class MarketplaceDetails(_serialization.Model): + """MarketplaceDetails of PAN Firewall resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar marketplace_subscription_id: Marketplace Subscription Id. + :vartype marketplace_subscription_id: str + :ivar offer_id: Offer Id. Required. + :vartype offer_id: str + :ivar publisher_id: Publisher Id. Required. + :vartype publisher_id: str + :ivar marketplace_subscription_status: Marketplace Subscription Status. Known values are: + "PendingFulfillmentStart", "Subscribed", "Suspended", "Unsubscribed", "NotStarted", and + "FulfillmentRequested". + :vartype marketplace_subscription_status: str or + ~azure.mgmt.paloaltonetworks.models.MarketplaceSubscriptionStatus + """ + + _validation = { + "marketplace_subscription_id": {"readonly": True}, + "offer_id": {"required": True}, + "publisher_id": {"required": True}, + } + + _attribute_map = { + "marketplace_subscription_id": {"key": "marketplaceSubscriptionId", "type": "str"}, + "offer_id": {"key": "offerId", "type": "str"}, + "publisher_id": {"key": "publisherId", "type": "str"}, + "marketplace_subscription_status": {"key": "marketplaceSubscriptionStatus", "type": "str"}, + } + + def __init__( + self, + *, + offer_id: str, + publisher_id: str, + marketplace_subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword offer_id: Offer Id. Required. + :paramtype offer_id: str + :keyword publisher_id: Publisher Id. Required. + :paramtype publisher_id: str + :keyword marketplace_subscription_status: Marketplace Subscription Status. Known values are: + "PendingFulfillmentStart", "Subscribed", "Suspended", "Unsubscribed", "NotStarted", and + "FulfillmentRequested". + :paramtype marketplace_subscription_status: str or + ~azure.mgmt.paloaltonetworks.models.MarketplaceSubscriptionStatus + """ + super().__init__(**kwargs) + self.marketplace_subscription_id = None + self.offer_id = offer_id + self.publisher_id = publisher_id + self.marketplace_subscription_status = marketplace_subscription_status + + +class MonitorLog(_serialization.Model): + """MonitorLog configurations. + + :ivar id: Resource ID of MonitorLog. + :vartype id: str + :ivar subscription_id: Subscription Id. + :vartype subscription_id: str + :ivar workspace: MonitorLog workspace. + :vartype workspace: str + :ivar primary_key: Primary Key value for Monitor. + :vartype primary_key: str + :ivar secondary_key: Secondary Key value for Monitor. + :vartype secondary_key: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "workspace": {"key": "workspace", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + subscription_id: Optional[str] = None, + workspace: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource ID of MonitorLog. + :paramtype id: str + :keyword subscription_id: Subscription Id. + :paramtype subscription_id: str + :keyword workspace: MonitorLog workspace. + :paramtype workspace: str + :keyword primary_key: Primary Key value for Monitor. + :paramtype primary_key: str + :keyword secondary_key: Secondary Key value for Monitor. + :paramtype secondary_key: str + """ + super().__init__(**kwargs) + self.id = id + self.subscription_id = subscription_id + self.workspace = workspace + self.primary_key = primary_key + self.secondary_key = secondary_key + + +class NameDescriptionObject(_serialization.Model): + """object type info. + + All required parameters must be populated in order to send to Azure. + + :ivar name: name value. Required. + :vartype name: str + :ivar description: description value. + :vartype description: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, *, name: str, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: name value. Required. + :paramtype name: str + :keyword description: description value. + :paramtype description: str + """ + super().__init__(**kwargs) + self.name = name + self.description = description + + +class NetworkProfile(_serialization.Model): + """Network settings for Firewall. + + All required parameters must be populated in order to send to Azure. + + :ivar vnet_configuration: Vnet configurations. + :vartype vnet_configuration: ~azure.mgmt.paloaltonetworks.models.VnetConfiguration + :ivar vwan_configuration: Vwan configurations. + :vartype vwan_configuration: ~azure.mgmt.paloaltonetworks.models.VwanConfiguration + :ivar network_type: vnet or vwan, cannot be updated. Required. Known values are: "VNET" and + "VWAN". + :vartype network_type: str or ~azure.mgmt.paloaltonetworks.models.NetworkType + :ivar public_ips: List of IPs associated with the Firewall. Required. + :vartype public_ips: list[~azure.mgmt.paloaltonetworks.models.IPAddress] + :ivar enable_egress_nat: Enable egress NAT, enabled by default. Required. Known values are: + "DISABLED" and "ENABLED". + :vartype enable_egress_nat: str or ~azure.mgmt.paloaltonetworks.models.EgressNat + :ivar egress_nat_ip: Egress nat IP to use. + :vartype egress_nat_ip: list[~azure.mgmt.paloaltonetworks.models.IPAddress] + """ + + _validation = { + "network_type": {"required": True}, + "public_ips": {"required": True}, + "enable_egress_nat": {"required": True}, + } + + _attribute_map = { + "vnet_configuration": {"key": "vnetConfiguration", "type": "VnetConfiguration"}, + "vwan_configuration": {"key": "vwanConfiguration", "type": "VwanConfiguration"}, + "network_type": {"key": "networkType", "type": "str"}, + "public_ips": {"key": "publicIps", "type": "[IPAddress]"}, + "enable_egress_nat": {"key": "enableEgressNat", "type": "str"}, + "egress_nat_ip": {"key": "egressNatIp", "type": "[IPAddress]"}, + } + + def __init__( + self, + *, + network_type: Union[str, "_models.NetworkType"], + public_ips: List["_models.IPAddress"], + enable_egress_nat: Union[str, "_models.EgressNat"], + vnet_configuration: Optional["_models.VnetConfiguration"] = None, + vwan_configuration: Optional["_models.VwanConfiguration"] = None, + egress_nat_ip: Optional[List["_models.IPAddress"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword vnet_configuration: Vnet configurations. + :paramtype vnet_configuration: ~azure.mgmt.paloaltonetworks.models.VnetConfiguration + :keyword vwan_configuration: Vwan configurations. + :paramtype vwan_configuration: ~azure.mgmt.paloaltonetworks.models.VwanConfiguration + :keyword network_type: vnet or vwan, cannot be updated. Required. Known values are: "VNET" and + "VWAN". + :paramtype network_type: str or ~azure.mgmt.paloaltonetworks.models.NetworkType + :keyword public_ips: List of IPs associated with the Firewall. Required. + :paramtype public_ips: list[~azure.mgmt.paloaltonetworks.models.IPAddress] + :keyword enable_egress_nat: Enable egress NAT, enabled by default. Required. Known values are: + "DISABLED" and "ENABLED". + :paramtype enable_egress_nat: str or ~azure.mgmt.paloaltonetworks.models.EgressNat + :keyword egress_nat_ip: Egress nat IP to use. + :paramtype egress_nat_ip: list[~azure.mgmt.paloaltonetworks.models.IPAddress] + """ + super().__init__(**kwargs) + self.vnet_configuration = vnet_configuration + self.vwan_configuration = vwan_configuration + self.network_type = network_type + self.public_ips = public_ips + self.enable_egress_nat = enable_egress_nat + self.egress_nat_ip = egress_nat_ip + + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.paloaltonetworks.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.paloaltonetworks.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.paloaltonetworks.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _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, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PanoramaConfig(_serialization.Model): + """Panorama Config. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar config_string: Base64 encoded string representing Panorama parameters to be used by + Firewall to connect to Panorama. This string is generated via azure plugin in Panorama. + Required. + :vartype config_string: str + :ivar vm_auth_key: VM auth key for panorama connectivity. + :vartype vm_auth_key: str + :ivar panorama_server: Primary Panorama Server IP address value in dotted format for IPv4. + :vartype panorama_server: str + :ivar panorama_server2: Secondary Panorama Server IP address value in dotted format for IPv4. + :vartype panorama_server2: str + :ivar dg_name: Panorama Device Group to join. + :vartype dg_name: str + :ivar tpl_name: Panorama Template Stack to join - (Once configured we can not edit the value). + :vartype tpl_name: str + :ivar cg_name: Panorama Collector Group to join - (Once configured we can not edit the value). + :vartype cg_name: str + :ivar host_name: Resource name(may be unique) for PN admin. + :vartype host_name: str + """ + + _validation = { + "config_string": {"required": True}, + "vm_auth_key": {"readonly": True}, + "panorama_server": {"readonly": True}, + "panorama_server2": {"readonly": True}, + "dg_name": {"readonly": True}, + "tpl_name": {"readonly": True}, + "cg_name": {"readonly": True}, + "host_name": {"readonly": True}, + } + + _attribute_map = { + "config_string": {"key": "configString", "type": "str"}, + "vm_auth_key": {"key": "vmAuthKey", "type": "str"}, + "panorama_server": {"key": "panoramaServer", "type": "str"}, + "panorama_server2": {"key": "panoramaServer2", "type": "str"}, + "dg_name": {"key": "dgName", "type": "str"}, + "tpl_name": {"key": "tplName", "type": "str"}, + "cg_name": {"key": "cgName", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + } + + def __init__(self, *, config_string: str, **kwargs: Any) -> None: + """ + :keyword config_string: Base64 encoded string representing Panorama parameters to be used by + Firewall to connect to Panorama. This string is generated via azure plugin in Panorama. + Required. + :paramtype config_string: str + """ + super().__init__(**kwargs) + self.config_string = config_string + self.vm_auth_key = None + self.panorama_server = None + self.panorama_server2 = None + self.dg_name = None + self.tpl_name = None + self.cg_name = None + self.host_name = None + + +class PlanData(_serialization.Model): + """Billing plan information. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar usage_type: different usage type like PAYG/COMMITTED. Known values are: "PAYG" and + "COMMITTED". + :vartype usage_type: str or ~azure.mgmt.paloaltonetworks.models.UsageType + :ivar billing_cycle: different billing cycles like MONTHLY/WEEKLY. Required. Known values are: + "WEEKLY" and "MONTHLY". + :vartype billing_cycle: str or ~azure.mgmt.paloaltonetworks.models.BillingCycle + :ivar plan_id: plan id as published by Liftr.PAN. Required. + :vartype plan_id: str + :ivar effective_date: date when plan was applied. + :vartype effective_date: ~datetime.datetime + """ + + _validation = { + "billing_cycle": {"required": True}, + "plan_id": {"required": True, "max_length": 50}, + "effective_date": {"readonly": True}, + } + + _attribute_map = { + "usage_type": {"key": "usageType", "type": "str"}, + "billing_cycle": {"key": "billingCycle", "type": "str"}, + "plan_id": {"key": "planId", "type": "str"}, + "effective_date": {"key": "effectiveDate", "type": "iso-8601"}, + } + + def __init__( + self, + *, + billing_cycle: Union[str, "_models.BillingCycle"], + plan_id: str, + usage_type: Optional[Union[str, "_models.UsageType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword usage_type: different usage type like PAYG/COMMITTED. Known values are: "PAYG" and + "COMMITTED". + :paramtype usage_type: str or ~azure.mgmt.paloaltonetworks.models.UsageType + :keyword billing_cycle: different billing cycles like MONTHLY/WEEKLY. Required. Known values + are: "WEEKLY" and "MONTHLY". + :paramtype billing_cycle: str or ~azure.mgmt.paloaltonetworks.models.BillingCycle + :keyword plan_id: plan id as published by Liftr.PAN. Required. + :paramtype plan_id: str + """ + super().__init__(**kwargs) + self.usage_type = usage_type + self.billing_cycle = billing_cycle + self.plan_id = plan_id + self.effective_date = None + + +class PostRulesResource(ProxyResource): # pylint: disable=too-many-instance-attributes + """PostRulestack rule list. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar etag: etag info. + :vartype etag: str + :ivar rule_name: rule name. Required. + :vartype rule_name: str + :ivar priority: + :vartype priority: int + :ivar description: rule description. + :vartype description: str + :ivar rule_state: state of this rule. Known values are: "DISABLED" and "ENABLED". + :vartype rule_state: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :ivar source: source address. + :vartype source: ~azure.mgmt.paloaltonetworks.models.SourceAddr + :ivar negate_source: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :vartype negate_source: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar destination: destination address. + :vartype destination: ~azure.mgmt.paloaltonetworks.models.DestinationAddr + :ivar negate_destination: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :vartype negate_destination: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar applications: array of rule applications. + :vartype applications: list[str] + :ivar category: rule category. + :vartype category: ~azure.mgmt.paloaltonetworks.models.Category + :ivar protocol: any, application-default, TCP:number, UDP:number. + :vartype protocol: str + :ivar protocol_port_list: prot port list. + :vartype protocol_port_list: list[str] + :ivar inbound_inspection_certificate: inbound Inspection Certificate. + :vartype inbound_inspection_certificate: str + :ivar audit_comment: rule comment. + :vartype audit_comment: str + :ivar action_type: rule action. Known values are: "Allow", "DenySilent", "DenyResetServer", and + "DenyResetBoth". + :vartype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionEnum + :ivar enable_logging: enable or disable logging. Known values are: "DISABLED" and "ENABLED". + :vartype enable_logging: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :ivar decryption_rule_type: enable or disable decryption. Known values are: + "SSLOutboundInspection", "SSLInboundInspection", and "None". + :vartype decryption_rule_type: str or + ~azure.mgmt.paloaltonetworks.models.DecryptionRuleTypeEnum + :ivar tags: tag for rule. + :vartype tags: list[~azure.mgmt.paloaltonetworks.models.TagInfo] + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "rule_name": {"required": True}, + "priority": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "etag": {"key": "properties.etag", "type": "str"}, + "rule_name": {"key": "properties.ruleName", "type": "str"}, + "priority": {"key": "properties.priority", "type": "int"}, + "description": {"key": "properties.description", "type": "str"}, + "rule_state": {"key": "properties.ruleState", "type": "str"}, + "source": {"key": "properties.source", "type": "SourceAddr"}, + "negate_source": {"key": "properties.negateSource", "type": "str"}, + "destination": {"key": "properties.destination", "type": "DestinationAddr"}, + "negate_destination": {"key": "properties.negateDestination", "type": "str"}, + "applications": {"key": "properties.applications", "type": "[str]"}, + "category": {"key": "properties.category", "type": "Category"}, + "protocol": {"key": "properties.protocol", "type": "str"}, + "protocol_port_list": {"key": "properties.protocolPortList", "type": "[str]"}, + "inbound_inspection_certificate": {"key": "properties.inboundInspectionCertificate", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "action_type": {"key": "properties.actionType", "type": "str"}, + "enable_logging": {"key": "properties.enableLogging", "type": "str"}, + "decryption_rule_type": {"key": "properties.decryptionRuleType", "type": "str"}, + "tags": {"key": "properties.tags", "type": "[TagInfo]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + rule_name: str, + etag: Optional[str] = None, + description: Optional[str] = None, + rule_state: Optional[Union[str, "_models.StateEnum"]] = None, + source: Optional["_models.SourceAddr"] = None, + negate_source: Optional[Union[str, "_models.BooleanEnum"]] = None, + destination: Optional["_models.DestinationAddr"] = None, + negate_destination: Optional[Union[str, "_models.BooleanEnum"]] = None, + applications: Optional[List[str]] = None, + category: Optional["_models.Category"] = None, + protocol: str = "application-default", + protocol_port_list: Optional[List[str]] = None, + inbound_inspection_certificate: Optional[str] = None, + audit_comment: Optional[str] = None, + action_type: Optional[Union[str, "_models.ActionEnum"]] = None, + enable_logging: Optional[Union[str, "_models.StateEnum"]] = None, + decryption_rule_type: Optional[Union[str, "_models.DecryptionRuleTypeEnum"]] = None, + tags: Optional[List["_models.TagInfo"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword etag: etag info. + :paramtype etag: str + :keyword rule_name: rule name. Required. + :paramtype rule_name: str + :keyword description: rule description. + :paramtype description: str + :keyword rule_state: state of this rule. Known values are: "DISABLED" and "ENABLED". + :paramtype rule_state: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :keyword source: source address. + :paramtype source: ~azure.mgmt.paloaltonetworks.models.SourceAddr + :keyword negate_source: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :paramtype negate_source: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword destination: destination address. + :paramtype destination: ~azure.mgmt.paloaltonetworks.models.DestinationAddr + :keyword negate_destination: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :paramtype negate_destination: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword applications: array of rule applications. + :paramtype applications: list[str] + :keyword category: rule category. + :paramtype category: ~azure.mgmt.paloaltonetworks.models.Category + :keyword protocol: any, application-default, TCP:number, UDP:number. + :paramtype protocol: str + :keyword protocol_port_list: prot port list. + :paramtype protocol_port_list: list[str] + :keyword inbound_inspection_certificate: inbound Inspection Certificate. + :paramtype inbound_inspection_certificate: str + :keyword audit_comment: rule comment. + :paramtype audit_comment: str + :keyword action_type: rule action. Known values are: "Allow", "DenySilent", "DenyResetServer", + and "DenyResetBoth". + :paramtype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionEnum + :keyword enable_logging: enable or disable logging. Known values are: "DISABLED" and "ENABLED". + :paramtype enable_logging: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :keyword decryption_rule_type: enable or disable decryption. Known values are: + "SSLOutboundInspection", "SSLInboundInspection", and "None". + :paramtype decryption_rule_type: str or + ~azure.mgmt.paloaltonetworks.models.DecryptionRuleTypeEnum + :keyword tags: tag for rule. + :paramtype tags: list[~azure.mgmt.paloaltonetworks.models.TagInfo] + """ + super().__init__(**kwargs) + self.etag = etag + self.rule_name = rule_name + self.priority = None + self.description = description + self.rule_state = rule_state + self.source = source + self.negate_source = negate_source + self.destination = destination + self.negate_destination = negate_destination + self.applications = applications + self.category = category + self.protocol = protocol + self.protocol_port_list = protocol_port_list + self.inbound_inspection_certificate = inbound_inspection_certificate + self.audit_comment = audit_comment + self.action_type = action_type + self.enable_logging = enable_logging + self.decryption_rule_type = decryption_rule_type + self.tags = tags + self.provisioning_state = None + + +class PostRulesResourceListResult(_serialization.Model): + """The response of a PostRulesResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PostRulesResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.PostRulesResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PredefinedUrlCategoriesResponse(_serialization.Model): + """predefined url categories response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: predefined url categories. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.PredefinedUrlCategory] + :ivar next_link: next link. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PredefinedUrlCategory]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.PredefinedUrlCategory"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: predefined url categories. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.PredefinedUrlCategory] + :keyword next_link: next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PredefinedUrlCategory(_serialization.Model): + """Predefined URL category object. + + All required parameters must be populated in order to send to Azure. + + :ivar action: Required. + :vartype action: str + :ivar name: Required. + :vartype name: str + """ + + _validation = { + "action": {"required": True}, + "name": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, action: str, name: str, **kwargs: Any) -> None: + """ + :keyword action: Required. + :paramtype action: str + :keyword name: Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.action = action + self.name = name + + +class PrefixListGlobalRulestackResource(ProxyResource): + """GlobalRulestack prefixList. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar description: prefix description. + :vartype description: str + :ivar prefix_list: prefix list. Required. + :vartype prefix_list: list[str] + :ivar etag: etag info. + :vartype etag: str + :ivar audit_comment: comment for this object. + :vartype audit_comment: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "prefix_list": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "prefix_list": {"key": "properties.prefixList", "type": "[str]"}, + "etag": {"key": "properties.etag", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + prefix_list: List[str], + description: Optional[str] = None, + etag: Optional[str] = None, + audit_comment: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: prefix description. + :paramtype description: str + :keyword prefix_list: prefix list. Required. + :paramtype prefix_list: list[str] + :keyword etag: etag info. + :paramtype etag: str + :keyword audit_comment: comment for this object. + :paramtype audit_comment: str + """ + super().__init__(**kwargs) + self.description = description + self.prefix_list = prefix_list + self.etag = etag + self.audit_comment = audit_comment + self.provisioning_state = None + + +class PrefixListGlobalRulestackResourceListResult(_serialization.Model): + """The response of a PrefixListGlobalRulestackResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrefixListGlobalRulestackResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: List["_models.PrefixListGlobalRulestackResource"], + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrefixListResource(ProxyResource): + """LocalRulestack prefixList. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar description: prefix description. + :vartype description: str + :ivar prefix_list: prefix list. Required. + :vartype prefix_list: list[str] + :ivar etag: etag info. + :vartype etag: str + :ivar audit_comment: comment for this object. + :vartype audit_comment: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "prefix_list": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "prefix_list": {"key": "properties.prefixList", "type": "[str]"}, + "etag": {"key": "properties.etag", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + prefix_list: List[str], + description: Optional[str] = None, + etag: Optional[str] = None, + audit_comment: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: prefix description. + :paramtype description: str + :keyword prefix_list: prefix list. Required. + :paramtype prefix_list: list[str] + :keyword etag: etag info. + :paramtype etag: str + :keyword audit_comment: comment for this object. + :paramtype audit_comment: str + """ + super().__init__(**kwargs) + self.description = description + self.prefix_list = prefix_list + self.etag = etag + self.audit_comment = audit_comment + self.provisioning_state = None + + +class PrefixListResourceListResult(_serialization.Model): + """The response of a PrefixListResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrefixListResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.PrefixListResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PreRulesResource(ProxyResource): # pylint: disable=too-many-instance-attributes + """PreRulestack rule list. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.paloaltonetworks.models.SystemData + :ivar etag: etag info. + :vartype etag: str + :ivar rule_name: rule name. Required. + :vartype rule_name: str + :ivar priority: + :vartype priority: int + :ivar description: rule description. + :vartype description: str + :ivar rule_state: state of this rule. Known values are: "DISABLED" and "ENABLED". + :vartype rule_state: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :ivar source: source address. + :vartype source: ~azure.mgmt.paloaltonetworks.models.SourceAddr + :ivar negate_source: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :vartype negate_source: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar destination: destination address. + :vartype destination: ~azure.mgmt.paloaltonetworks.models.DestinationAddr + :ivar negate_destination: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :vartype negate_destination: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar applications: array of rule applications. + :vartype applications: list[str] + :ivar category: rule category. + :vartype category: ~azure.mgmt.paloaltonetworks.models.Category + :ivar protocol: any, application-default, TCP:number, UDP:number. + :vartype protocol: str + :ivar protocol_port_list: prot port list. + :vartype protocol_port_list: list[str] + :ivar inbound_inspection_certificate: inbound Inspection Certificate. + :vartype inbound_inspection_certificate: str + :ivar audit_comment: rule comment. + :vartype audit_comment: str + :ivar action_type: rule action. Known values are: "Allow", "DenySilent", "DenyResetServer", and + "DenyResetBoth". + :vartype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionEnum + :ivar enable_logging: enable or disable logging. Known values are: "DISABLED" and "ENABLED". + :vartype enable_logging: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :ivar decryption_rule_type: enable or disable decryption. Known values are: + "SSLOutboundInspection", "SSLInboundInspection", and "None". + :vartype decryption_rule_type: str or + ~azure.mgmt.paloaltonetworks.models.DecryptionRuleTypeEnum + :ivar tags: tag for rule. + :vartype tags: list[~azure.mgmt.paloaltonetworks.models.TagInfo] + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.paloaltonetworks.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "rule_name": {"required": True}, + "priority": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "etag": {"key": "properties.etag", "type": "str"}, + "rule_name": {"key": "properties.ruleName", "type": "str"}, + "priority": {"key": "properties.priority", "type": "int"}, + "description": {"key": "properties.description", "type": "str"}, + "rule_state": {"key": "properties.ruleState", "type": "str"}, + "source": {"key": "properties.source", "type": "SourceAddr"}, + "negate_source": {"key": "properties.negateSource", "type": "str"}, + "destination": {"key": "properties.destination", "type": "DestinationAddr"}, + "negate_destination": {"key": "properties.negateDestination", "type": "str"}, + "applications": {"key": "properties.applications", "type": "[str]"}, + "category": {"key": "properties.category", "type": "Category"}, + "protocol": {"key": "properties.protocol", "type": "str"}, + "protocol_port_list": {"key": "properties.protocolPortList", "type": "[str]"}, + "inbound_inspection_certificate": {"key": "properties.inboundInspectionCertificate", "type": "str"}, + "audit_comment": {"key": "properties.auditComment", "type": "str"}, + "action_type": {"key": "properties.actionType", "type": "str"}, + "enable_logging": {"key": "properties.enableLogging", "type": "str"}, + "decryption_rule_type": {"key": "properties.decryptionRuleType", "type": "str"}, + "tags": {"key": "properties.tags", "type": "[TagInfo]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + rule_name: str, + etag: Optional[str] = None, + description: Optional[str] = None, + rule_state: Optional[Union[str, "_models.StateEnum"]] = None, + source: Optional["_models.SourceAddr"] = None, + negate_source: Optional[Union[str, "_models.BooleanEnum"]] = None, + destination: Optional["_models.DestinationAddr"] = None, + negate_destination: Optional[Union[str, "_models.BooleanEnum"]] = None, + applications: Optional[List[str]] = None, + category: Optional["_models.Category"] = None, + protocol: str = "application-default", + protocol_port_list: Optional[List[str]] = None, + inbound_inspection_certificate: Optional[str] = None, + audit_comment: Optional[str] = None, + action_type: Optional[Union[str, "_models.ActionEnum"]] = None, + enable_logging: Optional[Union[str, "_models.StateEnum"]] = None, + decryption_rule_type: Optional[Union[str, "_models.DecryptionRuleTypeEnum"]] = None, + tags: Optional[List["_models.TagInfo"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword etag: etag info. + :paramtype etag: str + :keyword rule_name: rule name. Required. + :paramtype rule_name: str + :keyword description: rule description. + :paramtype description: str + :keyword rule_state: state of this rule. Known values are: "DISABLED" and "ENABLED". + :paramtype rule_state: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :keyword source: source address. + :paramtype source: ~azure.mgmt.paloaltonetworks.models.SourceAddr + :keyword negate_source: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :paramtype negate_source: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword destination: destination address. + :paramtype destination: ~azure.mgmt.paloaltonetworks.models.DestinationAddr + :keyword negate_destination: cidr should not be 'any'. Known values are: "TRUE" and "FALSE". + :paramtype negate_destination: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword applications: array of rule applications. + :paramtype applications: list[str] + :keyword category: rule category. + :paramtype category: ~azure.mgmt.paloaltonetworks.models.Category + :keyword protocol: any, application-default, TCP:number, UDP:number. + :paramtype protocol: str + :keyword protocol_port_list: prot port list. + :paramtype protocol_port_list: list[str] + :keyword inbound_inspection_certificate: inbound Inspection Certificate. + :paramtype inbound_inspection_certificate: str + :keyword audit_comment: rule comment. + :paramtype audit_comment: str + :keyword action_type: rule action. Known values are: "Allow", "DenySilent", "DenyResetServer", + and "DenyResetBoth". + :paramtype action_type: str or ~azure.mgmt.paloaltonetworks.models.ActionEnum + :keyword enable_logging: enable or disable logging. Known values are: "DISABLED" and "ENABLED". + :paramtype enable_logging: str or ~azure.mgmt.paloaltonetworks.models.StateEnum + :keyword decryption_rule_type: enable or disable decryption. Known values are: + "SSLOutboundInspection", "SSLInboundInspection", and "None". + :paramtype decryption_rule_type: str or + ~azure.mgmt.paloaltonetworks.models.DecryptionRuleTypeEnum + :keyword tags: tag for rule. + :paramtype tags: list[~azure.mgmt.paloaltonetworks.models.TagInfo] + """ + super().__init__(**kwargs) + self.etag = etag + self.rule_name = rule_name + self.priority = None + self.description = description + self.rule_state = rule_state + self.source = source + self.negate_source = negate_source + self.destination = destination + self.negate_destination = negate_destination + self.applications = applications + self.category = category + self.protocol = protocol + self.protocol_port_list = protocol_port_list + self.inbound_inspection_certificate = inbound_inspection_certificate + self.audit_comment = audit_comment + self.action_type = action_type + self.enable_logging = enable_logging + self.decryption_rule_type = decryption_rule_type + self.tags = tags + self.provisioning_state = None + + +class PreRulesResourceListResult(_serialization.Model): + """The response of a PreRulesResource list operation. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The items on this page. Required. + :vartype value: list[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PreRulesResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.PreRulesResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The items on this page. Required. + :paramtype value: list[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RuleCounter(_serialization.Model): + """Rule counter. + + All required parameters must be populated in order to send to Azure. + + :ivar priority: priority number. Required. + :vartype priority: str + :ivar rule_stack_name: rule Stack Name. + :vartype rule_stack_name: str + :ivar rule_list_name: rule list name. + :vartype rule_list_name: str + :ivar firewall_name: firewall name. + :vartype firewall_name: str + :ivar rule_name: rule name. Required. + :vartype rule_name: str + :ivar hit_count: hit count. + :vartype hit_count: int + :ivar app_seen: apps seen. + :vartype app_seen: ~azure.mgmt.paloaltonetworks.models.AppSeenData + :ivar timestamp: timestamp of response. + :vartype timestamp: ~datetime.datetime + :ivar request_timestamp: timestamp of request. + :vartype request_timestamp: ~datetime.datetime + :ivar last_updated_timestamp: last updated timestamp. + :vartype last_updated_timestamp: ~datetime.datetime + """ + + _validation = { + "priority": {"required": True}, + "rule_name": {"required": True}, + } + + _attribute_map = { + "priority": {"key": "priority", "type": "str"}, + "rule_stack_name": {"key": "ruleStackName", "type": "str"}, + "rule_list_name": {"key": "ruleListName", "type": "str"}, + "firewall_name": {"key": "firewallName", "type": "str"}, + "rule_name": {"key": "ruleName", "type": "str"}, + "hit_count": {"key": "hitCount", "type": "int"}, + "app_seen": {"key": "appSeen", "type": "AppSeenData"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "request_timestamp": {"key": "requestTimestamp", "type": "iso-8601"}, + "last_updated_timestamp": {"key": "lastUpdatedTimestamp", "type": "iso-8601"}, + } + + def __init__( + self, + *, + priority: str, + rule_name: str, + rule_stack_name: Optional[str] = None, + rule_list_name: Optional[str] = None, + firewall_name: Optional[str] = None, + hit_count: Optional[int] = None, + app_seen: Optional["_models.AppSeenData"] = None, + timestamp: Optional[datetime.datetime] = None, + request_timestamp: Optional[datetime.datetime] = None, + last_updated_timestamp: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword priority: priority number. Required. + :paramtype priority: str + :keyword rule_stack_name: rule Stack Name. + :paramtype rule_stack_name: str + :keyword rule_list_name: rule list name. + :paramtype rule_list_name: str + :keyword firewall_name: firewall name. + :paramtype firewall_name: str + :keyword rule_name: rule name. Required. + :paramtype rule_name: str + :keyword hit_count: hit count. + :paramtype hit_count: int + :keyword app_seen: apps seen. + :paramtype app_seen: ~azure.mgmt.paloaltonetworks.models.AppSeenData + :keyword timestamp: timestamp of response. + :paramtype timestamp: ~datetime.datetime + :keyword request_timestamp: timestamp of request. + :paramtype request_timestamp: ~datetime.datetime + :keyword last_updated_timestamp: last updated timestamp. + :paramtype last_updated_timestamp: ~datetime.datetime + """ + super().__init__(**kwargs) + self.priority = priority + self.rule_stack_name = rule_stack_name + self.rule_list_name = rule_list_name + self.firewall_name = firewall_name + self.rule_name = rule_name + self.hit_count = hit_count + self.app_seen = app_seen + self.timestamp = timestamp + self.request_timestamp = request_timestamp + self.last_updated_timestamp = last_updated_timestamp + + +class RuleCounterReset(_serialization.Model): + """Rule counter reset. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar priority: priority number. + :vartype priority: str + :ivar rule_stack_name: rule Stack Name. + :vartype rule_stack_name: str + :ivar rule_list_name: rule list name. + :vartype rule_list_name: str + :ivar firewall_name: firewall name. + :vartype firewall_name: str + :ivar rule_name: rule name. + :vartype rule_name: str + """ + + _validation = { + "priority": {"readonly": True}, + } + + _attribute_map = { + "priority": {"key": "priority", "type": "str"}, + "rule_stack_name": {"key": "ruleStackName", "type": "str"}, + "rule_list_name": {"key": "ruleListName", "type": "str"}, + "firewall_name": {"key": "firewallName", "type": "str"}, + "rule_name": {"key": "ruleName", "type": "str"}, + } + + def __init__( + self, + *, + rule_stack_name: Optional[str] = None, + rule_list_name: Optional[str] = None, + firewall_name: Optional[str] = None, + rule_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword rule_stack_name: rule Stack Name. + :paramtype rule_stack_name: str + :keyword rule_list_name: rule list name. + :paramtype rule_list_name: str + :keyword firewall_name: firewall name. + :paramtype firewall_name: str + :keyword rule_name: rule name. + :paramtype rule_name: str + """ + super().__init__(**kwargs) + self.priority = None + self.rule_stack_name = rule_stack_name + self.rule_list_name = rule_list_name + self.firewall_name = firewall_name + self.rule_name = rule_name + + +class RulestackDetails(_serialization.Model): + """Associated rulestack details. + + :ivar resource_id: Resource Id. + :vartype resource_id: str + :ivar rulestack_id: Associated rulestack Id. + :vartype rulestack_id: str + :ivar location: Rulestack location. + :vartype location: str + """ + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "rulestack_id": {"key": "rulestackId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + resource_id: Optional[str] = None, + rulestack_id: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_id: Resource Id. + :paramtype resource_id: str + :keyword rulestack_id: Associated rulestack Id. + :paramtype rulestack_id: str + :keyword location: Rulestack location. + :paramtype location: str + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.rulestack_id = rulestack_id + self.location = location + + +class SecurityServices(_serialization.Model): + """security services. + + :ivar vulnerability_profile: IPs Vulnerability Profile Data. + :vartype vulnerability_profile: str + :ivar anti_spyware_profile: Anti spyware Profile data. + :vartype anti_spyware_profile: str + :ivar anti_virus_profile: anti virus profile data. + :vartype anti_virus_profile: str + :ivar url_filtering_profile: URL filtering profile data. + :vartype url_filtering_profile: str + :ivar file_blocking_profile: File blocking profile data. + :vartype file_blocking_profile: str + :ivar dns_subscription: DNS Subscription profile data. + :vartype dns_subscription: str + :ivar outbound_un_trust_certificate: Untrusted Egress Decryption profile data. + :vartype outbound_un_trust_certificate: str + :ivar outbound_trust_certificate: Trusted Egress Decryption profile data. + :vartype outbound_trust_certificate: str + """ + + _attribute_map = { + "vulnerability_profile": {"key": "vulnerabilityProfile", "type": "str"}, + "anti_spyware_profile": {"key": "antiSpywareProfile", "type": "str"}, + "anti_virus_profile": {"key": "antiVirusProfile", "type": "str"}, + "url_filtering_profile": {"key": "urlFilteringProfile", "type": "str"}, + "file_blocking_profile": {"key": "fileBlockingProfile", "type": "str"}, + "dns_subscription": {"key": "dnsSubscription", "type": "str"}, + "outbound_un_trust_certificate": {"key": "outboundUnTrustCertificate", "type": "str"}, + "outbound_trust_certificate": {"key": "outboundTrustCertificate", "type": "str"}, + } + + def __init__( + self, + *, + vulnerability_profile: Optional[str] = None, + anti_spyware_profile: Optional[str] = None, + anti_virus_profile: Optional[str] = None, + url_filtering_profile: Optional[str] = None, + file_blocking_profile: Optional[str] = None, + dns_subscription: Optional[str] = None, + outbound_un_trust_certificate: Optional[str] = None, + outbound_trust_certificate: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword vulnerability_profile: IPs Vulnerability Profile Data. + :paramtype vulnerability_profile: str + :keyword anti_spyware_profile: Anti spyware Profile data. + :paramtype anti_spyware_profile: str + :keyword anti_virus_profile: anti virus profile data. + :paramtype anti_virus_profile: str + :keyword url_filtering_profile: URL filtering profile data. + :paramtype url_filtering_profile: str + :keyword file_blocking_profile: File blocking profile data. + :paramtype file_blocking_profile: str + :keyword dns_subscription: DNS Subscription profile data. + :paramtype dns_subscription: str + :keyword outbound_un_trust_certificate: Untrusted Egress Decryption profile data. + :paramtype outbound_un_trust_certificate: str + :keyword outbound_trust_certificate: Trusted Egress Decryption profile data. + :paramtype outbound_trust_certificate: str + """ + super().__init__(**kwargs) + self.vulnerability_profile = vulnerability_profile + self.anti_spyware_profile = anti_spyware_profile + self.anti_virus_profile = anti_virus_profile + self.url_filtering_profile = url_filtering_profile + self.file_blocking_profile = file_blocking_profile + self.dns_subscription = dns_subscription + self.outbound_un_trust_certificate = outbound_un_trust_certificate + self.outbound_trust_certificate = outbound_trust_certificate + + +class SecurityServicesResponse(_serialization.Model): + """Security services list response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: response value. Required. + :vartype value: ~azure.mgmt.paloaltonetworks.models.SecurityServicesTypeList + :ivar next_link: next link. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "SecurityServicesTypeList"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: "_models.SecurityServicesTypeList", next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: response value. Required. + :paramtype value: ~azure.mgmt.paloaltonetworks.models.SecurityServicesTypeList + :keyword next_link: next link. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SecurityServicesTypeList(_serialization.Model): + """Security services type list. + + All required parameters must be populated in order to send to Azure. + + :ivar type: security services type. + :vartype type: str + :ivar entry: list. Required. + :vartype entry: list[~azure.mgmt.paloaltonetworks.models.NameDescriptionObject] + """ + + _validation = { + "entry": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "entry": {"key": "entry", "type": "[NameDescriptionObject]"}, + } + + def __init__( + self, *, entry: List["_models.NameDescriptionObject"], type: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword type: security services type. + :paramtype type: str + :keyword entry: list. Required. + :paramtype entry: list[~azure.mgmt.paloaltonetworks.models.NameDescriptionObject] + """ + super().__init__(**kwargs) + self.type = type + self.entry = entry + + +class SourceAddr(_serialization.Model): + """Address properties. + + :ivar cidrs: special value 'any'. + :vartype cidrs: list[str] + :ivar countries: list of countries. + :vartype countries: list[str] + :ivar feeds: list of feeds. + :vartype feeds: list[str] + :ivar prefix_lists: prefix list. + :vartype prefix_lists: list[str] + """ + + _attribute_map = { + "cidrs": {"key": "cidrs", "type": "[str]"}, + "countries": {"key": "countries", "type": "[str]"}, + "feeds": {"key": "feeds", "type": "[str]"}, + "prefix_lists": {"key": "prefixLists", "type": "[str]"}, + } + + def __init__( + self, + *, + cidrs: Optional[List[str]] = None, + countries: Optional[List[str]] = None, + feeds: Optional[List[str]] = None, + prefix_lists: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword cidrs: special value 'any'. + :paramtype cidrs: list[str] + :keyword countries: list of countries. + :paramtype countries: list[str] + :keyword feeds: list of feeds. + :paramtype feeds: list[str] + :keyword prefix_lists: prefix list. + :paramtype prefix_lists: list[str] + """ + super().__init__(**kwargs) + self.cidrs = cidrs + self.countries = countries + self.feeds = feeds + self.prefix_lists = prefix_lists + + +class StorageAccount(_serialization.Model): + """Storage Account configurations. + + :ivar id: Resource ID of storage account. + :vartype id: str + :ivar subscription_id: Subscription Id. + :vartype subscription_id: str + :ivar account_name: Storage account name. + :vartype account_name: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + subscription_id: Optional[str] = None, + account_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource ID of storage account. + :paramtype id: str + :keyword subscription_id: Subscription Id. + :paramtype subscription_id: str + :keyword account_name: Storage account name. + :paramtype account_name: str + """ + super().__init__(**kwargs) + self.id = id + self.subscription_id = subscription_id + self.account_name = account_name + + +class SupportInfo(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Support information for the resource. + + :ivar product_sku: product SKU associated with given resource. + :vartype product_sku: str + :ivar product_serial: product Serial associated with given resource. + :vartype product_serial: str + :ivar account_registered: account registered in Customer Support Portal. Known values are: + "TRUE" and "FALSE". + :vartype account_registered: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar account_id: Support account associated with given resource. + :vartype account_id: str + :ivar user_domain_supported: user domain is supported in Customer Support Portal. Known values + are: "TRUE" and "FALSE". + :vartype user_domain_supported: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar user_registered: user registered in Customer Support Portal. Known values are: "TRUE" and + "FALSE". + :vartype user_registered: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar free_trial: Product usage is in free trial period. Known values are: "TRUE" and "FALSE". + :vartype free_trial: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :ivar free_trial_days_left: Free trial days remaining. + :vartype free_trial_days_left: int + :ivar free_trial_credit_left: Free trial credit remaining. + :vartype free_trial_credit_left: int + :ivar help_url: URL for paloaltonetworks live community. + :vartype help_url: str + :ivar support_url: URL for paloaltonetworks Customer Service Portal. + :vartype support_url: str + :ivar register_url: URL for registering product in paloaltonetworks Customer Service Portal. + :vartype register_url: str + """ + + _attribute_map = { + "product_sku": {"key": "productSku", "type": "str"}, + "product_serial": {"key": "productSerial", "type": "str"}, + "account_registered": {"key": "accountRegistered", "type": "str"}, + "account_id": {"key": "accountId", "type": "str"}, + "user_domain_supported": {"key": "userDomainSupported", "type": "str"}, + "user_registered": {"key": "userRegistered", "type": "str"}, + "free_trial": {"key": "freeTrial", "type": "str"}, + "free_trial_days_left": {"key": "freeTrialDaysLeft", "type": "int"}, + "free_trial_credit_left": {"key": "freeTrialCreditLeft", "type": "int"}, + "help_url": {"key": "helpURL", "type": "str"}, + "support_url": {"key": "supportURL", "type": "str"}, + "register_url": {"key": "registerURL", "type": "str"}, + } + + def __init__( + self, + *, + product_sku: Optional[str] = None, + product_serial: Optional[str] = None, + account_registered: Optional[Union[str, "_models.BooleanEnum"]] = None, + account_id: Optional[str] = None, + user_domain_supported: Optional[Union[str, "_models.BooleanEnum"]] = None, + user_registered: Optional[Union[str, "_models.BooleanEnum"]] = None, + free_trial: Optional[Union[str, "_models.BooleanEnum"]] = None, + free_trial_days_left: Optional[int] = None, + free_trial_credit_left: Optional[int] = None, + help_url: Optional[str] = None, + support_url: Optional[str] = None, + register_url: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword product_sku: product SKU associated with given resource. + :paramtype product_sku: str + :keyword product_serial: product Serial associated with given resource. + :paramtype product_serial: str + :keyword account_registered: account registered in Customer Support Portal. Known values are: + "TRUE" and "FALSE". + :paramtype account_registered: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword account_id: Support account associated with given resource. + :paramtype account_id: str + :keyword user_domain_supported: user domain is supported in Customer Support Portal. Known + values are: "TRUE" and "FALSE". + :paramtype user_domain_supported: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword user_registered: user registered in Customer Support Portal. Known values are: "TRUE" + and "FALSE". + :paramtype user_registered: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword free_trial: Product usage is in free trial period. Known values are: "TRUE" and + "FALSE". + :paramtype free_trial: str or ~azure.mgmt.paloaltonetworks.models.BooleanEnum + :keyword free_trial_days_left: Free trial days remaining. + :paramtype free_trial_days_left: int + :keyword free_trial_credit_left: Free trial credit remaining. + :paramtype free_trial_credit_left: int + :keyword help_url: URL for paloaltonetworks live community. + :paramtype help_url: str + :keyword support_url: URL for paloaltonetworks Customer Service Portal. + :paramtype support_url: str + :keyword register_url: URL for registering product in paloaltonetworks Customer Service Portal. + :paramtype register_url: str + """ + super().__init__(**kwargs) + self.product_sku = product_sku + self.product_serial = product_serial + self.account_registered = account_registered + self.account_id = account_id + self.user_domain_supported = user_domain_supported + self.user_registered = user_registered + self.free_trial = free_trial + self.free_trial_days_left = free_trial_days_left + self.free_trial_credit_left = free_trial_credit_left + self.help_url = help_url + self.support_url = support_url + self.register_url = register_url + + +class SystemData(_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. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.paloaltonetworks.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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.paloaltonetworks.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _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"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :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. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.paloaltonetworks.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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.paloaltonetworks.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__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 + self.last_modified_at = last_modified_at + + +class TagInfo(_serialization.Model): + """Tag. + + All required parameters must be populated in order to send to Azure. + + :ivar key: tag name. Required. + :vartype key: str + :ivar value: tag value. Required. + :vartype value: str + """ + + _validation = { + "key": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, key: str, value: str, **kwargs: Any) -> None: + """ + :keyword key: tag name. Required. + :paramtype key: str + :keyword value: tag value. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.key = key + self.value = value + + +class VnetConfiguration(_serialization.Model): + """VnetInfo for Firewall Networking. + + All required parameters must be populated in order to send to Azure. + + :ivar vnet: Azure Virtual Network. Required. + :vartype vnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :ivar trust_subnet: Trust Subnet. Required. + :vartype trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :ivar un_trust_subnet: Untrust Subnet. Required. + :vartype un_trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :ivar ip_of_trust_subnet_for_udr: IP of trust subnet for UDR. + :vartype ip_of_trust_subnet_for_udr: ~azure.mgmt.paloaltonetworks.models.IPAddress + """ + + _validation = { + "vnet": {"required": True}, + "trust_subnet": {"required": True}, + "un_trust_subnet": {"required": True}, + } + + _attribute_map = { + "vnet": {"key": "vnet", "type": "IPAddressSpace"}, + "trust_subnet": {"key": "trustSubnet", "type": "IPAddressSpace"}, + "un_trust_subnet": {"key": "unTrustSubnet", "type": "IPAddressSpace"}, + "ip_of_trust_subnet_for_udr": {"key": "ipOfTrustSubnetForUdr", "type": "IPAddress"}, + } + + def __init__( + self, + *, + vnet: "_models.IPAddressSpace", + trust_subnet: "_models.IPAddressSpace", + un_trust_subnet: "_models.IPAddressSpace", + ip_of_trust_subnet_for_udr: Optional["_models.IPAddress"] = None, + **kwargs: Any + ) -> None: + """ + :keyword vnet: Azure Virtual Network. Required. + :paramtype vnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :keyword trust_subnet: Trust Subnet. Required. + :paramtype trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :keyword un_trust_subnet: Untrust Subnet. Required. + :paramtype un_trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :keyword ip_of_trust_subnet_for_udr: IP of trust subnet for UDR. + :paramtype ip_of_trust_subnet_for_udr: ~azure.mgmt.paloaltonetworks.models.IPAddress + """ + super().__init__(**kwargs) + self.vnet = vnet + self.trust_subnet = trust_subnet + self.un_trust_subnet = un_trust_subnet + self.ip_of_trust_subnet_for_udr = ip_of_trust_subnet_for_udr + + +class VwanConfiguration(_serialization.Model): + """VwanInfo for Firewall Networking. + + All required parameters must be populated in order to send to Azure. + + :ivar network_virtual_appliance_id: Network Virtual Appliance resource ID. + :vartype network_virtual_appliance_id: str + :ivar v_hub: vHub Address. Required. + :vartype v_hub: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :ivar trust_subnet: Trust Subnet. + :vartype trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :ivar un_trust_subnet: Untrust Subnet. + :vartype un_trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :ivar ip_of_trust_subnet_for_udr: IP of trust subnet for UDR. + :vartype ip_of_trust_subnet_for_udr: ~azure.mgmt.paloaltonetworks.models.IPAddress + """ + + _validation = { + "v_hub": {"required": True}, + } + + _attribute_map = { + "network_virtual_appliance_id": {"key": "networkVirtualApplianceId", "type": "str"}, + "v_hub": {"key": "vHub", "type": "IPAddressSpace"}, + "trust_subnet": {"key": "trustSubnet", "type": "IPAddressSpace"}, + "un_trust_subnet": {"key": "unTrustSubnet", "type": "IPAddressSpace"}, + "ip_of_trust_subnet_for_udr": {"key": "ipOfTrustSubnetForUdr", "type": "IPAddress"}, + } + + def __init__( + self, + *, + v_hub: "_models.IPAddressSpace", + network_virtual_appliance_id: Optional[str] = None, + trust_subnet: Optional["_models.IPAddressSpace"] = None, + un_trust_subnet: Optional["_models.IPAddressSpace"] = None, + ip_of_trust_subnet_for_udr: Optional["_models.IPAddress"] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_virtual_appliance_id: Network Virtual Appliance resource ID. + :paramtype network_virtual_appliance_id: str + :keyword v_hub: vHub Address. Required. + :paramtype v_hub: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :keyword trust_subnet: Trust Subnet. + :paramtype trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :keyword un_trust_subnet: Untrust Subnet. + :paramtype un_trust_subnet: ~azure.mgmt.paloaltonetworks.models.IPAddressSpace + :keyword ip_of_trust_subnet_for_udr: IP of trust subnet for UDR. + :paramtype ip_of_trust_subnet_for_udr: ~azure.mgmt.paloaltonetworks.models.IPAddress + """ + super().__init__(**kwargs) + self.network_virtual_appliance_id = network_virtual_appliance_id + self.v_hub = v_hub + self.trust_subnet = trust_subnet + self.un_trust_subnet = un_trust_subnet + self.ip_of_trust_subnet_for_udr = ip_of_trust_subnet_for_udr diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_palo_alto_networks_ngfw_mgmt_client_enums.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_palo_alto_networks_ngfw_mgmt_client_enums.py new file mode 100644 index 000000000000..58b34d11f1ad --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_palo_alto_networks_ngfw_mgmt_client_enums.py @@ -0,0 +1,200 @@ +# 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 azure.core import CaseInsensitiveEnumMeta + + +class ActionEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ActionEnum.""" + + ALLOW = "Allow" + DENY_SILENT = "DenySilent" + DENY_RESET_SERVER = "DenyResetServer" + DENY_RESET_BOTH = "DenyResetBoth" + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class AdvSecurityObjectTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AdvSecurityObjectTypeEnum.""" + + URL_CUSTOM = "urlCustom" + FEEDS = "feeds" + + +class BillingCycle(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Billing cycle.""" + + WEEKLY = "WEEKLY" + MONTHLY = "MONTHLY" + + +class BooleanEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Boolean Enum.""" + + TRUE = "TRUE" + FALSE = "FALSE" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DecryptionRuleTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DecryptionRuleTypeEnum.""" + + SSL_OUTBOUND_INSPECTION = "SSLOutboundInspection" + SSL_INBOUND_INSPECTION = "SSLInboundInspection" + NONE = "None" + + +class DefaultMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type for Default Mode for rules creation.""" + + IPS = "IPS" + FIREWALL = "FIREWALL" + NONE = "NONE" + + +class DNSProxy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DNS Proxy.""" + + DISABLED = "DISABLED" + ENABLED = "ENABLED" + + +class EgressNat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Egress NAT.""" + + DISABLED = "DISABLED" + ENABLED = "ENABLED" + + +class EnabledDNSType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enabled DNS type values.""" + + CUSTOM = "CUSTOM" + AZURE = "AZURE" + + +class LogOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Log options possible.""" + + SAME_DESTINATION = "SAME_DESTINATION" + INDIVIDUAL_DESTINATION = "INDIVIDUAL_DESTINATION" + + +class LogType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Possible log types.""" + + TRAFFIC = "TRAFFIC" + THREAT = "THREAT" + DECRYPTION = "DECRYPTION" + WILDFIRE = "WILDFIRE" + DLP = "DLP" + AUDIT = "AUDIT" + + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of managed identity assigned to this resource.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_AND_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class MarketplaceSubscriptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Marketplace Subscription Status.""" + + PENDING_FULFILLMENT_START = "PendingFulfillmentStart" + SUBSCRIBED = "Subscribed" + SUSPENDED = "Suspended" + UNSUBSCRIBED = "Unsubscribed" + NOT_STARTED = "NotStarted" + FULFILLMENT_REQUESTED = "FulfillmentRequested" + + +class NetworkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """NetworkType Enum.""" + + VNET = "VNET" + VWAN = "VWAN" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + +class ProtocolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Protocol Enum.""" + + TCP = "TCP" + UDP = "UDP" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the firewall resource.""" + + ACCEPTED = "Accepted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + NOT_SPECIFIED = "NotSpecified" + + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Rulestack Type.""" + + LOCAL = "LOCAL" + GLOBAL = "GLOBAL" + + +class SecurityServicesTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SecurityServicesTypeEnum.""" + + ANTI_SPYWARE = "antiSpyware" + ANTI_VIRUS = "antiVirus" + IPS_VULNERABILITY = "ipsVulnerability" + URL_FILTERING = "urlFiltering" + FILE_BLOCKING = "fileBlocking" + DNS_SUBSCRIPTION = "dnsSubscription" + + +class StateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enabled or Disabled Enum.""" + + DISABLED = "DISABLED" + ENABLED = "ENABLED" + + +class UsageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Usage Type.""" + + PAYG = "PAYG" + COMMITTED = "COMMITTED" diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_patch.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/__init__.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/__init__.py new file mode 100644 index 000000000000..05124829938e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/__init__.py @@ -0,0 +1,43 @@ +# 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 ._global_rulestack_operations import GlobalRulestackOperations +from ._certificate_object_global_rulestack_operations import CertificateObjectGlobalRulestackOperations +from ._fqdn_list_global_rulestack_operations import FqdnListGlobalRulestackOperations +from ._post_rules_operations import PostRulesOperations +from ._prefix_list_global_rulestack_operations import PrefixListGlobalRulestackOperations +from ._pre_rules_operations import PreRulesOperations +from ._operations import Operations +from ._firewalls_operations import FirewallsOperations +from ._local_rulestacks_operations import LocalRulestacksOperations +from ._certificate_object_local_rulestack_operations import CertificateObjectLocalRulestackOperations +from ._fqdn_list_local_rulestack_operations import FqdnListLocalRulestackOperations +from ._local_rules_operations import LocalRulesOperations +from ._prefix_list_local_rulestack_operations import PrefixListLocalRulestackOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "GlobalRulestackOperations", + "CertificateObjectGlobalRulestackOperations", + "FqdnListGlobalRulestackOperations", + "PostRulesOperations", + "PrefixListGlobalRulestackOperations", + "PreRulesOperations", + "Operations", + "FirewallsOperations", + "LocalRulestacksOperations", + "CertificateObjectLocalRulestackOperations", + "FqdnListLocalRulestackOperations", + "LocalRulesOperations", + "PrefixListLocalRulestackOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_certificate_object_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_certificate_object_global_rulestack_operations.py new file mode 100644 index 000000000000..5a31ea0a3c8c --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_certificate_object_global_rulestack_operations.py @@ -0,0 +1,661 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificateObjectGlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`certificate_object_global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, global_rulestack_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateObjectGlobalRulestackResource"]: + """List CertificateObjectGlobalRulestackResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateObjectGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("CertificateObjectGlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates"} + + @distributed_trace + def get( + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.CertificateObjectGlobalRulestackResource: + """Get a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateObjectGlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + def _create_or_update_initial( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectGlobalRulestackResource, IO], + **kwargs: Any + ) -> _models.CertificateObjectGlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "CertificateObjectGlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: _models.CertificateObjectGlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateObjectGlobalRulestackResource]: + """Create a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 CertificateObjectGlobalRulestackResource + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateObjectGlobalRulestackResource]: + """Create a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 CertificateObjectGlobalRulestackResource + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectGlobalRulestackResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CertificateObjectGlobalRulestackResource]: + """Create a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Is either a + CertificateObjectGlobalRulestackResource type or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 CertificateObjectGlobalRulestackResource + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectGlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CertificateObjectGlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } + + @distributed_trace + def begin_delete(self, global_rulestack_name: str, name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a CertificateObjectGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: certificate name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/certificates/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_certificate_object_local_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_certificate_object_local_rulestack_operations.py new file mode 100644 index 000000000000..794e553865d5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_certificate_object_local_rulestack_operations.py @@ -0,0 +1,722 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_local_rulestacks_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificateObjectLocalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`certificate_object_local_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> Iterable["_models.CertificateObjectLocalRulestackResource"]: + """List CertificateObjectLocalRulestackResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateObjectLocalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectLocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("CertificateObjectLocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates" + } + + @distributed_trace + def get( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.CertificateObjectLocalRulestackResource: + """Get a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateObjectLocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateObjectLocalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectLocalRulestackResource, IO], + **kwargs: Any + ) -> _models.CertificateObjectLocalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectLocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "CertificateObjectLocalRulestackResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: _models.CertificateObjectLocalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateObjectLocalRulestackResource]: + """Create a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 CertificateObjectLocalRulestackResource + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CertificateObjectLocalRulestackResource]: + """Create a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 CertificateObjectLocalRulestackResource + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.CertificateObjectLocalRulestackResource, IO], + **kwargs: Any + ) -> LROPoller[_models.CertificateObjectLocalRulestackResource]: + """Create a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type name: str + :param resource: Resource create parameters. Is either a + CertificateObjectLocalRulestackResource type or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 CertificateObjectLocalRulestackResource + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.CertificateObjectLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateObjectLocalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CertificateObjectLocalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a CertificateObjectLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: certificate name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/certificates/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_firewalls_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_firewalls_operations.py new file mode 100644 index 000000000000..75c9321f4034 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_firewalls_operations.py @@ -0,0 +1,1432 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/firewalls") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_global_rulestack_request( + resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getGlobalRulestack", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_log_profile_request( + resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getLogProfile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_support_info_request( + resource_group_name: str, firewall_name: str, subscription_id: str, *, email: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getSupportInfo", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if email is not None: + _params["email"] = _SERIALIZER.query("email", email, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_save_log_profile_request( + resource_group_name: str, firewall_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/saveLogProfile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "firewallName": _SERIALIZER.url("firewall_name", firewall_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class FirewallsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`firewalls` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.FirewallResource"]: + """List FirewallResource resources by subscription ID. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FirewallResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FirewallResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/firewalls" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.FirewallResource"]: + """List FirewallResource resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 FirewallResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FirewallResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls" + } + + @distributed_trace + def get(self, resource_group_name: str, firewall_name: str, **kwargs: Any) -> _models.FirewallResource: + """Get a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + def _create_or_update_initial( + self, resource_group_name: str, firewall_name: str, resource: Union[_models.FirewallResource, IO], **kwargs: Any + ) -> _models.FirewallResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "FirewallResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + firewall_name: str, + resource: _models.FirewallResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallResource]: + """Create a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 FirewallResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + firewall_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallResource]: + """Create a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 FirewallResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, firewall_name: str, resource: Union[_models.FirewallResource, IO], **kwargs: Any + ) -> LROPoller[_models.FirewallResource]: + """Create a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param resource: Resource create parameters. Is either a FirewallResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FirewallResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 FirewallResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FirewallResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("FirewallResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @overload + def update( + self, + resource_group_name: str, + firewall_name: str, + properties: _models.FirewallResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallResource: + """Update a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.FirewallResourceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + firewall_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallResource: + """Update a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + firewall_name: str, + properties: Union[_models.FirewallResourceUpdate, IO], + **kwargs: Any + ) -> _models.FirewallResource: + """Update a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param properties: The resource properties to be updated. Is either a FirewallResourceUpdate + type or a IO type. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.FirewallResourceUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FirewallResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "FirewallResourceUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FirewallResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, firewall_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, firewall_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a FirewallResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + firewall_name=firewall_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}" + } + + @distributed_trace + def get_global_rulestack( + self, resource_group_name: str, firewall_name: str, **kwargs: Any + ) -> _models.GlobalRulestackInfo: + """Get Global Rulestack associated with the Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackInfo or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalRulestackInfo] = kwargs.pop("cls", None) + + request = build_get_global_rulestack_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_global_rulestack.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GlobalRulestackInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_global_rulestack.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getGlobalRulestack" + } + + @distributed_trace + def get_log_profile(self, resource_group_name: str, firewall_name: str, **kwargs: Any) -> _models.LogSettings: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogSettings or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LogSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LogSettings] = kwargs.pop("cls", None) + + request = build_get_log_profile_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_log_profile.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_log_profile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getLogProfile" + } + + @distributed_trace + def get_support_info( + self, resource_group_name: str, firewall_name: str, email: Optional[str] = None, **kwargs: Any + ) -> _models.SupportInfo: + """support info for firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param email: email address on behalf of which this API called. Default value is None. + :type email: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportInfo or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SupportInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SupportInfo] = kwargs.pop("cls", None) + + request = build_get_support_info_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + email=email, + api_version=api_version, + template_url=self.get_support_info.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_support_info.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/getSupportInfo" + } + + @overload + def save_log_profile( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + firewall_name: str, + log_settings: Optional[_models.LogSettings] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param log_settings: Default value is None. + :type log_settings: ~azure.mgmt.paloaltonetworks.models.LogSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def save_log_profile( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + firewall_name: str, + log_settings: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param log_settings: Default value is None. + :type log_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def save_log_profile( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + firewall_name: str, + log_settings: Optional[Union[_models.LogSettings, IO]] = None, + **kwargs: Any + ) -> None: + """Log Profile for Firewall. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param firewall_name: Firewall resource name. Required. + :type firewall_name: str + :param log_settings: Is either a LogSettings type or a IO type. Default value is None. + :type log_settings: ~azure.mgmt.paloaltonetworks.models.LogSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(log_settings, (IO, bytes)): + _content = log_settings + else: + if log_settings is not None: + _json = self._serialize.body(log_settings, "LogSettings") + else: + _json = None + + request = build_save_log_profile_request( + resource_group_name=resource_group_name, + firewall_name=firewall_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.save_log_profile.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + save_log_profile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/firewalls/{firewallName}/saveLogProfile" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_fqdn_list_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_fqdn_list_global_rulestack_operations.py new file mode 100644 index 000000000000..06b55d036b64 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_fqdn_list_global_rulestack_operations.py @@ -0,0 +1,653 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class FqdnListGlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`fqdn_list_global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, global_rulestack_name: str, **kwargs: Any) -> Iterable["_models.FqdnListGlobalRulestackResource"]: + """List FqdnListGlobalRulestackResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FqdnListGlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListGlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FqdnListGlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists"} + + @distributed_trace + def get(self, global_rulestack_name: str, name: str, **kwargs: Any) -> _models.FqdnListGlobalRulestackResource: + """Get a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FqdnListGlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListGlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + def _create_or_update_initial( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListGlobalRulestackResource, IO], + **kwargs: Any + ) -> _models.FqdnListGlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListGlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "FqdnListGlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: _models.FqdnListGlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FqdnListGlobalRulestackResource]: + """Create a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FqdnListGlobalRulestackResource]: + """Create a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListGlobalRulestackResource, IO], + **kwargs: Any + ) -> LROPoller[_models.FqdnListGlobalRulestackResource]: + """Create a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Is either a FqdnListGlobalRulestackResource type + or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 FqdnListGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListGlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("FqdnListGlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } + + @distributed_trace + def begin_delete(self, global_rulestack_name: str, name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a FqdnListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: fqdn list name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/fqdnlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_fqdn_list_local_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_fqdn_list_local_rulestack_operations.py new file mode 100644 index 000000000000..3a4db4971eea --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_fqdn_list_local_rulestack_operations.py @@ -0,0 +1,721 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_local_rulestacks_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class FqdnListLocalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`fqdn_list_local_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> Iterable["_models.FqdnListLocalRulestackResource"]: + """List FqdnListLocalRulestackResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FqdnListLocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListLocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("FqdnListLocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists" + } + + @distributed_trace + def get( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.FqdnListLocalRulestackResource: + """Get a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FqdnListLocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FqdnListLocalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListLocalRulestackResource, IO], + **kwargs: Any + ) -> _models.FqdnListLocalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListLocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "FqdnListLocalRulestackResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: _models.FqdnListLocalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FqdnListLocalRulestackResource]: + """Create a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListLocalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FqdnListLocalRulestackResource]: + """Create a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 FqdnListLocalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.FqdnListLocalRulestackResource, IO], + **kwargs: Any + ) -> LROPoller[_models.FqdnListLocalRulestackResource]: + """Create a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type name: str + :param resource: Resource create parameters. Is either a FqdnListLocalRulestackResource type or + a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 FqdnListLocalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.FqdnListLocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FqdnListLocalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("FqdnListLocalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a FqdnListLocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: fqdn list name. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/fqdnlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_global_rulestack_operations.py new file mode 100644 index 000000000000..71736f95a2cc --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_global_rulestack_operations.py @@ -0,0 +1,1670 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}") + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}") + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}") + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}") + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commit_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/commit" + ) + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_change_log_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/getChangeLog" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_advanced_security_objects_request( + global_rulestack_name: str, + *, + type: Union[str, _models.AdvSecurityObjectTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listAdvancedSecurityObjects", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + _params["type"] = _SERIALIZER.query("type", type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_app_ids_request( + global_rulestack_name: str, + *, + app_id_version: Optional[str] = None, + app_prefix: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listAppIds" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if app_id_version is not None: + _params["appIdVersion"] = _SERIALIZER.query("app_id_version", app_id_version, "str") + if app_prefix is not None: + _params["appPrefix"] = _SERIALIZER.query("app_prefix", app_prefix, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_countries_request( + global_rulestack_name: str, *, skip: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listCountries" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_firewalls_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listFirewalls" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_predefined_url_categories_request( + global_rulestack_name: str, *, skip: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listPredefinedUrlCategories", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_security_services_request( + global_rulestack_name: str, + *, + type: Union[str, _models.SecurityServicesTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listSecurityServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + _params["type"] = _SERIALIZER.query("type", type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revert_request(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/revert" + ) + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class GlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.GlobalRulestackResource"]: + """List GlobalRulestackResource resources by Tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("GlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks"} + + @distributed_trace + def get(self, global_rulestack_name: str, **kwargs: Any) -> _models.GlobalRulestackResource: + """Get a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + def _create_or_update_initial( + self, global_rulestack_name: str, resource: Union[_models.GlobalRulestackResource, IO], **kwargs: Any + ) -> _models.GlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "GlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}" + } + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + resource: _models.GlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GlobalRulestackResource]: + """Create a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 GlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, global_rulestack_name: str, resource: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.GlobalRulestackResource]: + """Create a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 GlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, global_rulestack_name: str, resource: Union[_models.GlobalRulestackResource, IO], **kwargs: Any + ) -> LROPoller[_models.GlobalRulestackResource]: + """Create a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param resource: Resource create parameters. Is either a GlobalRulestackResource type or a IO + type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 GlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}" + } + + @overload + def update( + self, + global_rulestack_name: str, + properties: _models.GlobalRulestackResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GlobalRulestackResource: + """Update a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResourceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, global_rulestack_name: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.GlobalRulestackResource: + """Update a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, global_rulestack_name: str, properties: Union[_models.GlobalRulestackResourceUpdate, IO], **kwargs: Any + ) -> _models.GlobalRulestackResource: + """Update a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param properties: The resource properties to be updated. Is either a + GlobalRulestackResourceUpdate type or a IO type. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResourceUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.GlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "GlobalRulestackResourceUpdate") + + request = build_update_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + @distributed_trace + def begin_delete(self, global_rulestack_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a GlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}"} + + def _commit_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_commit_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self._commit_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _commit_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/commit" + } + + @distributed_trace + def begin_commit(self, global_rulestack_name: str, **kwargs: Any) -> LROPoller[None]: + """Commit rulestack configuration. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._commit_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_commit.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/commit" + } + + @distributed_trace + def get_change_log(self, global_rulestack_name: str, **kwargs: Any) -> _models.Changelog: + """Get changelog. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Changelog or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.Changelog + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Changelog] = kwargs.pop("cls", None) + + request = build_get_change_log_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.get_change_log.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Changelog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_change_log.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/getChangeLog" + } + + @distributed_trace + def list_advanced_security_objects( + self, + global_rulestack_name: str, + type: Union[str, _models.AdvSecurityObjectTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.AdvSecurityObjectListResponse: + """Get the list of advanced security objects. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param type: Known values are: "urlCustom" and "feeds". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvSecurityObjectListResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvSecurityObjectListResponse] = kwargs.pop("cls", None) + + request = build_list_advanced_security_objects_request( + global_rulestack_name=global_rulestack_name, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_advanced_security_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvSecurityObjectListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_advanced_security_objects.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listAdvancedSecurityObjects" + } + + @distributed_trace + def list_app_ids( + self, + global_rulestack_name: str, + app_id_version: Optional[str] = None, + app_prefix: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.ListAppIdResponse: + """List of AppIds for GlobalRulestack ApiVersion. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param app_id_version: Default value is None. + :type app_id_version: str + :param app_prefix: Default value is None. + :type app_prefix: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListAppIdResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListAppIdResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListAppIdResponse] = kwargs.pop("cls", None) + + request = build_list_app_ids_request( + global_rulestack_name=global_rulestack_name, + app_id_version=app_id_version, + app_prefix=app_prefix, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_app_ids.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAppIdResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_app_ids.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listAppIds" + } + + @distributed_trace + def list_countries( + self, global_rulestack_name: str, skip: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> _models.CountriesResponse: + """List of countries for Rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CountriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CountriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CountriesResponse] = kwargs.pop("cls", None) + + request = build_list_countries_request( + global_rulestack_name=global_rulestack_name, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_countries.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CountriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_countries.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listCountries" + } + + @distributed_trace + def list_firewalls(self, global_rulestack_name: str, **kwargs: Any) -> _models.ListFirewallsResponse: + """List of Firewalls associated with Rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListFirewallsResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListFirewallsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListFirewallsResponse] = kwargs.pop("cls", None) + + request = build_list_firewalls_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list_firewalls.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListFirewallsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_firewalls.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listFirewalls" + } + + @distributed_trace + def list_predefined_url_categories( + self, global_rulestack_name: str, skip: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> _models.PredefinedUrlCategoriesResponse: + """List predefined URL categories for rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PredefinedUrlCategoriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PredefinedUrlCategoriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PredefinedUrlCategoriesResponse] = kwargs.pop("cls", None) + + request = build_list_predefined_url_categories_request( + global_rulestack_name=global_rulestack_name, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_predefined_url_categories.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredefinedUrlCategoriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_predefined_url_categories.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listPredefinedUrlCategories" + } + + @distributed_trace + def list_security_services( + self, + global_rulestack_name: str, + type: Union[str, _models.SecurityServicesTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.SecurityServicesResponse: + """List the security services for rulestack. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param type: Known values are: "antiSpyware", "antiVirus", "ipsVulnerability", "urlFiltering", + "fileBlocking", and "dnsSubscription". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.SecurityServicesTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityServicesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SecurityServicesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecurityServicesResponse] = kwargs.pop("cls", None) + + request = build_list_security_services_request( + global_rulestack_name=global_rulestack_name, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_security_services.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityServicesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_security_services.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/listSecurityServices" + } + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, **kwargs: Any + ) -> None: + """Revert rulestack configuration. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revert_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.revert.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revert.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/revert"} diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_local_rules_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_local_rules_operations.py new file mode 100644 index 000000000000..43c2e9db14d3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_local_rules_operations.py @@ -0,0 +1,1066 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_local_rulestacks_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, local_rulestack_name: str, priority: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, local_rulestack_name: str, priority: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, local_rulestack_name: str, priority: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_counters_request( + resource_group_name: str, + local_rulestack_name: str, + priority: str, + subscription_id: str, + *, + firewall_name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/getCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_refresh_counters_request( + resource_group_name: str, + local_rulestack_name: str, + priority: str, + subscription_id: str, + *, + firewall_name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/refreshCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reset_counters_request( + resource_group_name: str, + local_rulestack_name: str, + priority: str, + subscription_id: str, + *, + firewall_name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/resetCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class LocalRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`local_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> Iterable["_models.LocalRulesResource"]: + """List LocalRulesResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocalRulesResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulesResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("LocalRulesResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules" + } + + @distributed_trace + def get( + self, resource_group_name: str, local_rulestack_name: str, priority: str, **kwargs: Any + ) -> _models.LocalRulesResource: + """Get a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulesResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulesResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulesResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: Union[_models.LocalRulesResource, IO], + **kwargs: Any + ) -> _models.LocalRulesResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulesResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "LocalRulesResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: _models.LocalRulesResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LocalRulesResource]: + """Create a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulesResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LocalRulesResource]: + """Create a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + resource: Union[_models.LocalRulesResource, IO], + **kwargs: Any + ) -> LROPoller[_models.LocalRulesResource]: + """Create a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Is either a LocalRulesResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulesResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 LocalRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulesResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LocalRulesResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, priority: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, priority: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a LocalRulesResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}" + } + + @distributed_trace + def get_counters( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + firewall_name: Optional[str] = None, + **kwargs: Any + ) -> _models.RuleCounter: + """Get counters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounter or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounter] = kwargs.pop("cls", None) + + request = build_get_counters_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.get_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounter", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_counters.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/getCounters" + } + + @distributed_trace + def refresh_counters( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + firewall_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """Refresh counters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_counters_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.refresh_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + refresh_counters.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/refreshCounters" + } + + @distributed_trace + def reset_counters( + self, + resource_group_name: str, + local_rulestack_name: str, + priority: str, + firewall_name: Optional[str] = None, + **kwargs: Any + ) -> _models.RuleCounterReset: + """Reset counters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param priority: Local Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounterReset or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounterReset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounterReset] = kwargs.pop("cls", None) + + request = build_reset_counters_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + priority=priority, + subscription_id=self._config.subscription_id, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.reset_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounterReset", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + reset_counters.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/localRules/{priority}/resetCounters" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_local_rulestacks_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_local_rulestacks_operations.py new file mode 100644 index 000000000000..ae6a732b1ae0 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_local_rulestacks_operations.py @@ -0,0 +1,2144 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commit_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/commit", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_change_log_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getChangeLog", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_support_info_request( + resource_group_name: str, + local_rulestack_name: str, + subscription_id: str, + *, + email: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getSupportInfo", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if email is not None: + _params["email"] = _SERIALIZER.query("email", email, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_advanced_security_objects_request( + resource_group_name: str, + local_rulestack_name: str, + subscription_id: str, + *, + type: Union[str, _models.AdvSecurityObjectTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAdvancedSecurityObjects", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + _params["type"] = _SERIALIZER.query("type", type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_app_ids_request( + resource_group_name: str, + local_rulestack_name: str, + subscription_id: str, + *, + app_id_version: Optional[str] = None, + app_prefix: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAppIds", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if app_id_version is not None: + _params["appIdVersion"] = _SERIALIZER.query("app_id_version", app_id_version, "str") + if app_prefix is not None: + _params["appPrefix"] = _SERIALIZER.query("app_prefix", app_prefix, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_countries_request( + resource_group_name: str, + local_rulestack_name: str, + subscription_id: str, + *, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listCountries", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_firewalls_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listFirewalls", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_predefined_url_categories_request( + resource_group_name: str, + local_rulestack_name: str, + subscription_id: str, + *, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listPredefinedUrlCategories", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_security_services_request( + resource_group_name: str, + local_rulestack_name: str, + subscription_id: str, + *, + type: Union[str, _models.SecurityServicesTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listSecurityServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["skip"] = _SERIALIZER.query("skip", skip, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + _params["type"] = _SERIALIZER.query("type", type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revert_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/revert", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class LocalRulestacksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`local_rulestacks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.LocalRulestackResource"]: + """List LocalRulestackResource resources by subscription ID. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("LocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.LocalRulestackResource"]: + """List LocalRulestackResource resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("LocalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks" + } + + @distributed_trace + def get(self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any) -> _models.LocalRulestackResource: + """Get a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: Union[_models.LocalRulestackResource, IO], + **kwargs: Any + ) -> _models.LocalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "LocalRulestackResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: _models.LocalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LocalRulestackResource]: + """Create a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LocalRulestackResource]: + """Create a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + resource: Union[_models.LocalRulestackResource, IO], + **kwargs: Any + ) -> LROPoller[_models.LocalRulestackResource]: + """Create a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param resource: Resource create parameters. Is either a LocalRulestackResource type or a IO + type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 LocalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.LocalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + @overload + def update( + self, + resource_group_name: str, + local_rulestack_name: str, + properties: _models.LocalRulestackResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalRulestackResource: + """Update a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResourceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + local_rulestack_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalRulestackResource: + """Update a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + local_rulestack_name: str, + properties: Union[_models.LocalRulestackResourceUpdate, IO], + **kwargs: Any + ) -> _models.LocalRulestackResource: + """Update a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param properties: The resource properties to be updated. Is either a + LocalRulestackResourceUpdate type or a IO type. Required. + :type properties: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResourceUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.LocalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalRulestackResourceUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a LocalRulestackResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}" + } + + def _commit_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_commit_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._commit_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _commit_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/commit" + } + + @distributed_trace + def begin_commit(self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any) -> LROPoller[None]: + """Commit rulestack configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._commit_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_commit.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/commit" + } + + @distributed_trace + def get_change_log(self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any) -> _models.Changelog: + """Get changelog. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Changelog or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.Changelog + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Changelog] = kwargs.pop("cls", None) + + request = build_get_change_log_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_change_log.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Changelog", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_change_log.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getChangeLog" + } + + @distributed_trace + def get_support_info( + self, resource_group_name: str, local_rulestack_name: str, email: Optional[str] = None, **kwargs: Any + ) -> _models.SupportInfo: + """support info for rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param email: email address on behalf of which this API called. Default value is None. + :type email: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SupportInfo or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SupportInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SupportInfo] = kwargs.pop("cls", None) + + request = build_get_support_info_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + email=email, + api_version=api_version, + template_url=self.get_support_info.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SupportInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_support_info.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getSupportInfo" + } + + @distributed_trace + def list_advanced_security_objects( + self, + resource_group_name: str, + local_rulestack_name: str, + type: Union[str, _models.AdvSecurityObjectTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.AdvSecurityObjectListResponse: + """Get the list of advanced security objects. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param type: Known values are: "urlCustom" and "feeds". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvSecurityObjectListResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.AdvSecurityObjectListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvSecurityObjectListResponse] = kwargs.pop("cls", None) + + request = build_list_advanced_security_objects_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_advanced_security_objects.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvSecurityObjectListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_advanced_security_objects.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAdvancedSecurityObjects" + } + + @distributed_trace + def list_app_ids( + self, + resource_group_name: str, + local_rulestack_name: str, + app_id_version: Optional[str] = None, + app_prefix: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.ListAppIdResponse: + """List of AppIds for LocalRulestack ApiVersion. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param app_id_version: Default value is None. + :type app_id_version: str + :param app_prefix: Default value is None. + :type app_prefix: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListAppIdResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListAppIdResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListAppIdResponse] = kwargs.pop("cls", None) + + request = build_list_app_ids_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + app_id_version=app_id_version, + app_prefix=app_prefix, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_app_ids.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAppIdResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_app_ids.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAppIds" + } + + @distributed_trace + def list_countries( + self, + resource_group_name: str, + local_rulestack_name: str, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.CountriesResponse: + """List of countries for Rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CountriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.CountriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CountriesResponse] = kwargs.pop("cls", None) + + request = build_list_countries_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_countries.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CountriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_countries.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listCountries" + } + + @distributed_trace + def list_firewalls( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> _models.ListFirewallsResponse: + """List of Firewalls associated with Rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListFirewallsResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.ListFirewallsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListFirewallsResponse] = kwargs.pop("cls", None) + + request = build_list_firewalls_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_firewalls.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListFirewallsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_firewalls.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listFirewalls" + } + + @distributed_trace + def list_predefined_url_categories( + self, + resource_group_name: str, + local_rulestack_name: str, + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.PredefinedUrlCategoriesResponse: + """List predefined URL categories for rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PredefinedUrlCategoriesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PredefinedUrlCategoriesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PredefinedUrlCategoriesResponse] = kwargs.pop("cls", None) + + request = build_list_predefined_url_categories_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_predefined_url_categories.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredefinedUrlCategoriesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_predefined_url_categories.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listPredefinedUrlCategories" + } + + @distributed_trace + def list_security_services( + self, + resource_group_name: str, + local_rulestack_name: str, + type: Union[str, _models.SecurityServicesTypeEnum], + skip: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> _models.SecurityServicesResponse: + """List the security services for rulestack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param type: Known values are: "antiSpyware", "antiVirus", "ipsVulnerability", "urlFiltering", + "fileBlocking", and "dnsSubscription". Required. + :type type: str or ~azure.mgmt.paloaltonetworks.models.SecurityServicesTypeEnum + :param skip: Default value is None. + :type skip: str + :param top: Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityServicesResponse or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.SecurityServicesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecurityServicesResponse] = kwargs.pop("cls", None) + + request = build_list_security_services_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + type=type, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_security_services.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityServicesResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_security_services.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listSecurityServices" + } + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> None: + """Revert rulestack configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revert_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/revert" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_operations.py new file mode 100644 index 000000000000..b24baa7783fc --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_operations.py @@ -0,0 +1,155 @@ +# 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +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_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/PaloAltoNetworks.Cloudngfw/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List the operations for the provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/operations"} diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_patch.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_post_rules_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_post_rules_operations.py new file mode 100644 index 000000000000..c4c3ab0b6987 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_post_rules_operations.py @@ -0,0 +1,933 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(global_rulestack_name: str, priority: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(global_rulestack_name: str, priority: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(global_rulestack_name: str, priority: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_counters_request( + global_rulestack_name: str, priority: str, *, firewall_name: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/getCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_refresh_counters_request( + global_rulestack_name: str, priority: str, *, firewall_name: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/refreshCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reset_counters_request( + global_rulestack_name: str, priority: str, *, firewall_name: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/resetCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PostRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`post_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, global_rulestack_name: str, **kwargs: Any) -> Iterable["_models.PostRulesResource"]: + """List PostRulesResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PostRulesResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PostRulesResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PostRulesResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules"} + + @distributed_trace + def get(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> _models.PostRulesResource: + """Get a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PostRulesResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PostRulesResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PostRulesResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PostRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + def _create_or_update_initial( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PostRulesResource, IO], **kwargs: Any + ) -> _models.PostRulesResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PostRulesResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PostRulesResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PostRulesResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PostRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: _models.PostRulesResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PostRulesResource]: + """Create a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PostRulesResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PostRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PostRulesResource]: + """Create a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PostRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PostRulesResource, IO], **kwargs: Any + ) -> LROPoller[_models.PostRulesResource]: + """Create a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Is either a PostRulesResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PostRulesResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PostRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PostRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PostRulesResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + priority=priority, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PostRulesResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + @distributed_trace + def begin_delete(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> LROPoller[None]: + """Delete a PostRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}" + } + + @distributed_trace + def get_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounter: + """Get counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounter or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounter] = kwargs.pop("cls", None) + + request = build_get_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.get_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounter", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/getCounters" + } + + @distributed_trace + def refresh_counters( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> None: + """Refresh counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.refresh_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + refresh_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/refreshCounters" + } + + @distributed_trace + def reset_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounterReset: + """Reset counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Post Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounterReset or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounterReset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounterReset] = kwargs.pop("cls", None) + + request = build_reset_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.reset_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounterReset", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + reset_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/postRules/{priority}/resetCounters" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_pre_rules_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_pre_rules_operations.py new file mode 100644 index 000000000000..d052b754d06e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_pre_rules_operations.py @@ -0,0 +1,933 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(global_rulestack_name: str, priority: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(global_rulestack_name: str, priority: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(global_rulestack_name: str, priority: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_counters_request( + global_rulestack_name: str, priority: str, *, firewall_name: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/getCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_refresh_counters_request( + global_rulestack_name: str, priority: str, *, firewall_name: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/refreshCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reset_counters_request( + global_rulestack_name: str, priority: str, *, firewall_name: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/resetCounters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "priority": _SERIALIZER.url("priority", priority, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if firewall_name is not None: + _params["firewallName"] = _SERIALIZER.query("firewall_name", firewall_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PreRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`pre_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, global_rulestack_name: str, **kwargs: Any) -> Iterable["_models.PreRulesResource"]: + """List PreRulesResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PreRulesResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PreRulesResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PreRulesResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules"} + + @distributed_trace + def get(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> _models.PreRulesResource: + """Get a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PreRulesResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PreRulesResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PreRulesResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PreRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + def _create_or_update_initial( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PreRulesResource, IO], **kwargs: Any + ) -> _models.PreRulesResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreRulesResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PreRulesResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PreRulesResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PreRulesResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: _models.PreRulesResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreRulesResource]: + """Create a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PreRulesResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PreRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + priority: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PreRulesResource]: + """Create a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PreRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, global_rulestack_name: str, priority: str, resource: Union[_models.PreRulesResource, IO], **kwargs: Any + ) -> LROPoller[_models.PreRulesResource]: + """Create a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param resource: Resource create parameters. Is either a PreRulesResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PreRulesResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PreRulesResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PreRulesResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PreRulesResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + priority=priority, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PreRulesResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + @distributed_trace + def begin_delete(self, global_rulestack_name: str, priority: str, **kwargs: Any) -> LROPoller[None]: + """Delete a PreRulesResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + priority=priority, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}" + } + + @distributed_trace + def get_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounter: + """Get counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounter or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounter] = kwargs.pop("cls", None) + + request = build_get_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.get_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounter", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/getCounters" + } + + @distributed_trace + def refresh_counters( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> None: + """Refresh counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.refresh_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + refresh_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/refreshCounters" + } + + @distributed_trace + def reset_counters( + self, global_rulestack_name: str, priority: str, firewall_name: Optional[str] = None, **kwargs: Any + ) -> _models.RuleCounterReset: + """Reset counters. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param priority: Pre Rule priority. Required. + :type priority: str + :param firewall_name: Default value is None. + :type firewall_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleCounterReset or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.RuleCounterReset + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RuleCounterReset] = kwargs.pop("cls", None) + + request = build_reset_counters_request( + global_rulestack_name=global_rulestack_name, + priority=priority, + firewall_name=firewall_name, + api_version=api_version, + template_url=self.reset_counters.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RuleCounterReset", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + reset_counters.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/preRules/{priority}/resetCounters" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_prefix_list_global_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_prefix_list_global_rulestack_operations.py new file mode 100644 index 000000000000..2e2fa7993d8f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_prefix_list_global_rulestack_operations.py @@ -0,0 +1,656 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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(global_rulestack_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists" + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(global_rulestack_name: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "globalRulestackName": _SERIALIZER.url("global_rulestack_name", global_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrefixListGlobalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`prefix_list_global_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, global_rulestack_name: str, **kwargs: Any) -> Iterable["_models.PrefixListGlobalRulestackResource"]: + """List PrefixListGlobalRulestackResource resources by Tenant. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrefixListGlobalRulestackResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListGlobalRulestackResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + global_rulestack_name=global_rulestack_name, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PrefixListGlobalRulestackResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists"} + + @distributed_trace + def get(self, global_rulestack_name: str, name: str, **kwargs: Any) -> _models.PrefixListGlobalRulestackResource: + """Get a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrefixListGlobalRulestackResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListGlobalRulestackResource] = kwargs.pop("cls", None) + + request = build_get_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + def _create_or_update_initial( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListGlobalRulestackResource, IO], + **kwargs: Any + ) -> _models.PrefixListGlobalRulestackResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListGlobalRulestackResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PrefixListGlobalRulestackResource") + + request = build_create_or_update_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: _models.PrefixListGlobalRulestackResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrefixListGlobalRulestackResource]: + """Create a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrefixListGlobalRulestackResource]: + """Create a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + global_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListGlobalRulestackResource, IO], + **kwargs: Any + ) -> LROPoller[_models.PrefixListGlobalRulestackResource]: + """Create a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Is either a PrefixListGlobalRulestackResource type + or a IO type. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PrefixListGlobalRulestackResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListGlobalRulestackResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListGlobalRulestackResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + global_rulestack_name=global_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrefixListGlobalRulestackResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, global_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } + + @distributed_trace + def begin_delete(self, global_rulestack_name: str, name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a PrefixListGlobalRulestackResource. + + :param global_rulestack_name: GlobalRulestack resource name. Required. + :type global_rulestack_name: str + :param name: Local Rule priority. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + global_rulestack_name=global_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/providers/PaloAltoNetworks.Cloudngfw/globalRulestacks/{globalRulestackName}/prefixlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_prefix_list_local_rulestack_operations.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_prefix_list_local_rulestack_operations.py new file mode 100644 index 000000000000..4aa8b8d63eeb --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/operations/_prefix_list_local_rulestack_operations.py @@ -0,0 +1,716 @@ +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_local_rulestacks_request( + resource_group_name: str, local_rulestack_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, local_rulestack_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-29-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "localRulestackName": _SERIALIZER.url("local_rulestack_name", local_rulestack_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrefixListLocalRulestackOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.paloaltonetworks.PaloAltoNetworksNgfwMgmtClient`'s + :attr:`prefix_list_local_rulestack` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_local_rulestacks( + self, resource_group_name: str, local_rulestack_name: str, **kwargs: Any + ) -> Iterable["_models.PrefixListResource"]: + """List PrefixListResource resources by LocalRulestacks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrefixListResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_local_rulestacks_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_local_rulestacks.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("PrefixListResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_local_rulestacks.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists" + } + + @distributed_trace + def get( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> _models.PrefixListResource: + """Get a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrefixListResource or the result of cls(response) + :rtype: ~azure.mgmt.paloaltonetworks.models.PrefixListResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrefixListResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrefixListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListResource, IO], + **kwargs: Any + ) -> _models.PrefixListResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IO, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "PrefixListResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrefixListResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrefixListResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: _models.PrefixListResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrefixListResource]: + """Create a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrefixListResource]: + """Create a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Required. + :type resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PrefixListResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + local_rulestack_name: str, + name: str, + resource: Union[_models.PrefixListResource, IO], + **kwargs: Any + ) -> LROPoller[_models.PrefixListResource]: + """Create a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type name: str + :param resource: Resource create parameters. Is either a PrefixListResource type or a IO type. + Required. + :type resource: ~azure.mgmt.paloaltonetworks.models.PrefixListResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PrefixListResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.paloaltonetworks.models.PrefixListResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrefixListResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + resource=resource, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrefixListResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, local_rulestack_name: str, name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a PrefixListResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param local_rulestack_name: LocalRulestack resource name. Required. + :type local_rulestack_name: str + :param name: Local Rule priority. Required. + :type 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + local_rulestack_name=local_rulestack_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/prefixlists/{name}" + } diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/py.typed b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/azure/mgmt/paloaltonetworksngfw/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..fcf05ffe8aed --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,51 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + name="armid1", + resource={ + "properties": { + "auditComment": "comment", + "certificateSelfSigned": "TRUE", + "certificateSignerResourceId": "", + "description": "description", + "etag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + "provisioningState": "Accepted", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..faa4670d42ca --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + name="armid1", + resource={"properties": {"certificateSelfSigned": "TRUE"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..ddb43e929372 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.begin_delete( + global_rulestack_name="praval", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..ab16170b4543 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.begin_delete( + global_rulestack_name="praval", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..b6f916ff7dba --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.get( + global_rulestack_name="praval", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..7997112179eb --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.get( + global_rulestack_name="praval", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_list_maximum_set_gen.py new file mode 100644 index 000000000000..4c3a63de6079 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_list_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.list( + global_rulestack_name="praval", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_list_minimum_set_gen.py new file mode 100644 index 000000000000..1cda07461b25 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_global_rulestack_list_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_global_rulestack_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.certificate_object_global_rulestack.list( + global_rulestack_name="praval", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectGlobalRulestack_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..209603af4853 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,52 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + resource={ + "properties": { + "auditComment": "comment", + "certificateSelfSigned": "TRUE", + "certificateSignerResourceId": "", + "description": "description", + "etag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + "provisioningState": "Accepted", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..a044e73d63b1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,43 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + resource={"properties": {"certificateSelfSigned": "TRUE"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..12961191153a --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..aa4a3c0e38bf --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..78dd5083e7fb --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_get_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..dcc4d03b69cf --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_get_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py new file mode 100644 index 000000000000..5a3ab1adeaf4 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.list_by_local_rulestacks( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py new file mode 100644 index 000000000000..e17c207c8d87 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/certificate_object_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python certificate_object_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.certificate_object_local_rulestack.list_by_local_rulestacks( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/CertificateObjectLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..319bad094ef8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_create_or_update_maximum_set_gen.py @@ -0,0 +1,145 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.begin_create_or_update( + resource_group_name="firewall-rg", + firewall_name="firewall1", + resource={ + "identity": { + "type": "None", + "userAssignedIdentities": {"key16": {"clientId": "aaaa", "principalId": "aaaaaaaaaaaaaaa"}}, + }, + "location": "eastus", + "properties": { + "associatedRulestack": {"location": "eastus", "resourceId": "lrs1", "rulestackId": "PANRSID"}, + "dnsSettings": { + "dnsServers": [ + { + "address": "20.22.92.111", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1", + } + ], + "enableDnsProxy": "DISABLED", + "enabledDnsType": "CUSTOM", + }, + "frontEndSettings": [ + { + "backendConfiguration": { + "address": { + "address": "20.22.32.136", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp2", + }, + "port": "80", + }, + "frontendConfiguration": { + "address": { + "address": "20.22.91.251", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp1", + }, + "port": "80", + }, + "name": "frontendsetting11", + "protocol": "TCP", + } + ], + "isPanoramaManaged": "TRUE", + "marketplaceDetails": { + "marketplaceSubscriptionStatus": "PendingFulfillmentStart", + "offerId": "liftr-pan-ame-test", + "publisherId": "isvtestuklegacy", + }, + "networkProfile": { + "egressNatIp": [ + { + "address": "20.22.92.111", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1", + } + ], + "enableEgressNat": "ENABLED", + "networkType": "VNET", + "publicIps": [ + { + "address": "20.22.92.11", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1", + } + ], + "vnetConfiguration": { + "ipOfTrustSubnetForUdr": { + "address": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "trustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet", + }, + "unTrustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "vnet": { + "addressSpace": "10.1.0.0/16", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet", + }, + }, + "vwanConfiguration": { + "ipOfTrustSubnetForUdr": { + "address": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "networkVirtualApplianceId": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "trustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet", + }, + "unTrustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "vHub": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + }, + }, + "panEtag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "panoramaConfig": {"configString": "bas64EncodedString"}, + "planData": {"billingCycle": "MONTHLY", "planId": "liftrpantestplan", "usageType": "PAYG"}, + "provisioningState": "Accepted", + }, + "tags": {"tagName": "value"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..0cc4d90504da --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_create_or_update_minimum_set_gen.py @@ -0,0 +1,59 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.begin_create_or_update( + resource_group_name="firewall-rg", + firewall_name="firewall1", + resource={ + "location": "eastus", + "properties": { + "dnsSettings": {}, + "marketplaceDetails": {"offerId": "liftr-pan-ame-test", "publisherId": "isvtestuklegacy"}, + "networkProfile": { + "enableEgressNat": "ENABLED", + "networkType": "VNET", + "publicIps": [ + { + "address": "20.22.92.11", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1", + } + ], + }, + "planData": {"billingCycle": "MONTHLY", "planId": "liftrpantestplan"}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_delete_maximum_set_gen.py new file mode 100644 index 000000000000..c739bf3d78e5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.begin_delete( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_delete_minimum_set_gen.py new file mode 100644 index 000000000000..ff5418603000 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.begin_delete( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_global_rulestack_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_global_rulestack_maximum_set_gen.py new file mode 100644 index 000000000000..7303a7ec44fd --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_global_rulestack_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_global_rulestack_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get_global_rulestack( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_getGlobalRulestack_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_global_rulestack_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_global_rulestack_minimum_set_gen.py new file mode 100644 index 000000000000..a7b977541cf9 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_global_rulestack_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_global_rulestack_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get_global_rulestack( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_getGlobalRulestack_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_log_profile_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_log_profile_maximum_set_gen.py new file mode 100644 index 000000000000..c26097868696 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_log_profile_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_log_profile_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get_log_profile( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_getLogProfile_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_log_profile_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_log_profile_minimum_set_gen.py new file mode 100644 index 000000000000..43882fadd80f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_log_profile_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_log_profile_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get_log_profile( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_getLogProfile_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_maximum_set_gen.py new file mode 100644 index 000000000000..4422b4490a5e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_minimum_set_gen.py new file mode 100644 index 000000000000..1a6a1cfd1076 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_support_info_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_support_info_maximum_set_gen.py new file mode 100644 index 000000000000..a0e5090868b9 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_support_info_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_support_info_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get_support_info( + resource_group_name="rgopenapi", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_getSupportInfo_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_support_info_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_support_info_minimum_set_gen.py new file mode 100644 index 000000000000..f4974f471b9f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_get_support_info_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_get_support_info_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.get_support_info( + resource_group_name="rgopenapi", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_getSupportInfo_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_resource_group_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_resource_group_maximum_set_gen.py new file mode 100644 index 000000000000..4b6bed9a0b5a --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_resource_group_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_list_by_resource_group_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.list_by_resource_group( + resource_group_name="firewall-rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_ListByResourceGroup_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_resource_group_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_resource_group_minimum_set_gen.py new file mode 100644 index 000000000000..02f38ef560bf --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_resource_group_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_list_by_resource_group_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.list_by_resource_group( + resource_group_name="firewall-rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_ListByResourceGroup_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_subscription_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_subscription_maximum_set_gen.py new file mode 100644 index 000000000000..eb1933259f38 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_subscription_maximum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_list_by_subscription_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_ListBySubscription_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_subscription_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_subscription_minimum_set_gen.py new file mode 100644 index 000000000000..2f9936f915f8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_list_by_subscription_minimum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_list_by_subscription_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_ListBySubscription_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_save_log_profile_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_save_log_profile_maximum_set_gen.py new file mode 100644 index 000000000000..ecb256b835af --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_save_log_profile_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_save_log_profile_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.save_log_profile( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_saveLogProfile_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_save_log_profile_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_save_log_profile_minimum_set_gen.py new file mode 100644 index 000000000000..e1cf4e7bd6a0 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_save_log_profile_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_save_log_profile_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.save_log_profile( + resource_group_name="firewall-rg", + firewall_name="firewall1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_saveLogProfile_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_update_maximum_set_gen.py new file mode 100644 index 000000000000..a54fcfd499e0 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/firewalls_update_maximum_set_gen.py @@ -0,0 +1,151 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python firewalls_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.firewalls.update( + resource_group_name="firewall-rg", + firewall_name="firewall1", + properties={ + "identity": { + "type": "None", + "userAssignedIdentities": {"key16": {"clientId": "aaaa", "principalId": "aaaaaaaaaaaaaaa"}}, + }, + "properties": { + "associatedRulestack": { + "location": "eastus", + "resourceId": "aaaaaaaaaa", + "rulestackId": "aaaaaaaaaaaaaaaa", + }, + "dnsSettings": { + "dnsServers": [ + { + "address": "20.22.92.111", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1", + } + ], + "enableDnsProxy": "DISABLED", + "enabledDnsType": "CUSTOM", + }, + "frontEndSettings": [ + { + "backendConfiguration": { + "address": { + "address": "20.22.32.136", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp2", + }, + "port": "80", + }, + "frontendConfiguration": { + "address": { + "address": "20.22.91.251", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp1", + }, + "port": "80", + }, + "name": "frontendsetting11", + "protocol": "TCP", + } + ], + "isPanoramaManaged": "TRUE", + "marketplaceDetails": { + "marketplaceSubscriptionStatus": "PendingFulfillmentStart", + "offerId": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "publisherId": "aaaa", + }, + "networkProfile": { + "egressNatIp": [ + { + "address": "20.22.92.111", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1", + } + ], + "enableEgressNat": "ENABLED", + "networkType": "VNET", + "publicIps": [ + { + "address": "20.22.92.11", + "resourceId": "/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1", + } + ], + "vnetConfiguration": { + "ipOfTrustSubnetForUdr": { + "address": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "trustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet", + }, + "unTrustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "vnet": { + "addressSpace": "10.1.0.0/16", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet", + }, + }, + "vwanConfiguration": { + "ipOfTrustSubnetForUdr": { + "address": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "networkVirtualApplianceId": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "trustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet", + }, + "unTrustSubnet": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + "vHub": { + "addressSpace": "10.1.1.0/24", + "resourceId": "/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet", + }, + }, + }, + "panEtag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "panoramaConfig": {"configString": "bas64EncodedString"}, + "planData": { + "billingCycle": "WEEKLY", + "planId": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "usageType": "PAYG", + }, + }, + "tags": {"tagName": "value"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Firewalls_Update_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..946a822dc2c3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,50 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + name="armid1", + resource={ + "properties": { + "auditComment": "string", + "description": "string", + "etag": "aaaaaaaaaaaaaaaaaa", + "fqdnList": ["string1", "string2"], + "provisioningState": "Accepted", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..b9e1b944010c --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + name="armid1", + resource={"properties": {"fqdnList": ["string1", "string2"]}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..69e66f590ab8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.begin_delete( + global_rulestack_name="praval", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..1092e5798190 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.begin_delete( + global_rulestack_name="praval", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..7afc94a8b14a --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.get( + global_rulestack_name="praval", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..766c0fd3f584 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.get( + global_rulestack_name="praval", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_list_maximum_set_gen.py new file mode 100644 index 000000000000..0c09fa6b32b8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_list_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.list( + global_rulestack_name="praval", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_list_minimum_set_gen.py new file mode 100644 index 000000000000..19e5fab35206 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_global_rulestack_list_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_global_rulestack_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fqdn_list_global_rulestack.list( + global_rulestack_name="praval", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListGlobalRulestack_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..755d0412200b --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,51 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + resource={ + "properties": { + "auditComment": "string", + "description": "string", + "etag": "aaaaaaaaaaaaaaaaaa", + "fqdnList": ["string1", "string2"], + "provisioningState": "Accepted", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..7b94cac7e838 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,43 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + resource={"properties": {"fqdnList": ["string1", "string2"]}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..02d7fbe9e860 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..66ec966d8e2d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..4c725524ad00 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_get_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..3b9c67f665bf --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_get_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py new file mode 100644 index 000000000000..69590c4928b5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.list_by_local_rulestacks( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py new file mode 100644 index 000000000000..be3def94c14a --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/fqdn_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python fqdn_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.fqdn_list_local_rulestack.list_by_local_rulestacks( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/FqdnListLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_commit_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_commit_maximum_set_gen.py new file mode 100644 index 000000000000..c6e3a697ded0 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_commit_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_commit_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.begin_commit( + global_rulestack_name="praval", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_commit_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_commit_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_commit_minimum_set_gen.py new file mode 100644 index 000000000000..dee8d6d6d846 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_commit_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_commit_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.begin_commit( + global_rulestack_name="praval", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_commit_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..625d039b58b8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,67 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + resource={ + "identity": { + "type": "None", + "userAssignedIdentities": {"key16": {"clientId": "aaaa", "principalId": "aaaaaaaaaaaaaaa"}}, + }, + "location": "eastus", + "properties": { + "associatedSubscriptions": ["2bf4a339-294d-4c25-b0b2-ef649e9f5c27"], + "defaultMode": "IPS", + "description": "global rulestacks", + "minAppIdVersion": "8.5.3", + "panEtag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "panLocation": "eastus", + "provisioningState": "Accepted", + "scope": "GLOBAL", + "securityServices": { + "antiSpywareProfile": "default", + "antiVirusProfile": "default", + "dnsSubscription": "default", + "fileBlockingProfile": "default", + "outboundTrustCertificate": "default", + "outboundUnTrustCertificate": "default", + "urlFilteringProfile": "default", + "vulnerabilityProfile": "default", + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..65b8a7bb71c2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + resource={"location": "eastus", "properties": {}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..6b85a9e3ab45 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.begin_delete( + global_rulestack_name="praval", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..848cd0782471 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.begin_delete( + global_rulestack_name="praval", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_change_log_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_change_log_maximum_set_gen.py new file mode 100644 index 000000000000..720b6015ecc2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_change_log_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_get_change_log_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.get_change_log( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_getChangeLog_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_change_log_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_change_log_minimum_set_gen.py new file mode 100644 index 000000000000..c54063d1dfdf --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_change_log_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_get_change_log_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.get_change_log( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_getChangeLog_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..49b3c1d3f717 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.get( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..0001f0c80891 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_get_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.get( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_advanced_security_objects_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_advanced_security_objects_maximum_set_gen.py new file mode 100644 index 000000000000..069a4580c06d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_advanced_security_objects_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_advanced_security_objects_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_advanced_security_objects( + global_rulestack_name="praval", + type="globalRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listAdvancedSecurityObjects_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_advanced_security_objects_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_advanced_security_objects_minimum_set_gen.py new file mode 100644 index 000000000000..12104a78cce7 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_advanced_security_objects_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_advanced_security_objects_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_advanced_security_objects( + global_rulestack_name="praval", + type="globalRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listAdvancedSecurityObjects_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_app_ids_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_app_ids_maximum_set_gen.py new file mode 100644 index 000000000000..4d3060a50174 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_app_ids_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_app_ids_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_app_ids( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listAppIds_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_app_ids_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_app_ids_minimum_set_gen.py new file mode 100644 index 000000000000..8e2f09c879de --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_app_ids_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_app_ids_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_app_ids( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listAppIds_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_countries_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_countries_maximum_set_gen.py new file mode 100644 index 000000000000..19e746ee33a4 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_countries_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_countries_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_countries( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listCountries_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_countries_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_countries_minimum_set_gen.py new file mode 100644 index 000000000000..b23abdb297e8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_countries_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_countries_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_countries( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listCountries_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_firewalls_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_firewalls_maximum_set_gen.py new file mode 100644 index 000000000000..2fc7eede73f3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_firewalls_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_firewalls_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_firewalls( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listFirewalls_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_firewalls_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_firewalls_minimum_set_gen.py new file mode 100644 index 000000000000..ca4eba134265 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_firewalls_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_firewalls_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_firewalls( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listFirewalls_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_maximum_set_gen.py new file mode 100644 index 000000000000..b04b14e5ca48 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_maximum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_minimum_set_gen.py new file mode 100644 index 000000000000..1c71c6c6833c --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_minimum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_predefined_url_categories_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_predefined_url_categories_maximum_set_gen.py new file mode 100644 index 000000000000..7836f2eb847e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_predefined_url_categories_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_predefined_url_categories_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_predefined_url_categories( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listPredefinedUrlCategories_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_predefined_url_categories_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_predefined_url_categories_minimum_set_gen.py new file mode 100644 index 000000000000..a4d313a07de2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_predefined_url_categories_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_predefined_url_categories_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_predefined_url_categories( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listPredefinedUrlCategories_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_security_services_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_security_services_maximum_set_gen.py new file mode 100644 index 000000000000..eac4d704cf3c --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_security_services_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_security_services_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_security_services( + global_rulestack_name="praval", + type="globalRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listSecurityServices_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_security_services_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_security_services_minimum_set_gen.py new file mode 100644 index 000000000000..a15c39749785 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_list_security_services_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_list_security_services_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.list_security_services( + global_rulestack_name="praval", + type="globalRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_listSecurityServices_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_revert_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_revert_maximum_set_gen.py new file mode 100644 index 000000000000..2b17c06222bb --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_revert_maximum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_revert_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.revert( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_revert_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_revert_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_revert_minimum_set_gen.py new file mode 100644 index 000000000000..b8d09b7ad4a9 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_revert_minimum_set_gen.py @@ -0,0 +1,40 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_revert_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.revert( + global_rulestack_name="praval", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_revert_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_update_maximum_set_gen.py new file mode 100644 index 000000000000..005b1f790f9b --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/global_rulestack_update_maximum_set_gen.py @@ -0,0 +1,66 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python global_rulestack_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.global_rulestack.update( + global_rulestack_name="praval", + properties={ + "identity": { + "type": "None", + "userAssignedIdentities": {"key16": {"clientId": "aaaa", "principalId": "aaaaaaaaaaaaaaa"}}, + }, + "location": "eastus", + "properties": { + "associatedSubscriptions": ["2bf4a339-294d-4c25-b0b2-ef649e9f5c27"], + "defaultMode": "IPS", + "description": "global rulestacks", + "minAppIdVersion": "8.5.3", + "panEtag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "panLocation": "eastus", + "scope": "GLOBAL", + "securityServices": { + "antiSpywareProfile": "default", + "antiVirusProfile": "default", + "dnsSubscription": "default", + "fileBlockingProfile": "default", + "outboundTrustCertificate": "default", + "outboundUnTrustCertificate": "default", + "urlFilteringProfile": "default", + "vulnerabilityProfile": "default", + }, + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/GlobalRulestack_Update_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..00644d44ad2f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_create_or_update_maximum_set_gen.py @@ -0,0 +1,71 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.begin_create_or_update( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + resource={ + "properties": { + "actionType": "Allow", + "applications": ["app1"], + "auditComment": "example comment", + "category": {"feeds": ["feed"], "urlCustom": ["https://microsoft.com"]}, + "decryptionRuleType": "SSLOutboundInspection", + "description": "description of local rule", + "destination": { + "cidrs": ["1.0.0.1/10"], + "countries": ["India"], + "feeds": ["feed"], + "fqdnLists": ["FQDN1"], + "prefixLists": ["PL1"], + }, + "enableLogging": "DISABLED", + "etag": "c18e6eef-ba3e-49ee-8a85-2b36c863a9d0", + "inboundInspectionCertificate": "cert1", + "negateDestination": "TRUE", + "negateSource": "TRUE", + "protocol": "HTTP", + "protocolPortList": ["80"], + "provisioningState": "Accepted", + "ruleName": "localRule1", + "ruleState": "DISABLED", + "source": {"cidrs": ["1.0.0.1/10"], "countries": ["India"], "feeds": ["feed"], "prefixLists": ["PL1"]}, + "tags": [{"key": "keyName", "value": "value"}], + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..ff2e27ddfbbe --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_create_or_update_minimum_set_gen.py @@ -0,0 +1,43 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.begin_create_or_update( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + resource={"properties": {"ruleName": "localRule1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_delete_maximum_set_gen.py new file mode 100644 index 000000000000..c08efd42a7ea --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_delete_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.begin_delete( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_delete_minimum_set_gen.py new file mode 100644 index 000000000000..b787282a74da --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_delete_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.begin_delete( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_counters_maximum_set_gen.py new file mode 100644 index 000000000000..f8fe7f7dc401 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_counters_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_get_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.get_counters( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_getCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_counters_minimum_set_gen.py new file mode 100644 index 000000000000..d294153cf0b4 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_counters_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_get_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.get_counters( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_getCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_maximum_set_gen.py new file mode 100644 index 000000000000..7c1dc0cfe164 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.get( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_minimum_set_gen.py new file mode 100644 index 000000000000..0f07f9789869 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_get_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.get( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_list_by_local_rulestacks_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_list_by_local_rulestacks_maximum_set_gen.py new file mode 100644 index 000000000000..99768f2b767d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_list_by_local_rulestacks_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_list_by_local_rulestacks_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.list_by_local_rulestacks( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_ListByLocalRulestacks_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_list_by_local_rulestacks_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_list_by_local_rulestacks_minimum_set_gen.py new file mode 100644 index 000000000000..f54048fe9f18 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_list_by_local_rulestacks_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_list_by_local_rulestacks_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.list_by_local_rulestacks( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_ListByLocalRulestacks_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_refresh_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_refresh_counters_maximum_set_gen.py new file mode 100644 index 000000000000..de3556908b29 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_refresh_counters_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_refresh_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.refresh_counters( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_refreshCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_refresh_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_refresh_counters_minimum_set_gen.py new file mode 100644 index 000000000000..c97c690fe819 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_refresh_counters_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_refresh_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.refresh_counters( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_refreshCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_reset_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_reset_counters_maximum_set_gen.py new file mode 100644 index 000000000000..48ba7b2153b5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_reset_counters_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_reset_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.reset_counters( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_resetCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_reset_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_reset_counters_minimum_set_gen.py new file mode 100644 index 000000000000..3a7c05cf2a96 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rules_reset_counters_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rules_reset_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rules.reset_counters( + resource_group_name="firewall-rg", + local_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRules_resetCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_commit_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_commit_maximum_set_gen.py new file mode 100644 index 000000000000..3efd5d1d7808 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_commit_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_commit_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.begin_commit( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_commit_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_commit_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_commit_minimum_set_gen.py new file mode 100644 index 000000000000..5bfe62a7c3b1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_commit_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_commit_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.begin_commit( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_commit_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..a408ea6d9463 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_create_or_update_maximum_set_gen.py @@ -0,0 +1,69 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + resource={ + "identity": { + "type": "None", + "userAssignedIdentities": {"key16": {"clientId": "aaaa", "principalId": "aaaaaaaaaaaaaaa"}}, + }, + "location": "eastus", + "properties": { + "associatedSubscriptions": ["2bf4a339-294d-4c25-b0b2-ef649e9f5c27"], + "defaultMode": "IPS", + "description": "local rulestacks", + "minAppIdVersion": "8.5.3", + "panEtag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "panLocation": "eastus", + "provisioningState": "Accepted", + "scope": "LOCAL", + "securityServices": { + "antiSpywareProfile": "default", + "antiVirusProfile": "default", + "dnsSubscription": "default", + "fileBlockingProfile": "default", + "outboundTrustCertificate": "default", + "outboundUnTrustCertificate": "default", + "urlFilteringProfile": "default", + "vulnerabilityProfile": "default", + }, + }, + "tags": {"tagName": "value"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..6e4337734ab7 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_create_or_update_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + resource={"location": "eastus", "properties": {}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_delete_maximum_set_gen.py new file mode 100644 index 000000000000..206e1363d39e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_delete_minimum_set_gen.py new file mode 100644 index 000000000000..57276bf2863b --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_change_log_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_change_log_maximum_set_gen.py new file mode 100644 index 000000000000..ea7dfae4a417 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_change_log_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_get_change_log_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.get_change_log( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_getChangeLog_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_change_log_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_change_log_minimum_set_gen.py new file mode 100644 index 000000000000..f57a135cf495 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_change_log_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_get_change_log_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.get_change_log( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_getChangeLog_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_maximum_set_gen.py new file mode 100644 index 000000000000..11160096fff2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_minimum_set_gen.py new file mode 100644 index 000000000000..b610d00de956 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_support_info_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_support_info_maximum_set_gen.py new file mode 100644 index 000000000000..454275b6b620 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_support_info_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_get_support_info_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.get_support_info( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_getSupportInfo_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_support_info_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_support_info_minimum_set_gen.py new file mode 100644 index 000000000000..f8937ebcfc08 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_get_support_info_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_get_support_info_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.get_support_info( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_getSupportInfo_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_advanced_security_objects_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_advanced_security_objects_maximum_set_gen.py new file mode 100644 index 000000000000..0ca2ee72d0b8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_advanced_security_objects_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_advanced_security_objects_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_advanced_security_objects( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + type="localRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listAdvancedSecurityObjects_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_advanced_security_objects_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_advanced_security_objects_minimum_set_gen.py new file mode 100644 index 000000000000..ad3ce2b8e824 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_advanced_security_objects_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_advanced_security_objects_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_advanced_security_objects( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + type="localRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listAdvancedSecurityObjects_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_app_ids_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_app_ids_maximum_set_gen.py new file mode 100644 index 000000000000..9f8c3abd3fcc --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_app_ids_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_app_ids_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_app_ids( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listAppIds_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_app_ids_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_app_ids_minimum_set_gen.py new file mode 100644 index 000000000000..9b9c210e7ec4 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_app_ids_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_app_ids_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_app_ids( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listAppIds_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_resource_group_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_resource_group_maximum_set_gen.py new file mode 100644 index 000000000000..1f57a312987c --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_resource_group_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_by_resource_group_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_by_resource_group( + resource_group_name="rgopenapi", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_ListByResourceGroup_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_resource_group_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_resource_group_minimum_set_gen.py new file mode 100644 index 000000000000..2ce09469f683 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_resource_group_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_by_resource_group_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_by_resource_group( + resource_group_name="rgopenapi", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_ListByResourceGroup_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_subscription_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_subscription_maximum_set_gen.py new file mode 100644 index 000000000000..6bb13e9c2c86 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_subscription_maximum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_by_subscription_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_ListBySubscription_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_subscription_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_subscription_minimum_set_gen.py new file mode 100644 index 000000000000..93e100965f32 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_by_subscription_minimum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_by_subscription_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_ListBySubscription_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_countries_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_countries_maximum_set_gen.py new file mode 100644 index 000000000000..206920f044e8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_countries_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_countries_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_countries( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listCountries_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_countries_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_countries_minimum_set_gen.py new file mode 100644 index 000000000000..2bea6be7e8ae --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_countries_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_countries_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_countries( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listCountries_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_firewalls_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_firewalls_maximum_set_gen.py new file mode 100644 index 000000000000..9b1a7d5b709e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_firewalls_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_firewalls_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_firewalls( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listFirewalls_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_firewalls_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_firewalls_minimum_set_gen.py new file mode 100644 index 000000000000..e60441e4a8f3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_firewalls_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_firewalls_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_firewalls( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listFirewalls_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_predefined_url_categories_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_predefined_url_categories_maximum_set_gen.py new file mode 100644 index 000000000000..722c3c00a3d1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_predefined_url_categories_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_predefined_url_categories_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_predefined_url_categories( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listPredefinedUrlCategories_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_predefined_url_categories_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_predefined_url_categories_minimum_set_gen.py new file mode 100644 index 000000000000..8f13e37a2189 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_predefined_url_categories_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_predefined_url_categories_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_predefined_url_categories( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listPredefinedUrlCategories_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_security_services_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_security_services_maximum_set_gen.py new file mode 100644 index 000000000000..30aee9a1c261 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_security_services_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_security_services_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_security_services( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + type="localRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listSecurityServices_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_security_services_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_security_services_minimum_set_gen.py new file mode 100644 index 000000000000..3196ef398241 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_list_security_services_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_list_security_services_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.list_security_services( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + type="localRulestacks", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_listSecurityServices_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_revert_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_revert_maximum_set_gen.py new file mode 100644 index 000000000000..98252995ef26 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_revert_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_revert_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.revert( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_revert_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_revert_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_revert_minimum_set_gen.py new file mode 100644 index 000000000000..eddfb006cac5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_revert_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_revert_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.revert( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_revert_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_update_maximum_set_gen.py new file mode 100644 index 000000000000..dea39e92a812 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/local_rulestacks_update_maximum_set_gen.py @@ -0,0 +1,67 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python local_rulestacks_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.local_rulestacks.update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + properties={ + "identity": { + "type": "None", + "userAssignedIdentities": {"key16": {"clientId": "aaaa", "principalId": "aaaaaaaaaaaaaaa"}}, + }, + "properties": { + "associatedSubscriptions": ["2bf4a339-294d-4c25-b0b2-ef649e9f5c27"], + "defaultMode": "IPS", + "description": "local rulestacks", + "minAppIdVersion": "8.5.3", + "panEtag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + "panLocation": "eastus", + "scope": "LOCAL", + "securityServices": { + "antiSpywareProfile": "default", + "antiVirusProfile": "default", + "dnsSubscription": "default", + "fileBlockingProfile": "default", + "outboundTrustCertificate": "default", + "outboundUnTrustCertificate": "default", + "urlFilteringProfile": "default", + "vulnerabilityProfile": "default", + }, + }, + "tags": {"tagName": "value"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/LocalRulestacks_Update_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/operations_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/operations_list_maximum_set_gen.py new file mode 100644 index 000000000000..be51c27dfd70 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/operations_list_maximum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python operations_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Operations_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/operations_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/operations_list_minimum_set_gen.py new file mode 100644 index 000000000000..0723c07be808 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/operations_list_minimum_set_gen.py @@ -0,0 +1,39 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python operations_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/Operations_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..4cf4c71cc18f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_create_or_update_maximum_set_gen.py @@ -0,0 +1,70 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.begin_create_or_update( + global_rulestack_name="lrs1", + priority="1", + resource={ + "properties": { + "actionType": "Allow", + "applications": ["app1"], + "auditComment": "example comment", + "category": {"feeds": ["feed"], "urlCustom": ["https://microsoft.com"]}, + "decryptionRuleType": "SSLOutboundInspection", + "description": "description of post rule", + "destination": { + "cidrs": ["1.0.0.1/10"], + "countries": ["India"], + "feeds": ["feed"], + "fqdnLists": ["FQDN1"], + "prefixLists": ["PL1"], + }, + "enableLogging": "DISABLED", + "etag": "c18e6eef-ba3e-49ee-8a85-2b36c863a9d0", + "inboundInspectionCertificate": "cert1", + "negateDestination": "TRUE", + "negateSource": "TRUE", + "protocol": "HTTP", + "protocolPortList": ["80"], + "provisioningState": "Accepted", + "ruleName": "postRule1", + "ruleState": "DISABLED", + "source": {"cidrs": ["1.0.0.1/10"], "countries": ["India"], "feeds": ["feed"], "prefixLists": ["PL1"]}, + "tags": [{"key": "keyName", "value": "value"}], + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..af384d759a3e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_create_or_update_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.begin_create_or_update( + global_rulestack_name="lrs1", + priority="1", + resource={"properties": {"ruleName": "postRule1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_delete_maximum_set_gen.py new file mode 100644 index 000000000000..3b198ae1ed21 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.begin_delete( + global_rulestack_name="lrs1", + priority="1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_delete_minimum_set_gen.py new file mode 100644 index 000000000000..37e8eb6f0bb6 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.begin_delete( + global_rulestack_name="lrs1", + priority="1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_counters_maximum_set_gen.py new file mode 100644 index 000000000000..2e68f5cf9544 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_counters_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_get_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.get_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_getCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_counters_minimum_set_gen.py new file mode 100644 index 000000000000..b83673aa730d --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_counters_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_get_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.get_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_getCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_maximum_set_gen.py new file mode 100644 index 000000000000..84734191d42e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.get( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_minimum_set_gen.py new file mode 100644 index 000000000000..8ea11dd8cdd1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.get( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_list_maximum_set_gen.py new file mode 100644 index 000000000000..94ec97700cd2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_list_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.list( + global_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_list_minimum_set_gen.py new file mode 100644 index 000000000000..229736b1bcc3 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_list_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.list( + global_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_refresh_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_refresh_counters_maximum_set_gen.py new file mode 100644 index 000000000000..5577996c5af9 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_refresh_counters_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_refresh_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.refresh_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_refreshCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_refresh_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_refresh_counters_minimum_set_gen.py new file mode 100644 index 000000000000..013c6b927308 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_refresh_counters_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_refresh_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.refresh_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_refreshCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_reset_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_reset_counters_maximum_set_gen.py new file mode 100644 index 000000000000..e9f4e1b82921 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_reset_counters_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_reset_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.reset_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_resetCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_reset_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_reset_counters_minimum_set_gen.py new file mode 100644 index 000000000000..f48bbcac0e18 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/post_rules_reset_counters_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python post_rules_reset_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.post_rules.reset_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PostRules_resetCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..7454bd50a441 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_create_or_update_maximum_set_gen.py @@ -0,0 +1,70 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.begin_create_or_update( + global_rulestack_name="lrs1", + priority="1", + resource={ + "properties": { + "actionType": "Allow", + "applications": ["app1"], + "auditComment": "example comment", + "category": {"feeds": ["feed"], "urlCustom": ["https://microsoft.com"]}, + "decryptionRuleType": "SSLOutboundInspection", + "description": "description of pre rule", + "destination": { + "cidrs": ["1.0.0.1/10"], + "countries": ["India"], + "feeds": ["feed"], + "fqdnLists": ["FQDN1"], + "prefixLists": ["PL1"], + }, + "enableLogging": "DISABLED", + "etag": "c18e6eef-ba3e-49ee-8a85-2b36c863a9d0", + "inboundInspectionCertificate": "cert1", + "negateDestination": "TRUE", + "negateSource": "TRUE", + "protocol": "HTTP", + "protocolPortList": ["80"], + "provisioningState": "Accepted", + "ruleName": "preRule1", + "ruleState": "DISABLED", + "source": {"cidrs": ["1.0.0.1/10"], "countries": ["India"], "feeds": ["feed"], "prefixLists": ["PL1"]}, + "tags": [{"key": "keyName", "value": "value"}], + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..05c81dd87b95 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_create_or_update_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.begin_create_or_update( + global_rulestack_name="lrs1", + priority="1", + resource={"properties": {"ruleName": "preRule1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_delete_maximum_set_gen.py new file mode 100644 index 000000000000..68a3ab97e1c1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.begin_delete( + global_rulestack_name="lrs1", + priority="1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_delete_minimum_set_gen.py new file mode 100644 index 000000000000..daa0916faef5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.begin_delete( + global_rulestack_name="lrs1", + priority="1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_counters_maximum_set_gen.py new file mode 100644 index 000000000000..b65119007c65 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_counters_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_get_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.get_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_getCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_counters_minimum_set_gen.py new file mode 100644 index 000000000000..60f8ff2320d1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_counters_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_get_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.get_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_getCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_maximum_set_gen.py new file mode 100644 index 000000000000..918463428303 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.get( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_minimum_set_gen.py new file mode 100644 index 000000000000..8accc9279f10 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.get( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_list_maximum_set_gen.py new file mode 100644 index 000000000000..458fc154185e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_list_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.list( + global_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_list_minimum_set_gen.py new file mode 100644 index 000000000000..b85e5fef13d6 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_list_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.list( + global_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_refresh_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_refresh_counters_maximum_set_gen.py new file mode 100644 index 000000000000..28af2599c7fa --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_refresh_counters_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_refresh_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.refresh_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_refreshCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_refresh_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_refresh_counters_minimum_set_gen.py new file mode 100644 index 000000000000..9487503e38be --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_refresh_counters_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_refresh_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.refresh_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_refreshCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_reset_counters_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_reset_counters_maximum_set_gen.py new file mode 100644 index 000000000000..c314247eb9a8 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_reset_counters_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_reset_counters_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.reset_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_resetCounters_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_reset_counters_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_reset_counters_minimum_set_gen.py new file mode 100644 index 000000000000..954bcf55429f --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/pre_rules_reset_counters_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python pre_rules_reset_counters_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.pre_rules.reset_counters( + global_rulestack_name="lrs1", + priority="1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PreRules_resetCounters_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..985bac3492fa --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,50 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + name="armid1", + resource={ + "properties": { + "auditComment": "comment", + "description": "string", + "etag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + "prefixList": ["1.0.0.0/24"], + "provisioningState": "Accepted", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..bc0cebd89ffa --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.begin_create_or_update( + global_rulestack_name="praval", + name="armid1", + resource={"properties": {"prefixList": ["1.0.0.0/24"]}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..96ab7dc85181 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.begin_delete( + global_rulestack_name="praval", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..ce7ee0db31e2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.begin_delete( + global_rulestack_name="praval", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..8bc7644a5648 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_get_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.get( + global_rulestack_name="praval", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..a9b66a2882cc --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_get_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.get( + global_rulestack_name="praval", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_list_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_list_maximum_set_gen.py new file mode 100644 index 000000000000..0a7f820df950 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_list_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_list_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.list( + global_rulestack_name="praval", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_list_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_list_minimum_set_gen.py new file mode 100644 index 000000000000..850e72cb44e6 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_global_rulestack_list_minimum_set_gen.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_global_rulestack_list_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.prefix_list_global_rulestack.list( + global_rulestack_name="praval", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListGlobalRulestack_List_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_create_or_update_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..95ccb01f0732 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_create_or_update_maximum_set_gen.py @@ -0,0 +1,51 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_create_or_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + resource={ + "properties": { + "auditComment": "comment", + "description": "string", + "etag": "2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + "prefixList": ["1.0.0.0/24"], + "provisioningState": "Accepted", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_create_or_update_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_create_or_update_minimum_set_gen.py new file mode 100644 index 000000000000..d7814b77cccf --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_create_or_update_minimum_set_gen.py @@ -0,0 +1,43 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_create_or_update_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.begin_create_or_update( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + resource={"properties": {"prefixList": ["1.0.0.0/24"]}}, + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_delete_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_delete_maximum_set_gen.py new file mode 100644 index 000000000000..9586fb37753b --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_delete_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_delete_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_delete_minimum_set_gen.py new file mode 100644 index 000000000000..034dc417bdc2 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_delete_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_delete_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.begin_delete( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ).result() + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_Delete_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_get_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_get_maximum_set_gen.py new file mode 100644 index 000000000000..0280b9c3bbc1 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_get_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_get_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_get_minimum_set_gen.py new file mode 100644 index 000000000000..8d9245aaf0fb --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_get_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_get_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.get( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + name="armid1", + ) + print(response) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_Get_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py new file mode 100644 index 000000000000..869bbefa2bb5 --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_list_by_local_rulestacks_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.list_by_local_rulestacks( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py new file mode 100644 index 000000000000..3172af13683a --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/generated_samples/prefix_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.paloaltonetworks import PaloAltoNetworksNgfwMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-paloaltonetworks +# USAGE + python prefix_list_local_rulestack_list_by_local_rulestacks_minimum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PaloAltoNetworksNgfwMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="2bf4a339-294d-4c25-b0b2-ef649e9f5c27", + ) + + response = client.prefix_list_local_rulestack.list_by_local_rulestacks( + resource_group_name="rgopenapi", + local_rulestack_name="lrs1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/preview/2022-08-29-preview/examples/PrefixListLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/sdk_packaging.toml b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/sdk_packaging.toml new file mode 100644 index 000000000000..b4bfe354591e --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/sdk_packaging.toml @@ -0,0 +1,10 @@ +[packaging] +package_name = "azure-mgmt-paloaltonetworksngfw" +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 +sample_link = "" diff --git a/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/setup.py b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/setup.py new file mode 100644 index 000000000000..3d7186a8a27b --- /dev/null +++ b/sdk/paloaltonetworks/azure-mgmt-paloaltonetworksngfw/setup.py @@ -0,0 +1,79 @@ +#!/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-paloaltonetworksngfw" +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.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + '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=[ + "isodate<1.0.0,>=0.6.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", + ], + python_requires=">=3.7" +) diff --git a/sdk/paloaltonetworks/ci.yml b/sdk/paloaltonetworks/ci.yml new file mode 100644 index 000000000000..6c2dded62c81 --- /dev/null +++ b/sdk/paloaltonetworks/ci.yml @@ -0,0 +1,34 @@ +# 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/paloaltonetworks/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/paloaltonetworks/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: paloaltonetworks + TestProxy: true + Artifacts: + - name: azure-mgmt-paloaltonetworksngfw + safeName: azuremgmtpaloaltonetworksngfw