from typing import Optional
from q2_sdk.core.install_steps.base import InstallStep, InstallStepAttribute
from q2_sdk.hq.db.host_account_data_element import (
HostAccountDataElement as HADEDbObject,
CreateHADEParams,
HADEDataTypes,
)
[docs]
class HostAccountDataElement(InstallStep):
"""Interacts with the Q2_HostAccountDataElement table"""
def __init__(
self,
hade_description: str,
hade_data_type: HADEDataTypes | str,
hade_name: str,
host_account_click_type_id: Optional[int] = None,
click_type_attributes: Optional[str] = None,
ui_text_element: Optional[str] = None,
ui_text_element_id: Optional[int] = None,
additional_desc_ui_text_element: Optional[str] = None,
additional_desc_ui_text_element_id: Optional[int] = None,
is_editable: bool = False,
**kwargs,
):
super().__init__(**kwargs)
if isinstance(hade_data_type, HADEDataTypes):
hade_data_type = hade_data_type.value
self.hade_description = InstallStepAttribute(hade_description)
self.hade_data_type = InstallStepAttribute(hade_data_type)
self.hade_name = InstallStepAttribute(hade_name)
self.host_account_click_type_id = InstallStepAttribute(
host_account_click_type_id
)
self.click_type_attributes = InstallStepAttribute(click_type_attributes)
self.ui_text_element = InstallStepAttribute(ui_text_element)
self.ui_text_element_id = InstallStepAttribute(ui_text_element_id)
self.additional_desc_ui_text_element = InstallStepAttribute(
additional_desc_ui_text_element
)
self.additional_desc_ui_text_element_id = InstallStepAttribute(
additional_desc_ui_text_element_id
)
self.is_editable = InstallStepAttribute(is_editable, is_bool=True)
[docs]
async def install(self):
install_obj = CreateHADEParams(
self.hade_description.value,
self.hade_data_type.value,
self.hade_name.value,
host_account_click_type_id=self.host_account_click_type_id.value,
click_type_attributes=self.click_type_attributes.value,
ui_text_element=self.ui_text_element.value,
ui_text_element_id=self.ui_text_element_id.value,
additional_desc_ui_text_element=self.additional_desc_ui_text_element.value,
additional_desc_ui_text_element_id=self.additional_desc_ui_text_element_id.value,
is_editable=self.is_editable.value,
)
db_obj = HADEDbObject(self.logger, hq_credentials=self.hq_credentials)
await db_obj.create(install_obj)
[docs]
async def uninstall(self):
"""
Other tables or products could rely on these hades, so uninstall shouldn't be allowed at this time
"""
pass