Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/prefilter-support'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dax Mickelson committed Nov 30, 2019
2 parents 865ef2a + f557471 commit bc9acc6
Show file tree
Hide file tree
Showing 6 changed files with 804 additions and 14 deletions.
2 changes: 2 additions & 0 deletions fmcapi/api_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
from .policy_services.natrules import NatRules
from .policy_services.prefilterpolicies import PreFilterPolicies
from .policy_services.prefilterpolicies import PreFilterPolicy
from .policy_services.prefilterrules import PreFilterRules

from .policy_assignment_services.policyassignments import PolicyAssignments

Expand Down Expand Up @@ -280,6 +281,7 @@
"IntrusionPolicy",
"PreFilterPolicies",
"PreFilterPolicy",
"PreFilterRules",
"HitCounts",
"HitCount",
"TaskStatuses",
Expand Down
34 changes: 25 additions & 9 deletions fmcapi/api_objects/policy_services/prefilterpolicies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,45 @@ class PreFilterPolicies(APIClassTemplate):
The PreFilterPolicies Object in the FMC.
"""

VALID_JSON_DATA = ["id", "name"]
VALID_JSON_DATA = ["id", "name", "type", "description", "defaultAction"]
VALID_FOR_KWARGS = VALID_JSON_DATA + []
URL_SUFFIX = "/policy/prefilterpolicies"
VALID_CHARACTERS_FOR_NAME = """[.\w\d_\- ]"""
REQUIRED_FOR_POST = ["name"]
DEFAULT_ACTION_OPTIONS = ["ANALYZE_TUNNELS", "BOCK_TUNNELS"]
FIRST_SUPPORTED_FMC_VERSION = "6.5"

def __init__(self, fmc, **kwargs):
super().__init__(fmc, **kwargs)
logging.debug("In __init__() for PreFilterPolicies class.")
self.parse_kwargs(**kwargs)
self.type = "PreFilterPolicy"

def post(self):
logging.info("POST method for API for PreFilterPolicies not supported.")
pass
self._defaultAction = None
self.defaultAction = "ANALYZE_TUNNELS"

@property
def defaultAction(self):
return {"type": "PrefilterPolicyDefaultAction", "action": self._defaultAction}

@defaultAction.setter
def defaultAction(self, action):
if action in self.DEFAULT_ACTION_OPTIONS:
self._defaultAction = action
else:
logging.error(
f"action, {action}, is not a valid option. Choose from {self.DEFAULT_ACTION_OPTIONS}."
)

def format_data(self):
json_data = super().format_data()
logging.debug("In format_data() for AccessPolicies class.")
json_data["defaultAction"] = self.defaultAction
return json_data

def put(self):
logging.info("PUT method for API for PreFilterPolicies not supported.")
pass

def delete(self):
logging.info("DELETE method for API for PreFilterPolicies not supported.")
pass


class PreFilterPolicy(PreFilterPolicies):
"""Dispose of this Class after 20210101."""
Expand Down
Loading

0 comments on commit bc9acc6

Please sign in to comment.