"""VendorAgreement logic tier.""" from collaborator.models.rds.vendor_agreement_persister import VendorAgreementPersister from collaborator.utils import logging from collaborator.utils.error import OwsError from collaborator.utils.typing import Account, User def create_vendor_agreement(account: Account, user: User) -> dict: """Create vendor agreement. Args: account (Account): the account that creates the vendor agreement user (User): The user that creates the vendor_agreement Returns: """ result, created = VendorAgreementPersister.create_vendor_agreement(account, user) if created: logging.log_event( logging.LOG_EVENT_CREATE, "vendor_agreement", result["id"], None, result, user, ) return result def get_vendor_agreement(account: Account) -> dict: """Get vendor agreement for account. Args: account (Account): the account that creates the vendor agreement Returns: (dict): the vendor agreement """ result = VendorAgreementPersister.get_vendor_agreement_for_account(account) if not result: error_message = f"Vendor agreement for Account ID: {account.id} not found" raise OwsError.not_found(message=error_message) return result