From 082764b766ca6cc4e46b4fabd9d5245ca8886fee Mon Sep 17 00:00:00 2001 From: Zachery Lantz Date: Thu, 8 May 2025 13:48:52 -0400 Subject: [PATCH 1/3] tunnelstatuses support --- fmcapi/api_objects/__init__.py | 2 + fmcapi/api_objects/health/__init__.py | 1 + fmcapi/api_objects/health/tunnelstatuses.py | 54 +++++++++++++++++++++ unit_tests/__init__.py | 4 +- unit_tests/tunnelstatuses.py | 17 +++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 fmcapi/api_objects/health/tunnelstatuses.py create mode 100644 unit_tests/tunnelstatuses.py diff --git a/fmcapi/api_objects/__init__.py b/fmcapi/api_objects/__init__.py index c78db7b..7f952f0 100644 --- a/fmcapi/api_objects/__init__.py +++ b/fmcapi/api_objects/__init__.py @@ -110,6 +110,7 @@ from .policy_services import ConnectionProfiles from .policy_services import DynamicAccessPolicies from .object_services import TimeRanges +from .health import TunnelStatuses logging.debug("In the api_objects __init__.py file.") @@ -218,4 +219,5 @@ "ConnectionProfiles", "DynamicAccessPolicies", "TimeRanges", + "TunnelStatuses", ] diff --git a/fmcapi/api_objects/health/__init__.py b/fmcapi/api_objects/health/__init__.py index b3b1193..4012df7 100644 --- a/fmcapi/api_objects/health/__init__.py +++ b/fmcapi/api_objects/health/__init__.py @@ -2,6 +2,7 @@ import logging from .terminateravpnsessions import TerminateRAVPNSessions +from .tunnelstatuses import TunnelStatuses logging.debug("In the health __init__.py file.") diff --git a/fmcapi/api_objects/health/tunnelstatuses.py b/fmcapi/api_objects/health/tunnelstatuses.py new file mode 100644 index 0000000..adcd3b3 --- /dev/null +++ b/fmcapi/api_objects/health/tunnelstatuses.py @@ -0,0 +1,54 @@ +from fmcapi.api_objects.apiclasstemplate import APIClassTemplate +import logging + + +class TunnelStatuses(APIClassTemplate): + """The TunnelStatuses Object in the FMC.""" + + FIRST_SUPPORTED_FMC_VERSION = "7.3" + VALID_JSON_DATA = [ + "id", + "type", + "state", + "lastChange", + "vpnTopology", + "peerA", + "peerB", + ] + VALID_GET_FILTERS = [ + "vpnTopologyId", # vpnTopologyId: uuid of vpn topo + "deviceId", # deviceId: uuid of device + "status", # status: TUNNEL_UP|TUNNEL_DOWN|UNKNOWN + "deployedStatus", # deployedStatus: Deployed|Configured|Both + "sortBy", # sortBy: :|<|> Topology|Device|Status|LastChange (sortBy Date: Thu, 8 May 2025 14:03:55 -0400 Subject: [PATCH 2/3] support for tunneldetails --- fmcapi/api_objects/__init__.py | 2 + fmcapi/api_objects/health/__init__.py | 1 + fmcapi/api_objects/health/tunneldetails.py | 47 ++++++++++++++++++++++ unit_tests/__init__.py | 2 + unit_tests/tunneldetails.py | 12 ++++++ 5 files changed, 64 insertions(+) create mode 100644 fmcapi/api_objects/health/tunneldetails.py create mode 100644 unit_tests/tunneldetails.py diff --git a/fmcapi/api_objects/__init__.py b/fmcapi/api_objects/__init__.py index 7f952f0..3cfdb6f 100644 --- a/fmcapi/api_objects/__init__.py +++ b/fmcapi/api_objects/__init__.py @@ -111,6 +111,7 @@ from .policy_services import DynamicAccessPolicies from .object_services import TimeRanges from .health import TunnelStatuses +from .health import TunnelDetails logging.debug("In the api_objects __init__.py file.") @@ -220,4 +221,5 @@ "DynamicAccessPolicies", "TimeRanges", "TunnelStatuses", + "TunnelDetails", ] diff --git a/fmcapi/api_objects/health/__init__.py b/fmcapi/api_objects/health/__init__.py index 4012df7..668fbd8 100644 --- a/fmcapi/api_objects/health/__init__.py +++ b/fmcapi/api_objects/health/__init__.py @@ -3,6 +3,7 @@ import logging from .terminateravpnsessions import TerminateRAVPNSessions from .tunnelstatuses import TunnelStatuses +from .tunneldetails import TunnelDetails logging.debug("In the health __init__.py file.") diff --git a/fmcapi/api_objects/health/tunneldetails.py b/fmcapi/api_objects/health/tunneldetails.py new file mode 100644 index 0000000..5ed5f04 --- /dev/null +++ b/fmcapi/api_objects/health/tunneldetails.py @@ -0,0 +1,47 @@ +from fmcapi.api_objects.apiclasstemplate import APIClassTemplate +import logging + + +class TunnelDetails(APIClassTemplate): + """The TunnelDetails Object in the FMC.""" + + FIRST_SUPPORTED_FMC_VERSION = "7.3" + REQUIRED_FOR_GET = ["container_uuid"] + VALID_JSON_DATA = [ + "type", + "peerA", + "peerB", + ] + + VALID_FOR_KWARGS = VALID_JSON_DATA + ["container_uuid"] + + URL_SUFFIX = f"/health/tunnelstatuses" + + def __init__(self, fmc, **kwargs): + """ + Initialize TunnelDetails object. + + :param fmc (object): FMC object + :param **kwargs: Any other values passed during instantiation. + :return: requests response + """ + super().__init__(fmc, **kwargs) + logging.debug("In __init__() for TunnelDetails class.") + self.parse_kwargs(**kwargs) + URL_CONTAINER_SUFFIX = f"/{self.container_uuid}/tunneldetails" + self.URL = self.URL + URL_CONTAINER_SUFFIX + + def delete(self, **kwargs): + """DELETE method for API for TunnelDetails not supported.""" + logging.info("DELETE method for API for TunnelDetails not supported.") + pass + + def put(self): + """PUT method for API for TunnelDetails not supported.""" + logging.info("PUT method for API for TunnelDetails not supported.") + pass + + def post(self, **kwargs): + """POST method for API for TunnelDetails not supported.""" + logging.info("POST method for API for TunnelDetails not supported.") + pass \ No newline at end of file diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index 8c6485e..112ff8e 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -80,6 +80,7 @@ from .timeranges import test__timeranges from .fqdns import test__fqdns from .tunnelstatuses import test__tunnelstatuses +from .tunneldetails import test__tunneldetails logging.debug("In the unit-tests __init__.py file.") @@ -164,4 +165,5 @@ "test__timeranges", "test__fqdns", "test__tunnelstatuses", + "test__tunneldetails", ] diff --git a/unit_tests/tunneldetails.py b/unit_tests/tunneldetails.py new file mode 100644 index 0000000..a286679 --- /dev/null +++ b/unit_tests/tunneldetails.py @@ -0,0 +1,12 @@ +import logging +import fmcapi + + +def test__tunneldetails(fmc): + logging.info("Test TunnelDetails. Get TunnelDetails.") + + obj1 = fmcapi.TunnelDetails(fmc=fmc, container_uuid="40A6B737-FDDC-0ed3-0000-000000000297") # Tunnel uuid not topology uuid + tunnel_details = obj1.get() + del obj1 + + logging.info("Test TunnelDetails done.\n") \ No newline at end of file From 850e308a2c9ae4017261f5c7bcd52e3fd09a1049 Mon Sep 17 00:00:00 2001 From: Zachery Lantz Date: Thu, 8 May 2025 14:09:47 -0400 Subject: [PATCH 3/3] tunnel summary support --- fmcapi/api_objects/__init__.py | 2 + fmcapi/api_objects/health/__init__.py | 1 + fmcapi/api_objects/health/tunnelsummaries.py | 50 ++++++++++++++++++++ unit_tests/__init__.py | 2 + unit_tests/tunnelsummaries.py | 12 +++++ 5 files changed, 67 insertions(+) create mode 100644 fmcapi/api_objects/health/tunnelsummaries.py create mode 100644 unit_tests/tunnelsummaries.py diff --git a/fmcapi/api_objects/__init__.py b/fmcapi/api_objects/__init__.py index 3cfdb6f..f1013de 100644 --- a/fmcapi/api_objects/__init__.py +++ b/fmcapi/api_objects/__init__.py @@ -112,6 +112,7 @@ from .object_services import TimeRanges from .health import TunnelStatuses from .health import TunnelDetails +from .health import TunnelSummaries logging.debug("In the api_objects __init__.py file.") @@ -222,4 +223,5 @@ "TimeRanges", "TunnelStatuses", "TunnelDetails", + "TunnelSummaries", ] diff --git a/fmcapi/api_objects/health/__init__.py b/fmcapi/api_objects/health/__init__.py index 668fbd8..8814a9b 100644 --- a/fmcapi/api_objects/health/__init__.py +++ b/fmcapi/api_objects/health/__init__.py @@ -4,6 +4,7 @@ from .terminateravpnsessions import TerminateRAVPNSessions from .tunnelstatuses import TunnelStatuses from .tunneldetails import TunnelDetails +from .tunnelsummaries import TunnelSummaries logging.debug("In the health __init__.py file.") diff --git a/fmcapi/api_objects/health/tunnelsummaries.py b/fmcapi/api_objects/health/tunnelsummaries.py new file mode 100644 index 0000000..74c79d1 --- /dev/null +++ b/fmcapi/api_objects/health/tunnelsummaries.py @@ -0,0 +1,50 @@ +from fmcapi.api_objects.apiclasstemplate import APIClassTemplate +import logging + + +class TunnelSummaries(APIClassTemplate): + """The TunnelSummaries Object in the FMC.""" + + FIRST_SUPPORTED_FMC_VERSION = "7.3" + VALID_JSON_DATA = [ + "tunnelCount", + "tunnelUpCount", + "tunnelDownCount", + "tunnelUnknownCount", + "type", + ] + VALID_GET_FILTERS = [ + "vpnTopologyId", # vpnTopologyId: uuid of vpn topo + "deviceId", # deviceId: uuid of device + "groupBy", # Topology|Device + ] + VALID_FOR_KWARGS = VALID_JSON_DATA + VALID_GET_FILTERS + [] + + URL_SUFFIX = "/health/tunnelsummaries" + + def __init__(self, fmc, **kwargs): + """ + Initialize TunnelSummaries object. + + :param fmc (object): FMC object + :param **kwargs: Any other values passed during instantiation. + :return: requests response + """ + super().__init__(fmc, **kwargs) + logging.debug("In __init__() for TunnelSummaries class.") + self.parse_kwargs(**kwargs) + + def delete(self, **kwargs): + """DELETE method for API for TunnelSummaries not supported.""" + logging.info("DELETE method for API for TunnelSummaries not supported.") + pass + + def put(self): + """PUT method for API for TunnelSummaries not supported.""" + logging.info("PUT method for API for TunnelSummaries not supported.") + pass + + def post(self, **kwargs): + """POST method for API for TunnelSummaries not supported.""" + logging.info("POST method for API for TunnelSummaries not supported.") + pass \ No newline at end of file diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index 112ff8e..20ee091 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -81,6 +81,7 @@ from .fqdns import test__fqdns from .tunnelstatuses import test__tunnelstatuses from .tunneldetails import test__tunneldetails +from .tunnelsummaries import test__tunnelsummaries logging.debug("In the unit-tests __init__.py file.") @@ -166,4 +167,5 @@ "test__fqdns", "test__tunnelstatuses", "test__tunneldetails", + "test__tunnelsummaries", ] diff --git a/unit_tests/tunnelsummaries.py b/unit_tests/tunnelsummaries.py new file mode 100644 index 0000000..e964007 --- /dev/null +++ b/unit_tests/tunnelsummaries.py @@ -0,0 +1,12 @@ +import logging +import fmcapi + + +def test__tunnelsummaries(fmc): + logging.info("Test TunnelSummaries. Get TunnelSummaries.") + + obj1 = fmcapi.TunnelSummaries(fmc=fmc) + tunnel_summaries = obj1.get() + del obj1 + + logging.info("Test TunnelSummaries done.\n") \ No newline at end of file