from typing import Unpack, Optional
from q2_sdk.core.install_steps.base import (
InstallStep,
InstallStepAttribute,
InstallStepArguments,
)
from q2_sdk.hq.db.vendor_config import ConfigDataType, VendorConfig as VendorConfigDbObj
[docs]
class VendorConfig(InstallStep):
def __init__(
self,
vendor_name,
config_name,
config_value,
data_type: ConfigDataType,
description: Optional[str] = None,
**kwargs: Unpack[InstallStepArguments],
):
super().__init__(**kwargs)
self.vendor_name = InstallStepAttribute(vendor_name)
self.config_name = InstallStepAttribute(config_name)
self.config_value = InstallStepAttribute(config_value)
self.data_type = InstallStepAttribute(data_type)
self.description = InstallStepAttribute(description)
self.install_order = 20
class DataType(ConfigDataType):
pass
[docs]
async def install(self):
await super().install()
await VendorConfigDbObj(self.logger, hq_credentials=self.hq_credentials).create(
self.vendor_name.value,
self.config_name.value,
self.config_value.value,
self.data_type.value,
self.description.value,
)
[docs]
async def uninstall(self):
await VendorConfigDbObj(self.logger, hq_credentials=self.hq_credentials).delete(
self.vendor_name.value, self.config_name.value
)