Source code for q2_sdk.core.install_steps.third_party_data_element

from typing import Unpack

from q2_sdk.core.exceptions import DevOnlyError
from q2_sdk.core.install_steps.base import (
    InstallStep,
    InstallStepAttribute,
    InstallStepArguments,
)
from q2_sdk.hq.db.third_party_data_element import (
    ThirdPartyDataElement as ThirdPartyDataElementDbObj,
)


[docs] class ThirdPartyDataElement(InstallStep): """Interacts with the Q2_ThirdPartyData table""" def __init__(self, short_name, description, **kwargs: Unpack[InstallStepArguments]): super().__init__(**kwargs) self.short_name = InstallStepAttribute(short_name) self.description = InstallStepAttribute(description) self.install_order = 20
[docs] async def install(self): await super().install() await ThirdPartyDataElementDbObj( self.logger, hq_credentials=self.hq_credentials ).create(self.short_name.value, self.description.value)
[docs] async def uninstall(self): try: await ThirdPartyDataElementDbObj( self.logger, hq_credentials=self.hq_credentials ).delete(self.short_name.value) except DevOnlyError: self.logger.info( "Skipping ThirdPartyDataElementDbObj delete because we are not in dev" )