nagrest/src/nag_object.py

43 lines
1.3 KiB
Python
Raw Normal View History

2022-03-25 18:07:23 +01:00
from enum import Enum
2022-03-28 10:01:36 +02:00
class NagObjectType(Enum):
2022-03-25 18:07:23 +01:00
Command = "command"
ContactGroup = "contactgroup"
Contact = "contact"
HostDependency = "hostdependency"
HostEscalation = "hostescalation"
HostGroup = "hostgroup"
Host = "host"
ServiceDependency = "servicedependency"
ServiceEscalation = "serviceescalation"
ServiceGroup = "servicegroup"
Service = "service"
TimePeriod = "timeperiod"
Nil = "nil"
2022-03-28 10:01:36 +02:00
class NagObject:
2022-03-25 18:07:23 +01:00
def __init__(self,
config_file: str = str(),
2022-03-28 10:01:36 +02:00
directives: list[list[str]] = list(),
2022-03-25 18:07:23 +01:00
line_no: int = 0,
2022-03-28 10:01:36 +02:00
type: NagObjectType = NagObjectType.Nil):
2022-03-25 18:07:23 +01:00
self.m_config_file: str = config_file
2022-03-28 10:01:36 +02:00
self.m_directives: list[list[str]] = directives
2022-03-25 18:07:23 +01:00
self.m_line_no: int = line_no
2022-03-28 10:01:36 +02:00
self.m_type: NagObjectType = type
2022-03-25 18:07:23 +01:00
def __str__(self):
string = "{}:\n\t{}: {}\n".format(self.m_config_file, self.m_line_no,
self.m_type)
for dir in self.m_directives:
string += "\t\t{}: {}\n".format(dir[0], dir[1])
return string
2022-03-28 10:01:36 +02:00
def get_type(self) -> NagObjectType:
2022-03-25 18:07:23 +01:00
return self.m_type
2022-03-28 10:01:36 +02:00
def get_directives(self) -> list[list[str]]:
2022-03-25 18:07:23 +01:00
return self.m_directives