Skip to content

Structure

Structure of a policy:

Policy is a dynamically loadable python class, here is the structure of a policy class:

```python class AIOSv1PolicyRule: def init(self, rule_id, settings, parameters): """ Initializes an AIOSv1PolicyRule instance.

    Args:
        rule_id (str): Unique identifier for the rule.
        settings (dict): Configuration settings for the rule.
        parameters (dict): Parameters defining the rule's behavior.
    """
    self.rule_id = rule_id
    self.settings = settings
    self.parameters = parameters

def eval(self, parameters, input_data, context):
    """
    Evaluates the policy rule.

    Args:
        parameters (dict): The current parameters.
        input_data (any): The input data to be evaluated.
        context (dict): Context (external cache), this can be used for storing and accessing the state across multiple runs.

    Returns:
        dict: A dictionary with the evaluation result.
    """
    # Rule logic goes here (can modify input_data)
    return {}

def management(self, action: str, data: dict) -> dict:
    """
    Executes a custom management command.

    This method enables external interaction with the rule instance for purposes such as:
    - updating settings or parameters
    - fetching internal state
    - diagnostics or lifecycle control

    Args:
        action (str): The management action to execute.
        data (dict): Input payload or command arguments.

    Returns:
        dict: A result dictionary containing the status and any relevant details.
    """
    # Implement custom management actions here
    pass