Skip to content

Conversation

@akimboyko
Copy link

@akimboyko akimboyko commented Jan 18, 2017

Hi @Crapworks,

Here is an update for RESTlos validate function to support weekdays in timeperiods in the format supported by 0.9.1.1 version of PyNag.

For example:

[
  {
    "alias": "monday_and_friday_are_workdays",
    "name": "monday_and_friday_are_workdays",
    "timeperiod_name": "monday_and_friday_are_workdays",
    "monday              06:00-11:00": "",
    "monday              12:30-15:00": "",
    "monday              17:30-22:30": "",
    "friday              00:00-12:00": "",
    "friday              13:00-22:00": "",
    "friday              23:05-23:25": ""
  }
]

It is not a real workaround for that as it is not based on PyNag object_definitions. However, it is good enough for our internal purposes.

Other types such as days of generic months, days of specific months, and calendar dates could be supported also if there will be interest by the community

main_cfg_values = {}

timeperiod_regex = re.compile(
'^(monday|tuesday|wednesday|thursday|friday|saturday|sunday)'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an initial version provides support for weekdays only


def validate(self, endpoint, data={}):
for attr in data.keys():
if endpoint == 'timeperiod':
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actual solution based on suggestion: use an if statement evereywhere to treat Timeperoids special from pynag issue 243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant