class BIAggregationPackSchema(Schema): id = ReqString(default="", example="bi_pack1") title = ReqString(default="", example="BI Title") comment = String( description= "An optional comment that may be used to explain the purpose of this object.", allow_none=True, example="Rule comment", ) contact_groups = ReqList(fields.String(), default=[], example=["contactgroup_a", "contactgroup_b"]) public = ReqBoolean(default=False) rules = ReqList(fields.Nested(BIRuleSchema()), default=[]) aggregations = ReqList(fields.Nested(BIAggregationSchema()), default=[]) @pre_dump def pre_dumper(self, obj: BIAggregationPack, many=False) -> Dict: # Convert aggregations and rules to list return { "id": obj.id, "title": obj.title, "comment": obj.comment, "contact_groups": obj.contact_groups, "public": obj.public, "rules": obj.get_rules().values(), "aggregations": obj.get_aggregations().values(), }
class BISiteHostPairSchema(Schema): site_id = ReqString() host_name = ReqString() @marshmallow.pre_dump def pre_dump(self, obj: Tuple) -> Dict: # Convert aggregations and rules to list return {"site_id": obj[0], "host_name": obj[1]}
class BIAggregationSchema(Schema): id = ReqString(default="", example="aggr1") customer = ReqString(default="", example="customer1") groups = create_nested_schema_for_class( BIAggregationGroups, example_config={ "names": ["groupA", "groupB"], "paths": [["path", "group", "a"], ["path", "group", "b"]] }, ) node = create_nested_schema_for_class(BINodeGenerator) aggregation_visualization = create_nested_schema( BIAggregationVisualizationSchema) computation_options = create_nested_schema_for_class( BIAggregationComputationOptions)
class BIRuleSchema(Schema): class Meta: ordered = True id = ReqString( default="", example="rule1", description="TODO: Hier muß Andreas noch etwas reinschreiben!", ) nodes = ReqList( fields.Nested(BINodeGeneratorSchema), default=[], example=[], description="TODO: Hier muß Andreas noch etwas reinschreiben!", ) params = create_nested_schema_for_class( BIParams, example_config={ "arguments": ["foo", "bar"], }, ) node_visualization = create_nested_schema( BINodeVisLayoutStyleSchema, default_schema=BINodeVisBlockStyleSchema) properties = create_nested_schema_for_class(BIRuleProperties) aggregation_function = create_nested_schema( BIAggregationFunctionSchema, default_schema=BIAggregationFunctionBest.schema()) computation_options = create_nested_schema_for_class( BIRuleComputationOptions)
class HostConditionsSchema(Schema): host_folder = ReqString(default="", example="servers/groupA") host_labels = ReqDict(default={}, example={"db": "mssql"}) host_tags = ReqDict(default={}, example={}) host_choice = ReqNested(BIHostChoice, default={"type": "all_hosts"}, example={"type": "all_hosts"})
class BIAggregationSchema(Schema): class Meta: ordered = True id = ReqString( default="", example="aggr1", description="TODO: Hier muß Andreas noch etwas reinschreiben!", ) customer = String( description="CME Edition only: The customer id for this aggregation.", allow_none=True, example="customer1", ) groups = create_nested_schema_for_class( BIAggregationGroups, example_config={ "names": ["groupA", "groupB"], "paths": [["path", "group", "a"], ["path", "group", "b"]] }, ) node = create_nested_schema_for_class(BINodeGenerator) aggregation_visualization = create_nested_schema( BIAggregationVisualizationSchema) computation_options = create_nested_schema_for_class( BIAggregationComputationOptions)
class BICompiledRuleSchema(Schema): id = ReqString() pack_id = ReqString() type = ReqConstant(BICompiledRule.type()) required_hosts = ReqList(fields.Nested(BISiteHostPairSchema)) nodes = ReqList(fields.Nested("BIResultSchema")) aggregation_function = ReqNested( BIAggregationFunctionSchema, example={ "type": "worst", "count": 2, "restrict_state": 1 }, ) node_visualization = ReqNested(BINodeVisLayoutStyleSchema, example=BINodeVisBlockStyleSchema().dump( {})) properties = ReqNested("BIRulePropertiesSchema", example={})
class BIAggregationPackSchema(Schema): id = ReqString(default="", example="bi_pack1") title = ReqString(default="", example="BI Title") contact_groups = ReqList(fields.String(), default=[], example=["contactgroup_a", "contactgroup_b"]) public = ReqBoolean(default=False) rules = ReqList(fields.Nested(BIRuleSchema()), default=[]) aggregations = ReqList(fields.Nested(BIAggregationSchema()), default=[]) @pre_dump def pre_dumper(self, obj: BIAggregationPack, many=False) -> Dict: # Convert aggregations and rules to list return { "id": obj.id, "title": obj.title, "contact_groups": obj.contact_groups, "public": obj.public, "rules": obj.get_rules().values(), "aggregations": obj.get_aggregations().values(), }
class BIRuleSchema(Schema): id = ReqString(default="", example="rule1") nodes = ReqList(fields.Nested(BINodeGeneratorSchema), default=[], example=[]) params = create_nested_schema_for_class(BIParams, example_config=[{ "arguments": ["foo", "bar"], }]) node_visualization = create_nested_schema(BINodeVisLayoutStyleSchema, default_schema=BINodeVisBlockStyleSchema) properties = create_nested_schema_for_class(BIRuleProperties) aggregation_function = create_nested_schema(BIAggregationFunctionSchema, default_schema=BIAggregationFunctionBest.schema()) computation_options = create_nested_schema_for_class(BIRuleComputationOptions)
class BICompiledAggregationSchema(Schema): id = ReqString() branches = ReqList(Nested(BICompiledRuleSchema)) aggregation_visualization = ReqNested(BIAggregationVisualizationSchema) computation_options = create_nested_schema_for_class( BIAggregationComputationOptions, example_config={"disabled": True}, ) groups = create_nested_schema_for_class( BIAggregationGroups, example_config={ "names": ["groupA", "groupB"], "paths": [["path", "group", "a"]] }, )
class BIPackEndpointSchema(Schema): title = ReqString( dump_default="", example="BI Title", description="TODO: Hier muß Andreas noch etwas reinschreiben!", ) contact_groups = ReqList( fields.String(), dump_default=[], example=["contact", "contactgroup_b"], description="TODO: Hier muß Andreas noch etwas reinschreiben!", ) public = ReqBoolean( dump_default=False, example="false", description="TODO: Hier muß Andreas noch etwas reinschreiben!", )
class BIPackEndpointSchema(Schema): title = ReqString( dump_default="", example="BI Title", description="The title of the BI pack.", ) contact_groups = ReqList( fields.String(), dump_default=[], example=["contact", "contactgroup_b"], description="A list of contact group identifiers.", ) public = ReqBoolean( dump_default=False, example="false", description="Should the BI pack be public or not.", )
class BIPackEndpointSchema(Schema): title = ReqString(default="", example="BI Title") contact_groups = ReqList(fields.String(), default=[], example=["contact", "contactgroup_b"]) public = ReqBoolean(default=False, example="false")
class BIAggregationVisualizationSchema(Schema): ignore_rule_styles = ReqBoolean(default=False, example=False) layout_id = ReqString(default="builtin_default", example="radial_layout2") line_style = ReqString(default="round", example="round")
class BIStateOfRemainingServicesActionSchema(Schema): type = ReqConstant(BIStateOfRemainingServicesAction.type()) host_regex = ReqString(default="", example="testhost")
class BICompiledLeafSchema(Schema): type = ReqConstant(BICompiledLeaf.type()) required_hosts = ReqList(Nested(BISiteHostPairSchema)) site_id = ReqString() host_name = ReqString() service_description = String()
class BIRuleEndpointSchema(BIRuleSchema): pack_id = ReqString(default="", example="pack1")
class BICallARuleActionSchema(Schema): type = ReqConstant(BICallARuleAction.type()) rule_id = ReqString(default="", example="test_rule_1") params = ReqNested(BIParamsSchema, default=BIParamsSchema().dump({}), example=BIParamsSchema().dump({}))
class BIAggregationEndpointSchema(BIAggregationSchema): pack_id = ReqString(default="", example="pack1")
class BIRulePropertiesSchema(Schema): title = ReqString(dump_default="", example="Rule title") comment = ReqString(dump_default="", example="Rule comment") docu_url = ReqString(dump_default="", example="Rule documentation") icon = ReqString(dump_default="", example="icon1.png") state_messages = ReqDict(dump_default={}, example={})
class BIRuleEndpointSchema(BIRuleSchema): pack_id = ReqString( dump_default="", example="pack1", description="TODO: Hier muß Andreas noch etwas reinschreiben!", )
class BIHostSearchSchema(Schema): type = ReqConstant(BIHostSearch.type()) conditions = ReqNested(HostConditionsSchema, default=HostConditionsSchema().dump({})) refer_to = ReqString(validate=validate.OneOf(["host", "child", "parent"]), default="host")
class BIHostNameRegexChoiceSchema(Schema): type = ReqConstant("host_name_regex") pattern = ReqString(default="", example="testhostn.*")
class BIFixedArgumentsSearchTokenSchema(Schema): key = ReqString() values = ReqList(fields.String)
class BIAggregationFunctionCountSettings(Schema): type = ReqString(default="count", validate=validate.OneOf(["count", "percentage"])) value = ReqInteger(default=1)
class BIHostAliasRegexChoiceSchema(Schema): type = ReqConstant("host_alias_regex") pattern = ReqString(default="", example="testali.*")
class BIRuleEndpointSchema(BIRuleSchema): pack_id = ReqString( dump_default="", example="pack1", description="The identifier of the BI pack.", )
class ServiceConditionsSchema(HostConditionsSchema): service_regex = ReqString(default="", example="Filesystem.*") service_labels = ReqDict(default={}, example={"db": "mssql"})
class BIStateOfServiceActionSchema(Schema): type = ReqConstant(BIStateOfServiceAction.type()) host_regex = ReqString(dump_default="", example="testhost") service_regex = ReqString(dump_default="", example="testservice")