From d9a793566d5cc9280d6957b1a6590ad1b45a3a4b Mon Sep 17 00:00:00 2001 From: Brian Torres-Gil Date: Fri, 4 Feb 2022 16:01:04 -0800 Subject: [PATCH] feat: ApplicationTag - tag predefined applications --- panos/device.py | 1 + panos/firewall.py | 1 + panos/objects.py | 110 +++++++++++++++++++++++++++++++++++++++------- panos/panorama.py | 2 + 4 files changed, 98 insertions(+), 16 deletions(-) diff --git a/panos/device.py b/panos/device.py index 9302ddbe..d3b6f2a2 100644 --- a/panos/device.py +++ b/panos/device.py @@ -130,6 +130,7 @@ class Vsys(VersionedPanObject): "objects.Tag", "objects.ApplicationObject", "objects.ApplicationGroup", + "objects.ApplicationTag", "objects.ApplicationFilter", "objects.ApplicationContainer", "objects.ScheduleObject", diff --git a/panos/firewall.py b/panos/firewall.py index ad0f98df..49c8ae3a 100644 --- a/panos/firewall.py +++ b/panos/firewall.py @@ -84,6 +84,7 @@ class Firewall(PanDevice): "objects.Tag", "objects.ApplicationObject", "objects.ApplicationGroup", + "objects.ApplicationTag", "objects.ApplicationFilter", "objects.ApplicationContainer", "objects.ScheduleObject", diff --git a/panos/objects.py b/panos/objects.py index dd7a4425..bf688b1c 100644 --- a/panos/objects.py +++ b/panos/objects.py @@ -319,7 +319,8 @@ def _setup(self): # xpaths self._xpaths.add_profile(value="/application") self._xpaths.add_profile( - value='//*[contains(local-name(), "application")]', parents=("Predefined",), + value='//*[contains(local-name(), "application")]', + parents=("Predefined",), ) # params @@ -484,6 +485,32 @@ def _setup(self): self._params = tuple(params) +class ApplicationTag(VersionedPanObject): + """ApplicationTag Object + + Applies an administrative tag to a predefined application + + Args: + name (str): Name of predefined application + tags (list): Administrative tags + + """ + + ROOT = Root.VSYS + SUFFIX = ENTRY + + def _setup(self): + # xpaths + self._xpaths.add_profile(value="/application-tag") + + # params + params = [] + + params.append(VersionedParamPath("tags", path="tag", vartype="member")) + + self._params = tuple(params) + + class ApplicationFilter(VersionedPanObject): """ApplicationFilter Object @@ -589,7 +616,8 @@ def _setup(self): # xpaths self._xpaths.add_profile(value="/application-container") self._xpaths.add_profile( - value='//*[contains(local-name(), "application")]', parents=("Predefined",), + value='//*[contains(local-name(), "application")]', + parents=("Predefined",), ) # params @@ -833,7 +861,9 @@ def _setup(self): VersionedParamPath( "action_type", default="tagging", - values=["tagging",], + values=[ + "tagging", + ], path="type/{action_type}", ) ) @@ -1123,7 +1153,10 @@ def _setup(self): params.append( VersionedParamPath( - "edl_type", default="ip", path="type", values=("ip", "domain", "url"), + "edl_type", + default="ip", + path="type", + values=("ip", "domain", "url"), ), ) params[-1].add_profile( @@ -1136,38 +1169,77 @@ def _setup(self): path="type/{edl_type}", values=("ip", "domain", "url", "predefined-ip", "predefined-url"), ) - params.append(VersionedParamPath("description", path="description",),) + params.append( + VersionedParamPath( + "description", + path="description", + ), + ) params[-1].add_profile( - "8.0.0", path="type/{edl_type}/description", + "8.0.0", + path="type/{edl_type}/description", + ) + params.append( + VersionedParamPath( + "source", + path="url", + ), ) - params.append(VersionedParamPath("source", path="url",),) params[-1].add_profile( - "8.0.0", path="type/{edl_type}/url", + "8.0.0", + path="type/{edl_type}/url", + ) + params.append( + VersionedParamPath( + "exceptions", + exclude=True, + ), ) - params.append(VersionedParamPath("exceptions", exclude=True,),) params[-1].add_profile( - "8.0.0", vartype="member", path="type/{edl_type}/exception-list", + "8.0.0", + vartype="member", + path="type/{edl_type}/exception-list", + ) + params.append( + VersionedParamPath( + "certificate_profile", + exclude=True, + ) ) - params.append(VersionedParamPath("certificate_profile", exclude=True,)) params[-1].add_profile( "8.0.0", path="type/{edl_type}/certificate-profile", condition={"edl_type": ["ip", "domain", "url"]}, ) - params.append(VersionedParamPath("username", exclude=True,)) + params.append( + VersionedParamPath( + "username", + exclude=True, + ) + ) params[-1].add_profile( "8.0.0", path="type/{edl_type}/auth/username", condition={"edl_type": ["ip", "domain", "url"]}, ) - params.append(VersionedParamPath("password", exclude=True,)) + params.append( + VersionedParamPath( + "password", + exclude=True, + ) + ) params[-1].add_profile( "8.0.0", path="type/{edl_type}/auth/password", vartype="encrypted", condition={"edl_type": ["ip", "domain", "url"]}, ) - params.append(VersionedParamPath("expand_domain", exclude=True,),) + params.append( + VersionedParamPath( + "expand_domain", + exclude=True, + ), + ) params[-1].add_profile( "9.0.0", path="type/{edl_type}/expand-domain", @@ -1230,7 +1302,10 @@ def _setup(self): "friday", "saturday", ), - condition={"edl_type": ["ip", "domain", "url"], "repeat": "weekly",}, + condition={ + "edl_type": ["ip", "domain", "url"], + "repeat": "weekly", + }, ) params.append( VersionedParamPath( @@ -1244,7 +1319,10 @@ def _setup(self): "8.0.0", vartype="int", path="type/{edl_type}/recurring/{repeat}/day-of-month", - condition={"edl_type": ["ip", "domain", "url"], "repeat": "monthly",}, + condition={ + "edl_type": ["ip", "domain", "url"], + "repeat": "monthly", + }, ) self._params = tuple(params) diff --git a/panos/panorama.py b/panos/panorama.py index d41535f6..cc446290 100644 --- a/panos/panorama.py +++ b/panos/panorama.py @@ -111,6 +111,7 @@ class DeviceGroup(VersionedPanObject): "objects.ServiceGroup", "objects.ApplicationObject", "objects.ApplicationGroup", + "objects.ApplicationTag", "objects.ApplicationFilter", "objects.ScheduleObject", "objects.SecurityProfileGroup", @@ -428,6 +429,7 @@ class Panorama(base.PanDevice): "objects.Tag", "objects.ApplicationObject", "objects.ApplicationGroup", + "objects.ApplicationTag", "objects.ApplicationFilter", "objects.ApplicationContainer", "objects.ScheduleObject",