class ConcreteTimePeriod(BaseSchema): alias = fields.String(description="The alias of the time period", example="alias") active_time_ranges = fields.List( fields.Nested(ConcreteTimeRangeActive), description="The days for which time ranges were specified", example={ 'day': 'all', 'time_ranges': [{ 'start': '12:00', 'end': '14:00' }] }, ) exceptions = fields.List( fields.Nested(ConcreteTimePeriodException), description="Specific day exclusions with their list of time ranges", example=[{ 'date': '2020-01-01', 'time_ranges': [{ 'start': '14:00', 'end': '18:00' }] }], ) exclude = fields.List( # type: ignore[assignment] fields.String(description="Name of excluding time period", example="holidays"), description= "The collection of time period aliases whose periods are excluded", )
class InputTimePeriod(BaseSchema): name = TimePeriodName(example="first", description="A unique name for the time period.", required=True, should_exist=False) alias = TimePeriodAlias( example="alias", description="An alias for the time period.", required=True, should_exist=False, ) active_time_ranges = fields.List( fields.Nested(TimeRangeActive), example="[{'day': 'monday','time_ranges': [{'start': '12:00','end': '14:00'}]}]", description="The list of active time ranges.", required=True, ) exceptions = fields.List( fields.Nested(TimePeriodException), required=False, example="[{'date': '2020-01-01', 'time_ranges': [{'start': '14:00', 'end': '18:00'}]}]", ) exclude = fields.List( TimePeriodAlias( example="alias", description="The alias for a time period.", required=True, should_exist=True, ), example="['alias']", description="The collection of time period aliases whose periods are excluded", required=False, )
class UpdateTimePeriod(BaseSchema): alias = TimePeriodAlias( example="alias", description="An alias for the time period", required=False, should_exist=False, ) active_time_ranges = fields.List( fields.Nested(TimeRangeActive), example={ 'start': '12:00', 'end': '14:00' }, description= "The list of active time ranges which replaces the existing list of time ranges", required=False, ) exceptions = fields.List( fields.Nested(TimePeriodException), required=False, example=[{ 'date': '2020-01-01', 'time_ranges': [{ 'start': '14:00', 'end': '18:00' }] }], )
class FolderMembers(BaseSchema): hosts = fields.Nested( ObjectCollectionMember(), description="A list of links pointing to the actual host-resources.", ) move = fields.Nested( ObjectActionMember(), description= "An action which triggers the move of this folder to another folder.", )
class InputHostTagGroup(BaseSchema): ident = HostTagGroupId( example="group_id", description="An id for the host tag group", attribute="id", ) title = fields.String( required=True, example="Kubernetes", description="A title for the host tag", ) topic = fields.String( required=True, example="Data Sources", description="Different tags can be grouped in a topic", ) help = fields.String( required=False, example="Kubernetes Pods", description="A help description for the tag group", missing="", ) tags = Tags( fields.Nested(HostTag), required=True, example=[{ "ident": "pod", "title": "Pod" }], description="A list of host tags belonging to the host tag group", )
class UpdateHostTagGroup(BaseSchema): title = fields.String( required=False, example="Kubernetes", description="A title for the host tag", ) topic = fields.String( required=False, example="Data Sources", description="Different tags can be grouped in a topic", ) help = fields.String( required=False, example="Kubernetes Pods", description="A help description for the tag group", ) tags = Tags( fields.Nested(HostTag), required=False, example=[{ "ident": "pod", "title": "Pod" }], description="A list of host tags belonging to the host tag group", ) repair = fields.Boolean( required=False, missing=False, example=False, description= "The host tag group can be in use by other hosts. Setting repair to True gives permission to automatically update the tag from the affected hosts." )
class HostMembers(BaseSchema): folder_config = fields.Nested( ConcreteFolder, description= "The folder in which this host resides. It is represented by a hexadecimal " "identifier which is it's 'primary key'. The folder can be accessed via the " "`self`-link provided in the links array.")
class TimeRangeActive(BaseSchema): day = fields.String( description= "The day for which time ranges are to be specified. The 'all' " "option allows to specify time ranges for all days.", pattern=f"all|{'|'.join(weekday_ids())}") time_ranges = fields.List(fields.Nested(TimeRange))
class DomainObject(Linkable): domainType: fields.Field = fields.String(required=True) # Generic things to ease development. Should be changed for more concrete schemas. id = fields.String() title = fields.String() members = fields.Nested(ObjectMemberDict()) extensions = fields.Dict()
class ActionResultScalar(ActionResultBase): resultType = fields.Constant('scalar') result = fields.Nested( Schema.from_dict( { 'links': fields.List( fields.Nested(LinkSchema), required=True, ), 'value': fields.String( required=True, example="Done.", ) }, name='ActionResultScalarValue', ))
class ActionResultScalar(ActionResultBase): result = fields.Nested( Schema.from_dict( { 'links': fields.List( fields.Nested(LinkSchema), required=True, ), 'value': fields.String( required=True, example="Done.", ) }, name='ActionResultScalarValue', ), description="The scalar result of the action.", )
class BulkUpdateHost(BaseSchema): entries = fields.List( fields.Nested(UpdateHostEntry), example=[{ "host_name": "example.com", "attributes": {} }], )
class FolderSchema(Linkable): domainType = fields.Constant( "folder_config", required=True, ) id = fields.String() title = fields.String() members = fields.Nested(FolderMembers())
class FolderCollection(DomainObjectCollection): domainType = fields.Constant( "folder_config", description="The domain type of the objects in the collection.", ) value = fields.List( fields.Nested(ConcreteFolder), description="A list of folder objects.", )
class ActionResultObject(ActionResultBase): resultType = fields.Constant('object') result = fields.Nested( Schema.from_dict( { 'links': fields.List( fields.Nested(LinkSchema), required=True, ), 'value': fields.Dict( required=True, example={'duration': '5 seconds.'}, ) }, name='ActionResultObjectValue', ))
class ConcreteTimePeriodException(BaseSchema): date = fields.Date( example="2020-01-01", description="The date of the time period exception." "8601 profile", ) time_ranges = fields.List( fields.Nested(ConcreteTimeRange), example="[{'start': '14:00', 'end': '18:00'}]", )
class BulkCreateHost(BaseSchema): entries = fields.List( fields.Nested(CreateHost), example=[{ "host_name": "example.com", "folder": "root", "attributes": {}, }], uniqueItems=True, )
class ActionResultObject(ActionResultBase): result = fields.Nested( Schema.from_dict( { 'links': fields.List( fields.Nested(LinkSchema), required=True, ), 'value': fields.Dict( required=True, example={'duration': '5 seconds.'}, ) }, name='ActionResultObjectValue', ), description="The result of the action. In this case, an object.", )
class BulkInputServiceGroup(BaseSchema): """Bulk creating service groups""" entries = fields.List( fields.Nested(InputServiceGroup), example=[{ "name": "environment", "alias": "Environment Sensors", }], uniqueItems=True, )
class BulkUpdateFolder(BaseSchema): entries = fields.Nested(UpdateFolderEntry, many=True, example=[{ 'ident': 'root', 'title': 'Virtual Servers', 'attributes': { 'key': 'foo' } }])
class BulkUpdateServiceGroup(BaseSchema): """Bulk update service groups""" entries = fields.List(fields.Nested(UpdateServiceGroup), example=[{ 'name': 'windows', 'attributes': { 'name': 'windows updated', 'alias': 'Windows Servers', }, }])
class BulkUpdateContactGroup(BaseSchema): """Bulk update contact groups""" entries = fields.List(fields.Nested(UpdateContactGroup), example=[{ 'name': 'OnCall', 'attributes': { 'name': 'OnCall updated', 'alias': 'Not on Sundays', }, }])
class UpdateContactGroup(BaseSchema): """Updating a contact group""" name = Group( group_type="contact", description="The name of the contact group.", example="OnCall", required=True, should_exist=True, ) attributes = fields.Nested(InputContactGroup)
class BulkInputHostGroup(BaseSchema): """Bulk creating host groups""" entries = fields.List( fields.Nested(InputHostGroup), example=[{ 'name': 'windows', 'alias': 'Windows Servers', }], uniqueItems=True, )
class BulkInputContactGroup(BaseSchema): """Bulk creating contact groups""" # TODO: add unique entries attribute entries = fields.List( fields.Nested(InputContactGroup), example=[{ "name": "OnCall", "alias": "Not on Sundays", }], uniqueItems=True, )
class BulkCreateFolder(BaseSchema): entries = fields.List( fields.Nested(CreateFolder), example=[{ "name": "production", "parent": "root", "attributes": { "foo": "bar" }, }], uniqueItems=True, )
class Version(LinkSchema): specVersion = fields.Str( description= ('The "major.minor" parts of the version of the spec supported by this ' 'implementation, e.g. "1.0"'), required=False, ) implVersion = fields.Str( description= ("(optional) Version of the implementation itself (format is specific to " "the implementation)"), required=False, ) additionalCapabilities = fields.Nested(VersionCapabilities)
class TimePeriodException(BaseSchema): date = fields.Date( required=True, example="2020-01-01", description="The date of the time period exception." "8601 profile", ) time_ranges = fields.List( fields.Nested(TimeRange), required=False, example=[{ 'start': '14:00', 'end': '18:00' }], )
class HostParameters(BaseSchema): """All the parameters for the hosts list. Examples: >>> p = HostParameters() >>> p.load({})['columns'] ['name'] >>> p.load({})['sites'] [] """ sites = fields.List( fields.String(), description="Restrict the query to this particular site.", missing=[], ) query = fields.Nested( fields.ExprSchema, description=( "An query expression in nested dictionary form. If you want to " "use multiple expressions, nest them with the AND/OR operators."), many=False, example=json.dumps({ 'op': 'not', 'expr': { 'op': '=', 'left': 'hosts.name', 'right': 'example.com' } }), required=False, ) columns = fields.List( fields.LiveStatusColumn( table=Hosts, mandatory=[Hosts.name.name], required=True, ), description= ("The desired columns of the hosts table. If left empty, a default set of " "columns is used."), missing=[Hosts.name.name], required=False, )
class DomainObjectCollection(Linkable): id = fields.String( description="The name of this collection.", missing='all', ) domainType: fields.Field = fields.String( description="The domain type of the objects in the collection.") title = fields.String( description="A human readable title of this object. Can be used for " "user interfaces.", ) value: fields.Field = fields.Nested( CollectionItem, description= "The collection itself. Each entry in here is part of the collection.", many=True, ) extensions = fields.Dict( description="Additional attributes alongside the collection.")