Skip to content

Commit

Permalink
Merge pull request #182 from marksull/release/20240328.0
Browse files Browse the repository at this point in the history
Release/20240328.0
  • Loading branch information
marksull committed Mar 27, 2024
2 parents 8f9fb1c + 34e11b7 commit 2af5775
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 55 deletions.
56 changes: 30 additions & 26 deletions fmcapi/api_objects/device_services/devicerecords.py
Expand Up @@ -24,33 +24,37 @@ class DeviceRecords(APIClassTemplate):
VALID_GET_FILTERS = [
# TODO: name as a get filter will conflict with existing logic to look something up by name - use hostname instead for now
# "name", # String
"hostName", # String
"serialNumber", # String
"containerType", # DeviceCluster|DeviceHAPair|DeviceStack
"clusterBootstrapSupported", # Bool
"analyticsOnly", # Bool
"includeOtherAssociatedPolicies", # Bool
"modeType" # NGFW|Chassis
]
VALID_FOR_KWARGS = VALID_JSON_DATA + VALID_GET_FILTERS + [
"acp_name",
"acp_id",
"model",
"modelId",
"modelNumber",
"modelType",
"healthStatus",
"healthPolicy",
"type",
"version",
"sw_version",
"deviceGroup",
"prohibitPacketTransfer",
"keepLocalEvents",
"ftdMode",
"keepLocalEvents",
"expanded"
"hostName", # String
"serialNumber", # String
"containerType", # DeviceCluster|DeviceHAPair|DeviceStack
"clusterBootstrapSupported", # Bool
"analyticsOnly", # Bool
"includeOtherAssociatedPolicies", # Bool
"modeType", # NGFW|Chassis
]
VALID_FOR_KWARGS = (
VALID_JSON_DATA
+ VALID_GET_FILTERS
+ [
"acp_name",
"acp_id",
"model",
"modelId",
"modelNumber",
"modelType",
"healthStatus",
"healthPolicy",
"type",
"version",
"sw_version",
"deviceGroup",
"prohibitPacketTransfer",
"keepLocalEvents",
"ftdMode",
"keepLocalEvents",
"expanded",
]
)
URL_SUFFIX = "/devices/devicerecords"
REQUIRED_FOR_POST = ["accessPolicy", "hostName", "regKey", "type"]
REQUIRED_FOR_PUT = ["id"]
Expand Down
26 changes: 13 additions & 13 deletions fmcapi/api_objects/object_services/grouppolicies.py
Expand Up @@ -11,26 +11,26 @@ class GroupPolicies(APIClassTemplate):
"id",
"name",
"type",
"generalSettings", # Dict
"anyConnectSettings", # Dict
"advancedSettings", # Dict
"enableSSLProtocol", # Bool
"enableIPsecIKEv2Protocol", # Bool
"generalSettings", # Dict
"anyConnectSettings", # Dict
"advancedSettings", # Dict
"enableSSLProtocol", # Bool
"enableIPsecIKEv2Protocol", # Bool
]
VALID_GET_FILTERS = [
"unusedOnly", # Bool
"nameOrValue", # String
"unusedOnly", # Bool
"nameOrValue", # String
]
VALID_FOR_KWARGS = VALID_JSON_DATA + VALID_GET_FILTERS + []
URL_SUFFIX = "/object/grouppolicies"
REQUIRED_FOR_PUT = [
"id",
"name",
"generalSettings", # Dict
"anyConnectSettings", # Dict
"advancedSettings", # Dict
"enableSSLProtocol", # Bool
"enableIPsecIKEv2Protocol", # Bool
"generalSettings", # Dict
"anyConnectSettings", # Dict
"advancedSettings", # Dict
"enableSSLProtocol", # Bool
"enableIPsecIKEv2Protocol", # Bool
]

def __init__(self, fmc, **kwargs):
Expand All @@ -44,4 +44,4 @@ def __init__(self, fmc, **kwargs):
super().__init__(fmc, **kwargs)
logging.debug("In __init__() for GroupPolicies class.")
self.type = "GroupPolicy"
self.parse_kwargs(**kwargs)
self.parse_kwargs(**kwargs)
6 changes: 3 additions & 3 deletions fmcapi/api_objects/policy_services/connectionprofiles.py
Expand Up @@ -8,7 +8,7 @@ class ConnectionProfiles(APIClassTemplate):
"""The ConnectionProfiles Object in the FMC."""

REQUIRED_FOR_GET = ["container_uuid"]
REQUIRED_FOR_POST = ["container_uuid","name"]
REQUIRED_FOR_POST = ["container_uuid", "name"]
REQUIRED_FOR_PUT = ["container_uuid", "id"]
REQUIRED_FOR_DELETE = ["container_uuid", "id"]
VALID_JSON_DATA = [
Expand All @@ -27,9 +27,9 @@ class ConnectionProfiles(APIClassTemplate):
"allowConnectionOnlyIfAuthorized",
"enablePasswordManagement",
"stripGroupFromUsername",
"stripRealmFromUsername"
"stripRealmFromUsername",
]
VALID_FOR_KWARGS = VALID_JSON_DATA + ["container_uuid"]
VALID_FOR_KWARGS = VALID_JSON_DATA + ["container_uuid"]
URL_SUFFIX = "/policy/ravpns"
FIRST_SUPPORTED_FMC_VERSION = "7.2"

Expand Down
18 changes: 7 additions & 11 deletions fmcapi/api_objects/policy_services/dynamicaccesspolicies.py
Expand Up @@ -8,6 +8,7 @@

class DynamicAccessPolicies(APIClassTemplate):
"""The DynamicAccessPolicies Object in the FMC."""

REQUIRED_FOR_PUT = [
"id",
"authorizationAttributes",
Expand Down Expand Up @@ -40,7 +41,6 @@ def __init__(self, fmc, **kwargs):
self.parse_kwargs(**kwargs)

def unpack_xml_config(self, encoded_xml):

"""
Unpack and reformat base64 encoded xml from DAP api responses
Expand All @@ -57,7 +57,6 @@ def unpack_xml_config(self, encoded_xml):
return xml_dict

def repack_xml_config(self, xml_dict):

"""Repack dict into xml and encoded for use with DAP api calls
Args:
Expand All @@ -74,7 +73,6 @@ def repack_xml_config(self, xml_dict):
return encoded_xml_string

def get(self, **kwargs):

"""
Modified get() for DynamicAccessPolicies class to make working with
dapXmlConfig and hostscanXmlConfig a bit easier. This will create self.dapXmlConfig_dict
Expand All @@ -83,41 +81,39 @@ def get(self, **kwargs):

super().get(**kwargs)
logging.debug("In get() for DynamicAccessPolicies class.")
if hasattr(self, 'dapXmlConfig'):
if hasattr(self, "dapXmlConfig"):
self.dapXmlConfig_dict = self.unpack_xml_config(self.dapXmlConfig)

if hasattr(self, 'hostscanXmlConfig'):
if hasattr(self, "hostscanXmlConfig"):
self.hostscanXmlConfig_dict = self.unpack_xml_config(self.hostscanXmlConfig)

def post(self, **kwargs):

"""
Modified post() for DynamicAccessPolicies class to make working with
dapXmlConfig and hostscanXmlConfig a bit easier. This will take self.dapXmlConfig_dict
and self.hostscanXmlConfig_dict and convert to xml before base64 encoding for use with api endpoint.
"""

if hasattr(self, 'dapXmlConfig_dict'):
if hasattr(self, "dapXmlConfig_dict"):
self.dapXmlConfig = self.repack_xml_config(self.dapXmlConfig_dict)

if hasattr(self, 'hostscanXmlConfig_dict'):
if hasattr(self, "hostscanXmlConfig_dict"):
self.hostscanXmlConfig = self.repack_xml_config(self.hostscanXmlConfig_dict)

super().post(**kwargs)
logging.debug("In post() for DynamicAccessPolicies class.")

def put(self, **kwargs):

"""
Modified put() for DynamicAccessPolicies class to make working with
dapXmlConfig and hostscanXmlConfig a bit easier. This will take self.dapXmlConfig_dict
and self.hostscanXmlConfig_dict and convert to xml before base64 encoding for use with api endpoint.
"""

if hasattr(self, 'dapXmlConfig_dict'):
if hasattr(self, "dapXmlConfig_dict"):
self.dapXmlConfig = self.repack_xml_config(self.dapXmlConfig_dict)

if hasattr(self, 'hostscanXmlConfig_dict'):
if hasattr(self, "hostscanXmlConfig_dict"):
self.hostscanXmlConfig = self.repack_xml_config(self.hostscanXmlConfig_dict)

super().put(**kwargs)
Expand Down
3 changes: 2 additions & 1 deletion fmcapi/api_objects/policy_services/ravpns.py
Expand Up @@ -6,6 +6,7 @@

class RAVpn(APIClassTemplate):
"""The RAVpn Object in the FMC."""

VALID_JSON_DATA = [
"id",
"name",
Expand All @@ -25,7 +26,7 @@ class RAVpn(APIClassTemplate):
"ldapAttributeMaps",
"loadBalanceSettings",
"configureSSL",
"configureIpsec"
"configureIpsec",
]
VALID_FOR_KWARGS = VALID_JSON_DATA + []
URL_SUFFIX = "/policy/ravpns"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -6,7 +6,7 @@

setup(
name="fmcapi",
version="20240130.0",
version="20240328.0",
description="Easier interface to Cisco's FMC API than writing your own way.",
long_description="""With the removal to configure a Cisco NGFW via the command line your only option is to
do so via a manager. Some things are better when automated so using the manager's API gives us that power.
Expand Down

0 comments on commit 2af5775

Please sign in to comment.