Skip to content

Commit

Permalink
feat: Add EDL support (PaloAltoNetworks#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinmog authored May 13, 2021
1 parent fdef980 commit 1f4f250
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 0 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.LogForwardingProfile",
"objects.DynamicUserGroup",
"objects.Region",
"objects.Edl",
"policies.Rulebase",
"network.EthernetInterface",
"network.AggregateInterface",
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.LogForwardingProfile",
"objects.DynamicUserGroup",
"objects.Region",
"objects.Edl",
"policies.Rulebase",
"network.EthernetInterface",
"network.AggregateInterface",
Expand Down
161 changes: 161 additions & 0 deletions panos/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,3 +1081,164 @@ def _setup(self):
)

self._params = tuple(params)


class Edl(VersionedPanObject):
"""External Dynamic List.
Args:
name (str): The name.
edl_type (str): The EDL type.
description (str): Description.
source (str): Source.
exceptions (list): (PAN-OS 8.0+) Exceptions.
certificate_profile (str): (PAN-OS 8.0+) Profile for authenticating client certificates.
username (str): (PAN-OS 8.0+) Username auth.
password (str): (PAN-OS 8.0+) Password auth.
expand_domain (bool): (PAN-OS 9.0+) Enable/disable expand domain (requires
`edl_type=domain`).
repeat (str): Retrieval interval. Valid values are "five-minute", "hourly",
"daily", "weekly", or "monthly".
repeat_at (str): The time specification for the given repeat value.
repeat_day_of_week (str): For `repeat=daily`, the day of the week.
repeat_day_of_month (int): For `repeat=monthly`, the day of the month.
"""

ROOT = Root.VSYS
SUFFIX = ENTRY

def _setup(self):
# xpaths
self._xpaths.add_profile(value="/external-list")

# params
params = []

params.append(
VersionedParamPath(
"edl_type", default="ip", path="type", values=("ip", "domain", "url"),
),
)
params[-1].add_profile(
"8.0.0",
path="type/{edl_type}",
values=("ip", "domain", "url", "predefined-ip"),
)
params[-1].add_profile(
"10.0.0",
path="type/{edl_type}",
values=("ip", "domain", "url", "predefined-ip", "predefined-url"),
)
params.append(VersionedParamPath("description", path="description",),)
params[-1].add_profile(
"8.0.0", path="type/{edl_type}/description",
)
params.append(VersionedParamPath("source", path="url",),)
params[-1].add_profile(
"8.0.0", path="type/{edl_type}/url",
)
params.append(VersionedParamPath("exceptions", exclude=True,),)
params[-1].add_profile(
"8.0.0", vartype="member", path="type/{edl_type}/exception-list",
)
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[-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[-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[-1].add_profile(
"9.0.0",
path="type/{edl_type}/expand-domain",
vartype="yesno",
condition={"edl_type": "domain"},
)
params.append(
VersionedParamPath(
"repeat",
path="recurring/{repeat}",
values=("five-minute", "hourly", "daily", "weekly", "monthly"),
),
)
params[-1].add_profile(
"8.0.0",
path="type/{edl_type}/recurring/{repeat}",
values=("five-minute", "hourly", "daily", "weekly", "monthly"),
condition={"edl_type": ["ip", "domain", "url"]},
)
params.append(
VersionedParamPath(
"repeat_at",
path="recurring/{repeat}/at",
condition={"repeat": ["daily", "weekly", "monthly"]},
),
)
params[-1].add_profile(
"8.0.0",
path="type/{edl_type}/recurring/{repeat}/at",
condition={
"edl_type": ["ip", "domain", "url"],
"repeat": ["daily", "weekly", "monthly"],
},
)
params.append(
VersionedParamPath(
"repeat_day_of_week",
path="recurring/{repeat}/day-of-week",
condition={"repeat": "weekly"},
values=(
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
),
),
)
params[-1].add_profile(
"8.0.0",
path="type/{edl_type}/recurring/{repeat}/day-of-week",
values=(
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
),
condition={"edl_type": ["ip", "domain", "url"], "repeat": "weekly",},
)
params.append(
VersionedParamPath(
"repeat_day_of_month",
vartype="int",
path="recurring/{repeat}/day-of-month",
condition={"repeat": "monthly"},
),
)
params[-1].add_profile(
"8.0.0",
vartype="int",
path="type/{edl_type}/recurring/{repeat}/day-of-month",
condition={"edl_type": ["ip", "domain", "url"], "repeat": "monthly",},
)

self._params = tuple(params)
1 change: 1 addition & 0 deletions panos/panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DeviceGroup(VersionedPanObject):
"objects.CustomUrlCategory",
"objects.LogForwardingProfile",
"objects.Region",
"objects.Edl",
"policies.PreRulebase",
"policies.PostRulebase",
)
Expand Down

0 comments on commit 1f4f250

Please sign in to comment.