glasswall.content_management.config_elements.textSearchConfig

 1from glasswall.content_management.config_elements.config_element import ConfigElement
 2from glasswall.content_management.config_elements.textList import textList
 3from glasswall.content_management.policies.policy import Policy
 4from glasswall.content_management.switches.switch import Switch
 5
 6
 7class textSearchConfig(ConfigElement):
 8    """ A textSearchConfig ConfigElement.
 9
10    textSearchConfig(
11        libVersion="core2",
12        textList_subelements=[
13            {"name": "textItem", "switches": [
14                {"name": "text", "value": "generic"},
15                {"name": "textSetting", "@replacementChar": "*", "value": "redact"},
16            ]}
17        ]
18    )
19    """
20
21    def __init__(self, attributes: dict = {}, textList_subelements: list = [], **kwargs):
22        self.name = self.__class__.__name__
23        self.attributes = attributes or {}
24        self.attributes = {
25            **{
26                "libVersion": kwargs.get("libVersion", "core2"),
27            },
28            **self.attributes,
29        }
30        subelements = []
31        for textList_dict in textList_subelements:
32            switch_list = []
33            for switch_dict in textList_dict.get("switches", []):
34                # Construct switch
35                switch = Switch(
36                    **Policy.get_switches(switch_dict),
37                    attributes=Policy.get_attributes(switch_dict)
38                )
39
40                # Append switch to switch_list
41                switch_list.append(switch)
42
43            # Overwrite textList_dict switches with switch_list objects
44            textList_dict["switches"] = switch_list
45
46            # Construct config_element
47            config_element = ConfigElement(**textList_dict)
48
49            # Append constructed config_element to subelements
50            subelements.append(config_element)
51
52        if subelements:
53            self.subelements = [
54                textList(subelements=subelements)
55            ]
56        else:
57            self.subelements = []
58
59        super().__init__(name=self.name, attributes=self.attributes, subelements=self.subelements)
10class textSearchConfig(ConfigElement):
11    """ A textSearchConfig ConfigElement.
12
13    textSearchConfig(
14        libVersion="core2",
15        textList_subelements=[
16            {"name": "textItem", "switches": [
17                {"name": "text", "value": "generic"},
18                {"name": "textSetting", "@replacementChar": "*", "value": "redact"},
19            ]}
20        ]
21    )
22    """
23
24    def __init__(self, attributes: dict = {}, textList_subelements: list = [], **kwargs):
25        self.name = self.__class__.__name__
26        self.attributes = attributes or {}
27        self.attributes = {
28            **{
29                "libVersion": kwargs.get("libVersion", "core2"),
30            },
31            **self.attributes,
32        }
33        subelements = []
34        for textList_dict in textList_subelements:
35            switch_list = []
36            for switch_dict in textList_dict.get("switches", []):
37                # Construct switch
38                switch = Switch(
39                    **Policy.get_switches(switch_dict),
40                    attributes=Policy.get_attributes(switch_dict)
41                )
42
43                # Append switch to switch_list
44                switch_list.append(switch)
45
46            # Overwrite textList_dict switches with switch_list objects
47            textList_dict["switches"] = switch_list
48
49            # Construct config_element
50            config_element = ConfigElement(**textList_dict)
51
52            # Append constructed config_element to subelements
53            subelements.append(config_element)
54
55        if subelements:
56            self.subelements = [
57                textList(subelements=subelements)
58            ]
59        else:
60            self.subelements = []
61
62        super().__init__(name=self.name, attributes=self.attributes, subelements=self.subelements)

A textSearchConfig ConfigElement.

textSearchConfig( libVersion="core2", textList_subelements=[ {"name": "textItem", "switches": [ {"name": "text", "value": "generic"}, {"name": "textSetting", "@replacementChar": "*", "value": "redact"}, ]} ] )

textSearchConfig(attributes: dict = {}, textList_subelements: list = [], **kwargs)
24    def __init__(self, attributes: dict = {}, textList_subelements: list = [], **kwargs):
25        self.name = self.__class__.__name__
26        self.attributes = attributes or {}
27        self.attributes = {
28            **{
29                "libVersion": kwargs.get("libVersion", "core2"),
30            },
31            **self.attributes,
32        }
33        subelements = []
34        for textList_dict in textList_subelements:
35            switch_list = []
36            for switch_dict in textList_dict.get("switches", []):
37                # Construct switch
38                switch = Switch(
39                    **Policy.get_switches(switch_dict),
40                    attributes=Policy.get_attributes(switch_dict)
41                )
42
43                # Append switch to switch_list
44                switch_list.append(switch)
45
46            # Overwrite textList_dict switches with switch_list objects
47            textList_dict["switches"] = switch_list
48
49            # Construct config_element
50            config_element = ConfigElement(**textList_dict)
51
52            # Append constructed config_element to subelements
53            subelements.append(config_element)
54
55        if subelements:
56            self.subelements = [
57                textList(subelements=subelements)
58            ]
59        else:
60            self.subelements = []
61
62        super().__init__(name=self.name, attributes=self.attributes, subelements=self.subelements)
name
attributes