Skip to content

Commit

Permalink
added support for objects.timeranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachery Lantz committed Apr 17, 2024
1 parent 9119042 commit 33ea9a2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions TestingUserScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def main():
# unit_tests.test__ravpn(fmc=fmc1)
# unit_tests.test__connectionprofiles(fmc=fmc1) # Requires existing RAVPN Policy ID
# unit_tests.test__dynamicaccesspolicies(fmc=fmc1)
# unit_tests.test__timeranges(fmc=fmc1)


"""
Expand Down
2 changes: 2 additions & 0 deletions fmcapi/api_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
from .policy_services.ravpns import RAVpn
from .policy_services import ConnectionProfiles
from .policy_services import DynamicAccessPolicies
from .object_services import TimeRanges

logging.debug("In the api_objects __init__.py file.")

Expand Down Expand Up @@ -216,4 +217,5 @@
"RAVpn",
"ConnectionProfiles",
"DynamicAccessPolicies",
"TimeRanges",
]
2 changes: 2 additions & 0 deletions fmcapi/api_objects/object_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from .dynamicobjects import DynamicObject
from .dynamicobjectmappings import DynamicObjectMappings
from .grouppolicies import GroupPolicies
from .timeranges import TimeRanges

logging.debug("In the object_services __init__.py file.")

Expand Down Expand Up @@ -110,4 +111,5 @@
"VlanTags",
"DynamicObjectMappings",
"DynamicObject",
"TimeRanges",
]
36 changes: 36 additions & 0 deletions fmcapi/api_objects/object_services/timeranges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Time Ranges Class."""

from fmcapi.api_objects.apiclasstemplate import APIClassTemplate
import logging


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

VALID_JSON_DATA = [
"id",
"name",
"description",
"effectiveStartDateTime",
"effectiveEndDateTime",
"recurrenceList"
]
VALID_FOR_KWARGS = VALID_JSON_DATA + []
REQUIRED_FOR_POST = [
"name",
"effectiveStartDateTime",
"effectiveEndDateTime"
]
URL_SUFFIX = "/object/timeranges"

def __init__(self, fmc, **kwargs):
"""
Initialize TimeRanges object.
:param fmc: (object) FMC object
:param kwargs: Any other values passed during instantiation.
:return: None
"""
super().__init__(fmc, **kwargs)
logging.debug("In __init__() for TimeRanges class.")
self.parse_kwargs(**kwargs)
2 changes: 2 additions & 0 deletions unit_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from .ravpn import test__ravpn
from .connectionprofiles import test__connectionprofiles
from .dynamicaccesspolicies import test__dynamicaccesspolicies
from .timeranges import test__timeranges

logging.debug("In the unit-tests __init__.py file.")

Expand Down Expand Up @@ -158,4 +159,5 @@
"test__ravpn",
"test__connectionprofiles",
"test__dynamicaccesspolicies",
"test__timeranges",
]
22 changes: 22 additions & 0 deletions unit_tests/timeranges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import logging
import fmcapi
import time

def test__timeranges(fmc):
logging.info("Testing TimeRanges class.")

starttime = str(int(time.time()))
namer = f"_fmcapi_test_{starttime}"

time_range = fmcapi.TimeRanges(fmc=fmc)
time_range.name = namer
time_range.effectiveStartDateTime = "1979-01-01T00:00"
time_range.effectiveEndDateTime = "1979-01-01T00:01"
time_range.post()
time_range.get()
time_range.effectiveStartDateTime = "1979-01-02T00:00"
time_range.effectiveEndDateTime = "1979-01-02T00:01"
time_range.put()
time_range.delete()

logging.info("Testing TimeRanges class done.\n")

0 comments on commit 33ea9a2

Please sign in to comment.