policy
Policy
class Policy()
A Content Management Policy made up of a list of ConfigElement instances.
__init__
def __init__(config_elements: list = [],
default: Optional[str] = None,
default_config_elements: list = [],
config: dict = {},
**kwargs)
__str__
def __str__()
__getattr__
def __getattr__(name)
text
@property
def text()
String representation of XML.
encode
def encode(*args)
UTF-8 encoded string representation of XML.
get_config_element_names
def get_config_element_names()
Returns a sorted list of unique ConfigElement.name values from self.config_elements.
remove_switch
def remove_switch(config_element: Union[ConfigElement, str],
switch: Union[Switch, str])
Removes all Switch instances from config_element.switches that match arg "switch" where the ConfigElement instance in self.config_elements matches arg "config_element".
Arguments:
config_elementUnion[ConfigElement, str] - A ConfigElement instance or ConfigElement.name to match.switchUnion[Switch, str] - A Switch instance or Switch.name to match.
Returns:
self
Raises:
glasswall.content_management.errors.config_elements.ConfigElementNotFound- The config_element was not found.glasswall.content_management.errors.switches.SwitchNotFound- The switch was not found.
add_switch
def add_switch(config_element: Union[ConfigElement, str],
switch: Switch,
replace: bool = True)
Adds a Switch to any ConfigElement in self.config_elements that matches arg "config_element".
Arguments:
config_elementUnion[ConfigElement, str] - A ConfigElement instance or str to match ConfigElement.name.switchSwitch - A Switch instance.replacebool, optional - Default True. Deletes any pre-existing Switch with the same .name attribute as arg "switch" within a ConfigElement that matches arg "config_element".
Returns:
self
Raises:
glasswall.content_management.errors.config_elements.ConfigElementNotFound- The config_element was not found.
remove_config_element
def remove_config_element(config_element: Union[ConfigElement, str])
Removes all ConfigElement instances from self.config_elements that match arg "config_element".
Arguments:
config_elementUnion[ConfigElement, str] - A ConfigElement instance or ConfigElement.name attribute to match.
Returns:
self
Raises:
glasswall.content_management.errors.config_elements.ConfigElementNotFound- The config_element was not found.
add_config_element
def add_config_element(config_element: ConfigElement, replace=True)
Adds a ConfigElement instance to self.config_elements.
Arguments:
config_elementConfigElement - A ConfigElement instance.replacebool, optional - Default True. Deletes any pre-existing ConfigElement with the same .name attribute in self.config_elements.
Returns:
self
get_attributes
@staticmethod
def get_attributes(dictionary: dict)
Returns attributes from arg "dictionary". Attributes are key value pairs that have a key starting with "@". The "@" is excluded in the returned keys.
get_switches
@staticmethod
def get_switches(dictionary: dict)
Returns switches from arg "dictionary". Switches are key value pairs that do not have a key starting with "@".
from_string
@staticmethod
def from_string(string: str)
Create Policy object from string.
Arguments:
stringstr - A string representation of an xml content management policy, or a file path.
Returns:
new_policyglasswall.content_management.policies.Policy - A Policy object.