Пример #1
0
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(),
        }
Пример #2
0
class BIAggregationPacksSchema(Schema):
    packs = ReqList(ReqNested(BIAggregationPackSchema))

    @pre_dump
    def pre_dumper(self, obj: BIAggregationPacks, many=None) -> Dict:
        # Convert packs to list
        return {"packs": obj.packs.values()}
Пример #3
0
class BIAggregationPacksSchema(Schema):
    packs = ReqList(ReqNested(BIAggregationPackSchema))

    @marshmallow.pre_dump
    def pre_dump(self, obj: BIAggregationPacks) -> Dict:
        # Convert packs to list
        return {"packs": obj.packs.values()}
Пример #4
0
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)
Пример #5
0
class BICompiledRuleSchema(Schema):
    id = ReqString()
    type = ReqConstant(BICompiledRule.type())
    required_hosts = ReqList(Nested(BISiteHostPairSchema))
    nodes = ReqList(Nested("BIResultSchema"))
    aggregation_function = ReqNested(
        BIAggregationFunctionSchema,
        example={
            "type": "worst",
            "count": 2,
            "restrict_state": 1
        },
    )
    node_visualization = ReqNested(BINodeVisLayoutStyleSchema,
                                   example=BINodeVisBlockStyleSchema().dump(
                                       {}).data)
    properties = ReqNested("BIRulePropertiesSchema", example={})
Пример #6
0
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(),
        }
Пример #7
0
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)
Пример #8
0
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"]]
        },
    )
Пример #9
0
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.",
    )
Пример #10
0
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!",
    )
Пример #11
0
class BIFixedArgumentsSearchSchema(Schema):
    type = ReqConstant(BIFixedArgumentsSearch.type())
    arguments = ReqList(fields.Nested(BIFixedArgumentsSearchTokenSchema))
Пример #12
0
class BIFixedArgumentsSearchTokenSchema(Schema):
    key = ReqString()
    values = ReqList(fields.String)
Пример #13
0
class BICompiledLeafSchema(Schema):
    type = ReqConstant(BICompiledLeaf.type())
    required_hosts = ReqList(Nested(BISiteHostPairSchema))
    site_id = ReqString()
    host_name = ReqString()
    service_description = String()
Пример #14
0
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")