ptnad.api.BQLAPI
Methods:
Name | Description |
---|---|
execute |
Execute a BQL query on a specific source. |
execute_raw |
Execute a BQL query on a specific source and return the full response. |
execute
Execute a BQL query on a specific source.
Args: query (str): The BQL query to execute. source (str): The identifier of the storage to query. Defaults to "2" (live).
Returns: Any: The result of the query execution.
Raises: PTNADAPIError: If there's an error executing the query.
Source code in src/ptnad/api/bql.py
execute_raw
Execute a BQL query on a specific source and return the full response.
Args: query (str): The BQL query to execute. source (str): The identifier of the storage to query. Defaults to "2" (live).
Returns: BQLResponse: An object containing the query results, execution time, total hits, and debug info.
Raises: PTNADAPIError: If there's an error executing the query.
Source code in src/ptnad/api/bql.py
ptnad.api.MonitoringAPI
Methods:
Name | Description |
---|---|
get_active_triggers |
Get all active triggers (triggers with status other than 'green'). |
get_status |
Get the current status. |
get_trigger_by_id |
Get a specific trigger by its ID. |
get_triggers |
Get the list of triggers. |
get_triggers_by_type |
Get all triggers of a specific type. |
Source code in src/ptnad/api/monitoring.py
get_active_triggers
Get all active triggers (triggers with status other than 'green').
Returns: List[Trigger]: A list of active Trigger objects.
Raises: PTNADAPIError: If there's an error retrieving the triggers.
Source code in src/ptnad/api/monitoring.py
get_status
Get the current status.
Returns: MonitoringStatus: An object containing the current status and any problems.
Raises: PTNADAPIError: If there's an error retrieving the status.
Source code in src/ptnad/api/monitoring.py
get_trigger_by_id
Get a specific trigger by its ID.
Args: trigger_id (str): The ID of the trigger to retrieve.
Returns: Optional[Trigger]: The Trigger object if found, None otherwise.
Raises: PTNADAPIError: If there's an error retrieving the trigger.
Source code in src/ptnad/api/monitoring.py
get_triggers
Get the list of triggers.
Returns: List[Trigger]: A list of Trigger objects.
Raises: PTNADAPIError: If there's an error retrieving the triggers.
Source code in src/ptnad/api/monitoring.py
get_triggers_by_type
Get all triggers of a specific type.
Args: trigger_type (str): The type of triggers to retrieve.
Returns: List[Trigger]: A list of Trigger objects of the specified type.
Raises: PTNADAPIError: If there's an error retrieving the triggers.
Source code in src/ptnad/api/monitoring.py
ptnad.api.RepListsAPI
Methods:
Name | Description |
---|---|
add_dynamic_list_item |
Add an item to a dynamic reputation list. |
bulk_add_items |
Add multiple items to a dynamic reputation list. |
bulk_delete_items |
Delete multiple items from a dynamic reputation list. |
create_list |
Create a new reputation list. |
delete_list |
Delete a reputation list. |
get_all_lists |
Get all reputation lists using pagination. |
get_dynamic_list_items |
Get items from a dynamic reputation list. |
get_list |
Get information about a specific reputation list. |
get_lists |
Get a list of reputation lists. |
get_stats |
Get statistics about reputation lists. |
remove_item |
Remove an item from a dynamic reputation list. |
update_list |
Update a reputation list. |
Source code in src/ptnad/api/replists.py
add_dynamic_list_item
add_dynamic_list_item(external_key: str, value: str, attributes: Dict[str, Any] | None = None) -> Dict[str, Any]
Add an item to a dynamic reputation list.
Args: external_key (str): External key of the reputation list. value (str): Value to add to the list. attributes (Optional[Dict[str, Any]]): Additional attributes for the item.
Returns: Dict[str, Any]: Information about the added item.
Raises: PTNADAPIError: If there's an error adding the item.
Source code in src/ptnad/api/replists.py
bulk_add_items
Add multiple items to a dynamic reputation list.
Args: external_key (str): External key of the reputation list. items (List[Dict[str, Any]]): List of items to add, each item should have 'value' and optionally 'attrs'.
Raises: PTNADAPIError: If there's an error adding the items.
Source code in src/ptnad/api/replists.py
bulk_delete_items
Delete multiple items from a dynamic reputation list.
Args: external_key (str): External key of the reputation list. values (List[str]): List of values to delete from the list.
Raises: PTNADAPIError: If there's an error deleting the items.
Source code in src/ptnad/api/replists.py
create_list
create_list(name: str, type: str, color: str, description: str | None = None, content: Union[str, List[str], None] = None, external_key: str | None = None) -> Dict[str, Any]
Create a new reputation list.
Args: name (str): Name of the reputation list. Must be a valid slug (letters, numbers, underscores, hyphens). type (str): Type of the reputation list ('ip', 'dn', 'uri', or 'md5'). color (str): Color code for the reputation list ('0' to '7'). description (Optional[str]): Description of the reputation list. content (Optional[Union[str, List[str]]]): Content of the reputation list. Can be a string or a list of strings that will be joined with newlines. external_key (Optional[str]): External key for the reputation list.
Returns: Dict[str, Any]: Information about the created reputation list.
Raises: ValidationError: If the input parameters are invalid. PTNADAPIError: If there's an error creating the list.
Source code in src/ptnad/api/replists.py
delete_list
Delete a reputation list.
Args: list_id (int): ID of the reputation list to delete.
Raises: PTNADAPIError: If there's an error deleting the reputation list.
Source code in src/ptnad/api/replists.py
get_all_lists
get_all_lists(search: str | None = None, ordering: str | None = None, limit: int = 100) -> List[Dict[str, Any]]
Get all reputation lists using pagination.
Args: search (Optional[str]): Keyword to filter the lists by name, description, or vendor name. ordering (Optional[str]): Field to sort the results by (id, name, color, type, created, modified, items_count, description, vendor__name). Use prefix with '-' for descending order. limit (int): Number of lists to fetch per request (default: 100).
Returns: List[Dict[str, Any]]: A list of dictionaries containing all reputation list information.
Raises: PTNADAPIError: If there's an error retrieving the lists.
Source code in src/ptnad/api/replists.py
get_dynamic_list_items
Get items from a dynamic reputation list.
Args: external_key (str): External key of the reputation list. ordering (Optional[str]): Field to sort the results by (value or modified).
Returns: List[Dict[str, Any]]: List of items in the reputation list.
Raises: PTNADAPIError: If there's an error retrieving the items.
Source code in src/ptnad/api/replists.py
get_list
Get information about a specific reputation list.
Args: list_id (int): ID of the reputation list.
Returns: Dict[str, Any]: Information about the reputation list.
Raises: PTNADAPIError: If there's an error retrieving the list.
Source code in src/ptnad/api/replists.py
get_lists
get_lists(search: str | None = None, ordering: str | None = None, limit: int = 100, offset: int = 0) -> List[Dict[str, Any]]
Get a list of reputation lists.
Args: search (Optional[str]): Keyword to filter the lists by name, description, or vendor name. ordering (Optional[str]): Field to sort the results by (id, name, color, type, created, modified, items_count, description, vendor__name). Use prefix '-' for descending order. limit (int): Maximum number of lists to return (default: 100). offset (int): Number of lists to skip (default: 0).
Returns: List[Dict[str, Any]]: A list of dictionaries containing reputation list information.
Raises: PTNADAPIError: If there's an error retrieving the lists.
Source code in src/ptnad/api/replists.py
get_stats
Get statistics about reputation lists.
Returns: Dict[str, Any]: Statistics about reputation lists.
Raises: PTNADAPIError: If there's an error retrieving the statistics.
Source code in src/ptnad/api/replists.py
remove_item
Remove an item from a dynamic reputation list.
Args: external_key (str): External key of the reputation list. value (str): Value to remove from the reputation list.
Raises: PTNADAPIError: If there's an error removing the item.
Source code in src/ptnad/api/replists.py
update_list
Update a reputation list.
Args: list_id (int): ID of the reputation list to update. **kwargs: Fields to update (color, name, type, description, content).
Returns: Dict[str, Any]: Updated information about the reputation list.
Raises: PTNADAPIError: If there's an error updating the list.
Source code in src/ptnad/api/replists.py
ptnad.api.SignaturesAPI
Methods:
Name | Description |
---|---|
apply_changes |
Apply changes made to Rules and commit them to sensors. |
get_classes |
Get a list of signature classes. |
get_rule |
Get information about a specific Rule. |
get_rules |
Get a list of Rules. |
get_stats |
Get statistics about Rules. |
revert_changes |
Revert changes made to Rules. |
update_rule |
Update a Rule. |
Source code in src/ptnad/api/signatures.py
apply_changes
Apply changes made to Rules and commit them to sensors.
Returns: Dict[str, str]: A dictionary with the hashsum of the package.
Raises: PTNADAPIError: If there's an error applying the changes.
Source code in src/ptnad/api/signatures.py
get_classes
get_classes(search: str | None = None, ordering: str | None = None, **filters) -> List[Dict[str, Any]]
Get a list of signature classes.
Args: search (Optional[str]): Keyword to filter the classes. ordering (Optional[str]): Field to sort the results by. **filters: Additional filters (name, title, priority).
Returns: List[Dict[str, Any]]: A list of dictionaries containing signature class information.
Raises: PTNADAPIError: If there's an error retrieving the classes.
Source code in src/ptnad/api/signatures.py
get_rule
Get information about a specific Rule.
Args: rule_id (int): sid of the Rule.
Returns: Dict[str, Any]: Information about the Rule.
Raises: PTNADAPIError: If there's an error retrieving the rule.
Source code in src/ptnad/api/signatures.py
get_rules
get_rules(search: str | None = None, ordering: str | None = None, limit: int = 100, offset: int = 0, **filters) -> List[Dict[str, Any]]
Get a list of Rules.
Args: search (Optional[str]): Keyword to filter the rules. ordering (Optional[str]): Field to sort the results by. limit (int): Maximum number of rules to return (default: 100). offset (int): Number of rules to skip (default: 0). *filters: Additional filters. Available filters: sid: Filter by sid (can be a single value or a list) sid__gte: sid greater than or equal to sid__lt: sid less than vendor: Filter by vendor name (can be a single value or a list) enabled: Filter by enabled status (true or false) has_redef: Filter by has_redef status (true or false) has_exceptions: Filter by has_exceptions status (true or false) priority: Filter by priority (if priority=4, finds all rules with priority>=4) cls: Filter by class name (can be a single value or a list) diff: Filter by rule changes, valid values (can be a list): added (+), updated (), removed (-), unchanged (=). Available in 12.2+ has_error: Filter by has_error status (true or false) client: Search for IP address in src_adr and dst_adr server: Search for IP address in src_adr and dst_adr
Returns: List[Dict[str, Any]]: A list of dictionaries containing Rule information.
Raises: PTNADAPIError: If there's an error retrieving the rules.
Source code in src/ptnad/api/signatures.py
get_stats
Get statistics about Rules.
Returns: Dict[str, Any]: Statistics about Rules.
Raises: PTNADAPIError: If there's an error retrieving the statistics.
Source code in src/ptnad/api/signatures.py
revert_changes
Revert changes made to Rules.
Raises: PTNADAPIError: If there's an error reverting the changes.
Source code in src/ptnad/api/signatures.py
update_rule
Update a Rule.
Args: rule_id (int): ID of the Rule to update. **kwargs: Fields to update (enabled, action, msg, etc.).
Returns: Dict[str, Any]: Updated information about the Rule.
Raises: PTNADAPIError: If there's an error updating the rule.