# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
DataSet models for UpdateGroup.
These typed dataclass models represent the tables and columns within the
DataSet parameters for the UpdateGroup HQ operation.
IMPORTANT: Update operations require a GET first to populate the original_record
field. HQ uses the unchanged row for optimistic concurrency checking.
Usage::
from q2_sdk.hq.hq_api.backoffice import UpdateGroup
q2_form_to_group_edit = UpdateGroup.Q2FormToGroupEdit(
form_id=1,
display_name="...",
group_id=1,
group_desc="...",
display_in_list=True,
)
q2_sec_alert_profile = UpdateGroup.Q2SecAlertProfile(
description="...",
enable_email_by_default=True,
)
q2_dashboard_profile = UpdateGroup.Q2DashboardProfile(
description="...",
)
q2_group = UpdateGroup.Q2Group(
group_desc="...",
sec_alert_profile_id=1,
is_commercial=True,
is_treasury=True,
)
q2_message_recipient_group_to_group_edit = UpdateGroup.Q2MessageRecipientGroupToGroupEdit(
secure_message_group_id=1,
secure_message_group_name="...",
group_id=1,
group_desc="...",
)
q2_group_default_landing_page = UpdateGroup.Q2GroupDefaultLandingPage(
group_id=1,
navigation_node_id=1,
property_id=1,
description="...",
)
q2_ui_selection_to_group_edit = UpdateGroup.Q2UiSelectionToGroupEdit(
ui_selection_id=1,
short_name="...",
description="...",
group_id=1,
language="...",
)
q2_edv_profile = UpdateGroup.Q2EdvProfile(
description="...",
token_lifetime_in_minutes=1,
)
q2_ach_class_code_to_group_edit = UpdateGroup.Q2AchClassCodeToGroupEdit(
ach_class_code_id=1,
ach_class_code="...",
end_user_description="...",
group_id=1,
)
q2_ach_class_code_group_enabled_edit = UpdateGroup.Q2AchClassCodeGroupEnabledEdit(
ach_class_code_id=1,
ach_class_code="...",
group_id=1,
)
transaction_rights = UpdateGroup.TransactionRights(
transaction_type_id=1,
transaction_type="...",
description="...",
enabled=True,
authorize=True,
cancel=True,
create=True,
create_restricted=True,
update=True,
view=1,
limit_per_transaction=1.0,
limit_per_day=1.0,
limit_per_month=1.0,
limit_per_acct_per_day=1.0,
count_per_acct_per_day=1,
count_per_day=1,
count_per_month=1,
dual_approval_limit=1.0,
token_required_limit=1.0,
bit_flags=1,
)
user_rights = UpdateGroup.UserRights(
rights_short_name="...",
rights_long_name="...",
has_rights=True,
)
user_monetary_rights = UpdateGroup.UserMonetaryRights(
rights_short_name="...",
rights_long_name="...",
amount=1.0,
)
q2_customer_account_view = UpdateGroup.Q2CustomerAccountView(
customer_account_id=1,
customer_id=1,
host_account_id=1,
account_number_internal="...",
product_name="...",
is_external_account=True,
product_id=1,
product_type_id=1,
user_access=1,
current_access_flag=1,
)
"""
from __future__ import annotations
import copy
from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional
from q2_sdk.hq.models.dataset_builder import DataSetBuilder, DataSetTable, RowState
[docs]
@dataclass
class Q2SecAlertProfile:
"""
Represents a row in the Q2_SecAlertProfile table.
"""
sec_alert_profile_id: int = -1
description: str = ""
enable_email_by_default: bool = False
original_record: Optional["Q2SecAlertProfile"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["SecAlertProfileID", "sec_alert_profile_id"],
["Description", "description"],
["EnableEmailByDefault", "enable_email_by_default"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.sec_alert_profile_id,
self.description,
self.enable_email_by_default,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"sec_alert_profile_id": int,
"description": str,
"enable_email_by_default": bool,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2SecAlertProfile":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2DashboardProfile:
"""
Represents a row in the Q2_DashboardProfile table.
"""
dashboard_profile_id: int = -1
description: str = ""
original_record: Optional["Q2DashboardProfile"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["DashboardProfileID", "dashboard_profile_id"],
["Description", "description"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.dashboard_profile_id,
self.description,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"dashboard_profile_id": int,
"description": str,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2DashboardProfile":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2Group:
"""
Represents a row in the Q2_Group table.
"""
group_id: int = -1
group_desc: str = ""
deleted_date: Optional[str] = None
default_ui_selection_id: Optional[int] = None
dashboard_profile_id: Optional[int] = None
sec_alert_profile_id: int = 0
is_commercial: bool = False
is_treasury: bool = False
policy_id: Optional[int] = None
edv_profile_id: Optional[int] = None
currency_exchange_plan_id: Optional[int] = None
original_record: Optional["Q2Group"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["GroupID", "group_id"],
["GroupDesc", "group_desc"],
["DeletedDate", "deleted_date"],
["DefaultUiSelectionID", "default_ui_selection_id"],
["DashboardProfileID", "dashboard_profile_id"],
["SecAlertProfileID", "sec_alert_profile_id"],
["IsCommercial", "is_commercial"],
["IsTreasury", "is_treasury"],
["PolicyID", "policy_id"],
["EdvProfileID", "edv_profile_id"],
["CurrencyExchangePlanID", "currency_exchange_plan_id"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.group_id,
self.group_desc,
self.deleted_date,
self.default_ui_selection_id,
self.dashboard_profile_id,
self.sec_alert_profile_id,
self.is_commercial,
self.is_treasury,
self.policy_id,
self.edv_profile_id,
self.currency_exchange_plan_id,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"group_id": int,
"group_desc": str,
"deleted_date": str,
"default_ui_selection_id": int,
"dashboard_profile_id": int,
"sec_alert_profile_id": int,
"is_commercial": bool,
"is_treasury": bool,
"policy_id": int,
"edv_profile_id": int,
"currency_exchange_plan_id": int,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2Group":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2MessageRecipientGroupToGroupEdit:
"""
Represents a row in the Q2_MessageRecipientGroupToGroupEdit table.
"""
is_available_to_group: Optional[bool] = None
secure_message_group_id: int = 0
secure_message_group_name: str = ""
secure_message_group_description: Optional[str] = None
group_id: int = 0
group_desc: str = ""
original_record: Optional["Q2MessageRecipientGroupToGroupEdit"] = field(
default=None, repr=False
)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["IsAvailableToGroup", "is_available_to_group"],
["SecureMessageGroupID", "secure_message_group_id"],
["SecureMessageGroupName", "secure_message_group_name"],
["SecureMessageGroupDescription", "secure_message_group_description"],
["GroupID", "group_id"],
["GroupDesc", "group_desc"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.is_available_to_group,
self.secure_message_group_id,
self.secure_message_group_name,
self.secure_message_group_description,
self.group_id,
self.group_desc,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"is_available_to_group": bool,
"secure_message_group_id": int,
"secure_message_group_name": str,
"secure_message_group_description": str,
"group_id": int,
"group_desc": str,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2MessageRecipientGroupToGroupEdit":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2GroupDefaultLandingPage:
"""
Represents a row in the Q2_GroupDefaultLandingPage table.
"""
is_default: Optional[bool] = None
group_id: int = 0
navigation_node_id: int = 0
route: Optional[str] = None
short_name: Optional[str] = None
property_id: int = 0
text_value: Optional[str] = None
description: str = ""
original_record: Optional["Q2GroupDefaultLandingPage"] = field(
default=None, repr=False
)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["IsDefault", "is_default"],
["GroupID", "group_id"],
["NavigationNodeID", "navigation_node_id"],
["Route", "route"],
["ShortName", "short_name"],
["PropertyID", "property_id"],
["TextValue", "text_value"],
["Description", "description"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.is_default,
self.group_id,
self.navigation_node_id,
self.route,
self.short_name,
self.property_id,
self.text_value,
self.description,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"is_default": bool,
"group_id": int,
"navigation_node_id": int,
"route": str,
"short_name": str,
"property_id": int,
"text_value": str,
"description": str,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2GroupDefaultLandingPage":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2UiSelectionToGroupEdit:
"""
Represents a row in the Q2_UiSelectionToGroupEdit table.
"""
ui_selection_id: int = 0
short_name: str = ""
description: str = ""
group_id: int = 0
is_available_to_group: Optional[bool] = None
language: str = ""
original_record: Optional["Q2UiSelectionToGroupEdit"] = field(
default=None, repr=False
)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["UiSelectionID", "ui_selection_id"],
["ShortName", "short_name"],
["Description", "description"],
["GroupID", "group_id"],
["IsAvailableToGroup", "is_available_to_group"],
["Language", "language"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.ui_selection_id,
self.short_name,
self.description,
self.group_id,
self.is_available_to_group,
self.language,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"ui_selection_id": int,
"short_name": str,
"description": str,
"group_id": int,
"is_available_to_group": bool,
"language": str,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2UiSelectionToGroupEdit":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2EdvProfile:
"""
Represents a row in the Q2_EdvProfile table.
"""
edv_profile_id: int = -1
description: str = ""
token_lifetime_in_minutes: int = 0
original_record: Optional["Q2EdvProfile"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["EdvProfileID", "edv_profile_id"],
["Description", "description"],
["TokenLifetimeInMinutes", "token_lifetime_in_minutes"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.edv_profile_id,
self.description,
self.token_lifetime_in_minutes,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"edv_profile_id": int,
"description": str,
"token_lifetime_in_minutes": int,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2EdvProfile":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2AchClassCodeToGroupEdit:
"""
Represents a row in the Q2_AchClassCodeToGroupEdit table.
"""
ach_class_code_id: int = 0
ach_class_code: str = ""
end_user_description: str = ""
group_id: int = 0
is_available_to_group: Optional[bool] = None
ach_pass_thru_requires_entitled_account: Optional[bool] = None
original_record: Optional["Q2AchClassCodeToGroupEdit"] = field(
default=None, repr=False
)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["ACHClassCodeID", "ach_class_code_id"],
["AchClassCode", "ach_class_code"],
["EndUserDescription", "end_user_description"],
["GroupID", "group_id"],
["IsAvailableToGroup", "is_available_to_group"],
[
"AchPassThruRequiresEntitledAccount",
"ach_pass_thru_requires_entitled_account",
],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.ach_class_code_id,
self.ach_class_code,
self.end_user_description,
self.group_id,
self.is_available_to_group,
self.ach_pass_thru_requires_entitled_account,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"ach_class_code_id": int,
"ach_class_code": str,
"end_user_description": str,
"group_id": int,
"is_available_to_group": bool,
"ach_pass_thru_requires_entitled_account": bool,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2AchClassCodeToGroupEdit":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2AchClassCodeGroupEnabledEdit:
"""
Represents a row in the Q2_AchClassCodeGroupEnabledEdit table.
"""
ach_class_code_id: int = 0
ach_class_code: str = ""
group_id: int = 0
is_enabled_for_group: Optional[bool] = None
original_record: Optional["Q2AchClassCodeGroupEnabledEdit"] = field(
default=None, repr=False
)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["ACHClassCodeID", "ach_class_code_id"],
["AchClassCode", "ach_class_code"],
["GroupID", "group_id"],
["IsEnabledForGroup", "is_enabled_for_group"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.ach_class_code_id,
self.ach_class_code,
self.group_id,
self.is_enabled_for_group,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"ach_class_code_id": int,
"ach_class_code": str,
"group_id": int,
"is_enabled_for_group": bool,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2AchClassCodeGroupEnabledEdit":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class TransactionRights:
"""
Represents a row in the TransactionRights table.
"""
transaction_type_id: int = 0
transaction_type: str = ""
description: str = ""
enabled: bool = False
authorize: bool = False
cancel: bool = False
create: bool = False
create_restricted: bool = False
update: bool = False
view: int = 0
limit_per_transaction: float = 0.0
limit_per_day: float = 0.0
limit_per_month: float = 0.0
limit_per_acct_per_day: float = 0.0
count_per_acct_per_day: int = 0
count_per_day: int = 0
count_per_month: int = 0
dual_approval_limit: float = 0.0
token_required_limit: float = 0.0
bit_flags: int = 0
original_record: Optional["TransactionRights"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["TransactionTypeID", "transaction_type_id"],
["TransactionType", "transaction_type"],
["Description", "description"],
["Enabled", "enabled"],
["Authorize", "authorize"],
["Cancel", "cancel"],
["Create", "create"],
["CreateRestricted", "create_restricted"],
["Update", "update"],
["View", "view"],
["LimitPerTransaction", "limit_per_transaction"],
["LimitPerDay", "limit_per_day"],
["LimitPerMonth", "limit_per_month"],
["LimitPerAcctPerDay", "limit_per_acct_per_day"],
["CountPerAcctPerDay", "count_per_acct_per_day"],
["CountPerDay", "count_per_day"],
["CountPerMonth", "count_per_month"],
["DualApprovalLimit", "dual_approval_limit"],
["TokenRequiredLimit", "token_required_limit"],
["BitFlags", "bit_flags"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.transaction_type_id,
self.transaction_type,
self.description,
self.enabled,
self.authorize,
self.cancel,
self.create,
self.create_restricted,
self.update,
self.view,
self.limit_per_transaction,
self.limit_per_day,
self.limit_per_month,
self.limit_per_acct_per_day,
self.count_per_acct_per_day,
self.count_per_day,
self.count_per_month,
self.dual_approval_limit,
self.token_required_limit,
self.bit_flags,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"transaction_type_id": int,
"transaction_type": str,
"description": str,
"enabled": bool,
"authorize": bool,
"cancel": bool,
"create": bool,
"create_restricted": bool,
"update": bool,
"view": int,
"limit_per_transaction": float,
"limit_per_day": float,
"limit_per_month": float,
"limit_per_acct_per_day": float,
"count_per_acct_per_day": int,
"count_per_day": int,
"count_per_month": int,
"dual_approval_limit": float,
"token_required_limit": float,
"bit_flags": int,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "TransactionRights":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class UserRights:
"""
Represents a row in the UserRights table.
"""
rights_short_name: str = ""
rights_long_name: str = ""
has_rights: bool = False
original_record: Optional["UserRights"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["RightsShortName", "rights_short_name"],
["RightsLongName", "rights_long_name"],
["HasRights", "has_rights"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.rights_short_name,
self.rights_long_name,
self.has_rights,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"rights_short_name": str,
"rights_long_name": str,
"has_rights": bool,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "UserRights":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class UserMonetaryRights:
"""
Represents a row in the UserMonetaryRights table.
"""
rights_short_name: str = ""
rights_long_name: str = ""
amount: float = 0.0
original_record: Optional["UserMonetaryRights"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["RightsShortName", "rights_short_name"],
["RightsLongName", "rights_long_name"],
["Amount", "amount"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.rights_short_name,
self.rights_long_name,
self.amount,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"rights_short_name": str,
"rights_long_name": str,
"amount": float,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "UserMonetaryRights":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
@dataclass
class Q2CustomerAccountView:
"""
Represents a row in the Q2_CustomerAccountView table.
"""
customer_account_id: int = 0
customer_id: int = 0
is_cif_rel: Optional[bool] = None
host_account_id: int = 0
account_number_internal: str = ""
product_name: str = ""
is_user_enabled: Optional[bool] = None
is_external_account: bool = False
product_id: int = 0
product_type_id: int = 0
user_access: int = 0
current_access_flag: int = 0
valid_customer_access_flag: Optional[int] = None
valid_system_access_flag: Optional[int] = None
original_record: Optional["Q2CustomerAccountView"] = field(default=None, repr=False)
[docs]
@staticmethod
def get_columns() -> list[list[str]]:
"""Returns [[HqColumnName, pythonAttrName], ...] mapping."""
return [
["CustomerAccountID", "customer_account_id"],
["CustomerID", "customer_id"],
["IsCifRel", "is_cif_rel"],
["HostAccountID", "host_account_id"],
["AccountNumberInternal", "account_number_internal"],
["ProductName", "product_name"],
["IsUserEnabled", "is_user_enabled"],
["IsExternalAccount", "is_external_account"],
["ProductID", "product_id"],
["ProductTypeID", "product_type_id"],
["UserAccess", "user_access"],
["CurrentAccessFlag", "current_access_flag"],
["ValidCustomerAccessFlag", "valid_customer_access_flag"],
["ValidSystemAccessFlag", "valid_system_access_flag"],
]
[docs]
def to_row_values(self) -> list[Any]:
"""Returns column values in get_columns() order."""
return [
self.customer_account_id,
self.customer_id,
self.is_cif_rel,
self.host_account_id,
self.account_number_internal,
self.product_name,
self.is_user_enabled,
self.is_external_account,
self.product_id,
self.product_type_id,
self.user_access,
self.current_access_flag,
self.valid_customer_access_flag,
self.valid_system_access_flag,
]
_COLUMN_TYPES: ClassVar[dict[str, type]] = {
"customer_account_id": int,
"customer_id": int,
"is_cif_rel": bool,
"host_account_id": int,
"account_number_internal": str,
"product_name": str,
"is_user_enabled": bool,
"is_external_account": bool,
"product_id": int,
"product_type_id": int,
"user_access": int,
"current_access_flag": int,
"valid_customer_access_flag": int,
"valid_system_access_flag": int,
}
[docs]
@classmethod
def from_hq_response(cls, row_elem) -> "Q2CustomerAccountView":
"""Parse an lxml row element into this model with original_record set."""
kwargs: dict[str, Any] = {}
for hq_name, python_name in cls.get_columns():
child = row_elem.find(hq_name)
if child is not None and child.text is not None:
target_type = cls._COLUMN_TYPES.get(python_name, str)
if target_type is bool:
kwargs[python_name] = child.text.lower() in ("true", "1")
elif target_type in (int, float):
try:
kwargs[python_name] = target_type(child.text)
except (ValueError, TypeError):
kwargs[python_name] = child.text
else:
kwargs[python_name] = child.text
instance = cls(**kwargs)
instance.original_record = copy.deepcopy(instance)
return instance
[docs]
def build_group_edit_dataset(
q2_form_to_group_edit: Optional[Q2FormToGroupEdit | list[Q2FormToGroupEdit]] = None,
q2_sec_alert_profile: Optional[Q2SecAlertProfile | list[Q2SecAlertProfile]] = None,
q2_dashboard_profile: Optional[
Q2DashboardProfile | list[Q2DashboardProfile]
] = None,
q2_group: Optional[Q2Group | list[Q2Group]] = None,
q2_message_recipient_group_to_group_edit: Optional[
Q2MessageRecipientGroupToGroupEdit | list[Q2MessageRecipientGroupToGroupEdit]
] = None,
q2_group_default_landing_page: Optional[
Q2GroupDefaultLandingPage | list[Q2GroupDefaultLandingPage]
] = None,
q2_ui_selection_to_group_edit: Optional[
Q2UiSelectionToGroupEdit | list[Q2UiSelectionToGroupEdit]
] = None,
q2_edv_profile: Optional[Q2EdvProfile | list[Q2EdvProfile]] = None,
q2_ach_class_code_to_group_edit: Optional[
Q2AchClassCodeToGroupEdit | list[Q2AchClassCodeToGroupEdit]
] = None,
q2_ach_class_code_group_enabled_edit: Optional[
Q2AchClassCodeGroupEnabledEdit | list[Q2AchClassCodeGroupEnabledEdit]
] = None,
) -> DataSetBuilder:
"""
Build the group_edit DataSet parameter for UpdateGroup.
For update operations, each model instance should have its original_record
set to the pre-modification state (from a prior GET call).
For add operations, set auto-increment ID fields to negative values.
:returns: DataSetBuilder ready to pass as the 'group_edit' parameter
"""
dataset = DataSetBuilder("DalGroupEdit")
# Q2_FormToGroupEdit
q2_form_to_group_edit_cols = [col[0] for col in Q2FormToGroupEdit.get_columns()]
q2_form_to_group_edit_table = dataset.add_table(
"Q2_FormToGroupEdit", q2_form_to_group_edit_cols
)
_add_rows_to_table(q2_form_to_group_edit_table, q2_form_to_group_edit)
# Q2_SecAlertProfile
q2_sec_alert_profile_cols = [col[0] for col in Q2SecAlertProfile.get_columns()]
q2_sec_alert_profile_table = dataset.add_table(
"Q2_SecAlertProfile", q2_sec_alert_profile_cols
)
_add_rows_to_table(q2_sec_alert_profile_table, q2_sec_alert_profile)
# Q2_DashboardProfile
q2_dashboard_profile_cols = [col[0] for col in Q2DashboardProfile.get_columns()]
q2_dashboard_profile_table = dataset.add_table(
"Q2_DashboardProfile", q2_dashboard_profile_cols
)
_add_rows_to_table(q2_dashboard_profile_table, q2_dashboard_profile)
# Q2_Group
q2_group_cols = [col[0] for col in Q2Group.get_columns()]
q2_group_table = dataset.add_table("Q2_Group", q2_group_cols)
_add_rows_to_table(q2_group_table, q2_group)
# Q2_MessageRecipientGroupToGroupEdit
q2_message_recipient_group_to_group_edit_cols = [
col[0] for col in Q2MessageRecipientGroupToGroupEdit.get_columns()
]
q2_message_recipient_group_to_group_edit_table = dataset.add_table(
"Q2_MessageRecipientGroupToGroupEdit",
q2_message_recipient_group_to_group_edit_cols,
)
_add_rows_to_table(
q2_message_recipient_group_to_group_edit_table,
q2_message_recipient_group_to_group_edit,
)
# Q2_GroupDefaultLandingPage
q2_group_default_landing_page_cols = [
col[0] for col in Q2GroupDefaultLandingPage.get_columns()
]
q2_group_default_landing_page_table = dataset.add_table(
"Q2_GroupDefaultLandingPage", q2_group_default_landing_page_cols
)
_add_rows_to_table(
q2_group_default_landing_page_table, q2_group_default_landing_page
)
# Q2_UiSelectionToGroupEdit
q2_ui_selection_to_group_edit_cols = [
col[0] for col in Q2UiSelectionToGroupEdit.get_columns()
]
q2_ui_selection_to_group_edit_table = dataset.add_table(
"Q2_UiSelectionToGroupEdit", q2_ui_selection_to_group_edit_cols
)
_add_rows_to_table(
q2_ui_selection_to_group_edit_table, q2_ui_selection_to_group_edit
)
# Q2_EdvProfile
q2_edv_profile_cols = [col[0] for col in Q2EdvProfile.get_columns()]
q2_edv_profile_table = dataset.add_table("Q2_EdvProfile", q2_edv_profile_cols)
_add_rows_to_table(q2_edv_profile_table, q2_edv_profile)
# Q2_AchClassCodeToGroupEdit
q2_ach_class_code_to_group_edit_cols = [
col[0] for col in Q2AchClassCodeToGroupEdit.get_columns()
]
q2_ach_class_code_to_group_edit_table = dataset.add_table(
"Q2_AchClassCodeToGroupEdit", q2_ach_class_code_to_group_edit_cols
)
_add_rows_to_table(
q2_ach_class_code_to_group_edit_table, q2_ach_class_code_to_group_edit
)
# Q2_AchClassCodeGroupEnabledEdit
q2_ach_class_code_group_enabled_edit_cols = [
col[0] for col in Q2AchClassCodeGroupEnabledEdit.get_columns()
]
q2_ach_class_code_group_enabled_edit_table = dataset.add_table(
"Q2_AchClassCodeGroupEnabledEdit", q2_ach_class_code_group_enabled_edit_cols
)
_add_rows_to_table(
q2_ach_class_code_group_enabled_edit_table, q2_ach_class_code_group_enabled_edit
)
return dataset
[docs]
def build_group_rights_dataset(
transaction_rights: Optional[TransactionRights | list[TransactionRights]] = None,
user_rights: Optional[UserRights | list[UserRights]] = None,
user_monetary_rights: Optional[
UserMonetaryRights | list[UserMonetaryRights]
] = None,
q2_customer_account_view: Optional[
Q2CustomerAccountView | list[Q2CustomerAccountView]
] = None,
) -> DataSetBuilder:
"""
Build the group_rights DataSet parameter for UpdateGroup.
For update operations, each model instance should have its original_record
set to the pre-modification state (from a prior GET call).
For add operations, set auto-increment ID fields to negative values.
:returns: DataSetBuilder ready to pass as the 'group_rights' parameter
"""
dataset = DataSetBuilder("UserRightsEdit")
# TransactionRights
transaction_rights_cols = [col[0] for col in TransactionRights.get_columns()]
transaction_rights_table = dataset.add_table(
"TransactionRights", transaction_rights_cols
)
_add_rows_to_table(transaction_rights_table, transaction_rights)
# UserRights
user_rights_cols = [col[0] for col in UserRights.get_columns()]
user_rights_table = dataset.add_table("UserRights", user_rights_cols)
_add_rows_to_table(user_rights_table, user_rights)
# UserMonetaryRights
user_monetary_rights_cols = [col[0] for col in UserMonetaryRights.get_columns()]
user_monetary_rights_table = dataset.add_table(
"UserMonetaryRights", user_monetary_rights_cols
)
_add_rows_to_table(user_monetary_rights_table, user_monetary_rights)
# Q2_CustomerAccountView
q2_customer_account_view_cols = [
col[0] for col in Q2CustomerAccountView.get_columns()
]
q2_customer_account_view_table = dataset.add_table(
"Q2_CustomerAccountView", q2_customer_account_view_cols
)
_add_rows_to_table(q2_customer_account_view_table, q2_customer_account_view)
return dataset
def _add_rows_to_table(
table: DataSetTable,
records: Optional[Any | list],
) -> None:
"""
Add rows to a DataSetTable from one or more model instances.
Handles Modified+Unchanged pairs (for updates), Added rows (for inserts),
and Deleted rows automatically based on each record's original_record field.
"""
if records is None:
return
if not isinstance(records, list):
records = [records]
for record in records:
values = record.to_row_values()
if record.original_record is not None:
# Update: emit Modified row (new values) + Unchanged row (original)
table.add_row(RowState.MODIFIED, values)
table.add_row(RowState.UNCHANGED, record.original_record.to_row_values())
else:
# Add: emit Added row (new record)
table.add_row(RowState.ADDED, values)