-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for objects.timeranges
- Loading branch information
Zachery Lantz
committed
Apr 17, 2024
1 parent
9119042
commit 33ea9a2
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |