Source code for q2_sdk.hq.db.sec_alert_event_def

from argparse import _SubParsersAction
from functools import partial
from typing import List, Optional, Union

from q2_sdk.core.dynamic_imports import (
    api_ExecuteStoredProcedure as ExecuteStoredProcedure,
)
from q2_sdk.hq.table_row import TableRow

from .db_object import DbObject


[docs] class SecAlertEventDefRow(TableRow): SecAlertEventDefID: int SecAlertEventID: int SecAlertEventShortName: str ErrorReturnCode: int ActionID: int AuditActionShortName: str UISourceID: int
[docs] class SecAlertEventDef(DbObject): NAME = "SecAlertEventDef" REPRESENTATION_ROW_CLASS = SecAlertEventDefRow
[docs] def add_arguments(self, parser: _SubParsersAction): sub = parser.add_parser("get_sec_alert_event_defs") sub.add_argument( "-sae", "--sec-alert-event-short-name", dest="sec_alert_event_short_name", help="Q2_SecAlertEvent.ShortName", ) sub.add_argument( "-aa", "--audit-action-short-name", dest="audit_action_short_name", help="Q2_AuditAction.ShortName", ) sub.set_defaults(parser="get_sec_alert_event_defs") sub.set_defaults(func=partial(self.get, serialize_for_cli=True))
[docs] async def get( self, sec_alert_event_short_name: Optional[str] = None, audit_action_short_name: Optional[str] = None, serialize_for_cli: bool = False, ) -> Union[List[SecAlertEventDefRow], str]: sql_params = [] if sec_alert_event_short_name is not None: if ( not isinstance(sec_alert_event_short_name, str) or not sec_alert_event_short_name.strip() ): raise ValueError( "sec_alert_event_short_name must be a non-empty string" ) sql_params.append( ExecuteStoredProcedure.SqlParam( ExecuteStoredProcedure.DataType.VarChar, "sec_alert_event_short_name", sec_alert_event_short_name, ) ) if audit_action_short_name is not None: if ( not isinstance(audit_action_short_name, str) or not audit_action_short_name.strip() ): raise ValueError("audit_action_short_name must be a non-empty string") sql_params.append( ExecuteStoredProcedure.SqlParam( ExecuteStoredProcedure.DataType.VarChar, "audit_action_short_name", audit_action_short_name, ) ) response = await self.call_hq( "sdk_GetSecAlertEventDef", ExecuteStoredProcedure.SqlParameters(sql_params), ) if serialize_for_cli: response = self.serialize_for_cli( response, [ "SecAlertEventDefID", "SecAlertEventShortName", "AuditActionShortName", "ErrorReturnCode", "UISourceID", ], ) return response