# Code generated by sqlc. DO NOT EDIT.
# versions:
#   sqlc v1.29.0
# source: set_workflow_run_status_based_on_task_runs.sql
import dataclasses
from typing import Any, Optional
import uuid

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


SET_WORKFLOW_RUN_STATUS_BASED_ON_TASK_RUNS = """-- name: set_workflow_run_status_based_on_task_runs \\:one
SELECT set_workflow_run_status_based_on_task_runs FROM set_workflow_run_status_based_on_task_runs(:p1)
"""


@dataclasses.dataclass()
class SetWorkflowRunStatusBasedOnTaskRunsParams:
    workflow_run_id: uuid.UUID


class Querier:
    def __init__(self, conn: sqlalchemy.engine.Connection):
        self._conn = conn

    def set_workflow_run_status_based_on_task_runs(self, arg: SetWorkflowRunStatusBasedOnTaskRunsParams) -> Optional[Optional[Any]]:
        row = self._conn.execute(sqlalchemy.text(SET_WORKFLOW_RUN_STATUS_BASED_ON_TASK_RUNS), {"p1": arg.workflow_run_id}).first()
        if row is None:
            return None
        return row[0]


class AsyncQuerier:
    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
        self._conn = conn

    async def set_workflow_run_status_based_on_task_runs(self, arg: SetWorkflowRunStatusBasedOnTaskRunsParams) -> Optional[Optional[Any]]:
        row = (await self._conn.execute(sqlalchemy.text(SET_WORKFLOW_RUN_STATUS_BASED_ON_TASK_RUNS), {"p1": arg.workflow_run_id})).first()
        if row is None:
            return None
        return row[0]
