Skip to content

Commit

Permalink
feat: ApplicationTag - tag predefined applications
Browse files Browse the repository at this point in the history
  • Loading branch information
btorresgil committed Feb 14, 2022
1 parent f4f08d0 commit d9a7935
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 16 deletions.
1 change: 1 addition & 0 deletions panos/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class Vsys(VersionedPanObject):
"objects.Tag",
"objects.ApplicationObject",
"objects.ApplicationGroup",
"objects.ApplicationTag",
"objects.ApplicationFilter",
"objects.ApplicationContainer",
"objects.ScheduleObject",
Expand Down
1 change: 1 addition & 0 deletions panos/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Firewall(PanDevice):
"objects.Tag",
"objects.ApplicationObject",
"objects.ApplicationGroup",
"objects.ApplicationTag",
"objects.ApplicationFilter",
"objects.ApplicationContainer",
"objects.ScheduleObject",
Expand Down
110 changes: 94 additions & 16 deletions panos/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -833,7 +861,9 @@ def _setup(self):
VersionedParamPath(
"action_type",
default="tagging",
values=["tagging",],
values=[
"tagging",
],
path="type/{action_type}",
)
)
Expand Down Expand Up @@ -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(
Expand All @@ -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",
Expand Down Expand Up @@ -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(
Expand All @@ -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)
2 changes: 2 additions & 0 deletions panos/panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class DeviceGroup(VersionedPanObject):
"objects.ServiceGroup",
"objects.ApplicationObject",
"objects.ApplicationGroup",
"objects.ApplicationTag",
"objects.ApplicationFilter",
"objects.ScheduleObject",
"objects.SecurityProfileGroup",
Expand Down Expand Up @@ -428,6 +429,7 @@ class Panorama(base.PanDevice):
"objects.Tag",
"objects.ApplicationObject",
"objects.ApplicationGroup",
"objects.ApplicationTag",
"objects.ApplicationFilter",
"objects.ApplicationContainer",
"objects.ScheduleObject",
Expand Down

0 comments on commit d9a7935

Please sign in to comment.