from typing import Unpack
from q2_sdk.core.install_steps.base import (
InstallStep,
InstallStepAttribute,
InstallStepArguments,
)
from q2_sdk.hq.db.ui_config_property_data import (
UiConfigPropertyData as UiConfigPropertyDataDbObj,
)
[docs]
class UIConfigPropertyData(InstallStep):
"""
Interacts with the Q2_UiConfigPropertyData and Q2_UiConfigPropertyDataElements tables
"""
def __init__(
self,
property_name,
property_data_type,
property_value,
**kwargs: Unpack[InstallStepArguments],
):
super().__init__(**kwargs)
if isinstance(property_value, bool):
property_value = str(property_value).lower()
self.property_name = InstallStepAttribute(property_name)
self.property_data_type = InstallStepAttribute(property_data_type)
self.property_value = InstallStepAttribute(str(property_value))
[docs]
async def install(self, is_central=False):
await super().install()
is_central = is_central or self.is_central
await UiConfigPropertyDataDbObj(
self.logger, hq_credentials=self.hq_credentials
).create(
self.property_name.value,
self.property_data_type.value,
self.property_value.value,
is_central=is_central,
)
[docs]
async def uninstall(self):
await UiConfigPropertyDataDbObj(
self.logger, hq_credentials=self.hq_credentials
).delete(self.property_name.value)