Audit Record

class q2_sdk.hq.db.audit_record.AuditRecordRow(element, row_class=None, rename_fields=None)[source]

Bases: TableRow

AuditAction: str
AuditID: int
AuditUUID: str
AdminUserLogonID: int
AdminUserLoginName: str
Workstation: str
UISourceID: int
SessionId: str
ActionID: int
CustomerID: int
UserID: int
UserLogonID: int
HostAccountID: int
TransactionID: int
ErrorReturnText: str
ErrorReturnCode: int
ExceptionMessage: str
ClientAddress: str
HydraID: int
HydraIDName: str
EndDateTime: datetime
DateTime: datetime
class q2_sdk.hq.db.audit_record.AuditRecordRowBase(element, row_class=None, rename_fields=None)[source]

Bases: AuditRecordRow

Deprecated This class is used for backwards compatiblity. It will be removed in a future version of the SDK.

class q2_sdk.hq.db.audit_record.AuditFilterType(*values)[source]

Bases: Enum

USERLOGON = 'userlogon'
UISOURCE = 'uisource'
class q2_sdk.hq.db.audit_record.AuditFilter(filter_type=None, filter_value=None)[source]

Bases: object

AuditFilter(filter_type: Optional[q2_sdk.hq.db.audit_record.AuditFilterType] = None, filter_value: Union[str, int] = None)

filter_type: AuditFilterType | None = None
filter_value: str | int = None
class q2_sdk.hq.db.audit_record.AuditRecord(logger, hq_credentials=None, ret_table_obj=None)[source]

Bases: DbObject

Allows for safe queries on the Q2_Audit table

Programmatic access to the Q2 database. Not as flexible as a true ORM, but takes the guesswork out of database schemas and ensures safety in the transactions.

Parameters:
  • logger – Reference to calling request’s logger (self.logger in your extension)

  • hq_credentials (Optional[HqCredentials]) – HQ Connectivity Information (Defaults to settings file)

  • ret_table_obj (Optional[bool]) – Flag to return list of LXML elements if False or TableRow objects from DB calls if True (Defaults to settings file)

REPRESENTATION_ROW_CLASS

alias of AuditRecordRow

add_arguments(parser)[source]

Hook for subclassed DbObjects to add custom arguments.

async get_by_id(audit_id, serialize_for_cli=False)[source]
Return type:

AuditRecordRow

async get_audit_session(session_id, serialize_for_cli=False)[source]

Searches for audit records by session ids from the last three days

Return type:

list[AuditRecordRow]

async get(audit_action_name, days_ago=0, record_count=100, serialize_for_cli=False, audit_id=None, **kwargs)[source]
Return type:

List[AuditRecordRow]

async create(audit_details, session_id, workstation_id=None, exception_message=None, customer_id=-1, user_id=-1, user_logon_id=-1, host_account_id=-1, transaction_id=-1, ui_source='API', audit_action_short_name='SDK', client_address=None, error_return_code=None)[source]
get_data_type(filter_type)[source]
async get_by_user_id(user_id, start_date=None, end_date=None, audit_filter=None, record_count=100, serialize_for_cli=False)[source]

Searches for audit records by user ID within a date range.

Parameters:
  • user_id (int) – The Q2_User.UserID to search for

  • start_date (Optional[datetime]) – Start of date range in ISO format (defaults to 3 days ago)

  • end_date (Optional[datetime]) – End of date range in ISO format (defaults to now)

  • audit_filter (Optional[AuditFilter]) – AuditFilter with filter_type and filter_value

  • record_count – Number of records to be returned, defaults to 100

  • serialize_for_cli (bool) – If True, returns formatted string for CLI output

Return type:

List[AuditRecordRow]

Returns:

List of AuditRecordRow objects