from typing import ClassVar, Union

BoolLike = Union[bool, BooleanExpression]
NumberLike = Union[float, int, NumberExpression]
StringLike = Union[str, StringExpression]

class BooleanExpression:
    def as_num(self) -> NumberExpression: ...
    def as_str(self) -> StringExpression: ...
    def as_obj(self) -> ObjectExpression: ...
    def __invert__(self) -> BooleanExpression: ...
    def __and__(self, other: BoolLike) -> BooleanExpression: ...
    def __or__(self, other: BoolLike) -> BooleanExpression: ...
    def __eq__(self, other: BoolLike) -> BooleanExpression: ...  # ty:ignore[invalid-method-override]
    def __ne__(self, other: BoolLike) -> BooleanExpression: ...  # ty:ignore[invalid-method-override]
    def if_else(
        self, condition: BoolLike, else_expr: BoolLike
    ) -> BooleanExpression: ...
    def to_json(self) -> ObjectExpression: ...

class NumberExpression:
    def as_bool(self) -> BooleanExpression: ...
    def as_str(self) -> StringExpression: ...
    def as_obj(self) -> ObjectExpression: ...
    def __lt__(self, other: NumberLike) -> BooleanExpression: ...
    def __le__(self, other: NumberLike) -> BooleanExpression: ...
    def __gt__(self, other: NumberLike) -> BooleanExpression: ...
    def __ge__(self, other: NumberLike) -> BooleanExpression: ...
    def __eq__(self, other: NumberLike) -> BooleanExpression: ...  # ty:ignore[invalid-method-override]
    def __ne__(self, other: NumberLike) -> BooleanExpression: ...  # ty:ignore[invalid-method-override]
    def if_else(
        self, condition: BoolLike, else_expr: NumberLike
    ) -> NumberExpression: ...
    def to_json(self) -> ObjectExpression: ...

class StringExpression:
    def as_bool(self) -> BooleanExpression: ...
    def as_num(self) -> NumberExpression: ...
    def as_obj(self) -> ObjectExpression: ...
    def __eq__(self, other: StringLike) -> BooleanExpression: ...  # ty:ignore[invalid-method-override]
    def __ne__(self, other: StringLike) -> BooleanExpression: ...  # ty:ignore[invalid-method-override]
    def contains(self, other: StringLike) -> BooleanExpression: ...
    def startswith(self, other: StringLike) -> BooleanExpression: ...
    def endswith(self, other: StringLike) -> BooleanExpression: ...
    def format(self, args: list[StringLike]) -> StringExpression: ...
    def to_json(self) -> ObjectExpression: ...
    def from_json_to_bool(self) -> BooleanExpression: ...
    def from_json_to_num(self) -> NumberExpression: ...
    def from_json_to_str(self) -> StringExpression: ...
    def from_json_to_array(self) -> ArrayExpression: ...
    def from_json_to_obj(self) -> ObjectExpression: ...
    def hash_files(
        self, others: list[StringLike] | None = None
    ) -> StringExpression: ...
    def if_else(
        self, condition: BoolLike, else_expr: StringLike
    ) -> StringExpression: ...

class ArrayExpression:
    def as_num(self) -> NumberExpression: ...
    def as_obj(self) -> ObjectExpression: ...
    def contains(self, other: ObjectExpression) -> BooleanExpression: ...
    def join(self, separator: StringLike | None = None) -> StringExpression: ...
    def to_json(self) -> ObjectExpression: ...

class ObjectExpression:
    def as_num(self) -> NumberExpression: ...
    def as_str(self) -> StringExpression: ...
    def as_bool(self) -> BooleanExpression: ...
    def as_array(self) -> ArrayExpression: ...
    def to_json(self) -> ObjectExpression: ...
    def from_json_to_bool(self) -> BooleanExpression: ...
    def from_json_to_num(self) -> NumberExpression: ...
    def from_json_to_str(self) -> ObjectExpression: ...
    def from_json_to_array(self) -> ArrayExpression: ...
    def from_json_to_obj(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> ObjectExpression: ...
    def __getattr__(self, key: str) -> ObjectExpression: ...
    def get(self, key: str) -> ObjectExpression: ...

class GithubContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def action(self) -> StringExpression: ...
    @property
    def action_path(self) -> StringExpression: ...
    @property
    def action_ref(self) -> StringExpression: ...
    @property
    def action_repository(self) -> StringExpression: ...
    @property
    def action_status(self) -> StringExpression: ...
    @property
    def actor(self) -> StringExpression: ...
    @property
    def actor_id(self) -> StringExpression: ...
    @property
    def api_url(self) -> StringExpression: ...
    @property
    def base_ref(self) -> StringExpression: ...
    @property
    def env(self) -> StringExpression: ...
    @property
    def event(self) -> ObjectExpression: ...
    @property
    def event_name(self) -> StringExpression: ...
    @property
    def event_path(self) -> StringExpression: ...
    @property
    def graphql_url(self) -> StringExpression: ...
    @property
    def head_ref(self) -> StringExpression: ...
    @property
    def job(self) -> StringExpression: ...
    @property
    def path(self) -> StringExpression: ...
    @property
    def ref(self) -> StringExpression: ...
    @property
    def ref_name(self) -> StringExpression: ...
    @property
    def ref_protected(self) -> BooleanExpression: ...
    @property
    def ref_type(self) -> StringExpression: ...
    @property
    def repository(self) -> StringExpression: ...
    @property
    def reporitory_id(self) -> StringExpression: ...
    @property
    def repositor_owner(self) -> StringExpression: ...
    @property
    def repository_owner_id(self) -> StringExpression: ...
    @property
    def repository_url(self) -> StringExpression: ...
    @property
    def retention_days(self) -> StringExpression: ...
    @property
    def run_id(self) -> StringExpression: ...
    @property
    def run_number(self) -> StringExpression: ...
    @property
    def run_attempt(self) -> StringExpression: ...
    @property
    def secret_source(self) -> StringExpression: ...
    @property
    def server_url(self) -> StringExpression: ...
    @property
    def sha(self) -> StringExpression: ...
    @property
    def token(self) -> StringExpression: ...
    @property
    def triggering_actor(self) -> StringExpression: ...
    @property
    def workflow(self) -> StringExpression: ...
    @property
    def workflow_ref(self) -> StringExpression: ...
    @property
    def workflow_sha(self) -> StringExpression: ...
    @property
    def workspace(self) -> StringExpression: ...

class EnvContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> StringExpression: ...
    def __getattr__(self, key: str) -> StringExpression: ...

class VarsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> StringExpression: ...
    def __getattr__(self, key: str) -> StringExpression: ...

class JobContainerContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def id(self) -> StringExpression: ...
    @property
    def network(self) -> StringExpression: ...

class JobServicesIdContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def id(self) -> StringExpression: ...
    @property
    def network(self) -> StringExpression: ...
    @property
    def ports(self) -> ObjectExpression: ...

class JobServicesContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> JobServicesIdContext: ...
    def __getattr__(self, key: str) -> JobServicesIdContext: ...

class JobContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def check_run_id(self) -> NumberExpression: ...
    @property
    def container(self) -> JobContainerContext: ...
    @property
    def services(self) -> JobServicesContext: ...
    @property
    def status(self) -> StringExpression: ...

class JobsJobIdOutputsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> StringExpression: ...
    def __getattr__(self, key: str) -> StringExpression: ...

class JobsJobIdContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def result(self) -> StringExpression: ...
    @property
    def outputs(self) -> JobsJobIdOutputsContext: ...

class JobsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> JobsJobIdContext: ...
    def __getattr__(self, key: str) -> JobsJobIdContext: ...

class StepsStepIdOutputsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> StringExpression: ...
    def __getattr__(self, key: str) -> StringExpression: ...

class StepsStepIdContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def outputs(self) -> StepsStepIdOutputsContext: ...
    @property
    def conclusion(self) -> StringExpression: ...
    @property
    def outcome(self) -> StringExpression: ...

class StepsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> StepsStepIdContext: ...
    def __getattr__(self, key: str) -> StepsStepIdContext: ...

class RunnerContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def name(self) -> StringExpression: ...
    @property
    def os(self) -> StringExpression: ...
    @property
    def arch(self) -> StringExpression: ...
    @property
    def temp(self) -> StringExpression: ...
    @property
    def tool_cache(self) -> StringExpression: ...
    @property
    def debug(self) -> StringExpression: ...
    @property
    def environment(self) -> StringExpression: ...

class SecretsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def github_token(self) -> StringExpression: ...
    def __getitem__(self, key: str) -> StringExpression: ...
    def __getattr__(self, key: str) -> StringExpression: ...

class StrategyContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def fail_fast(self) -> BooleanExpression: ...
    @property
    def job_index(self) -> NumberExpression: ...
    @property
    def job_total(self) -> NumberExpression: ...
    @property
    def max_parallel(self) -> NumberExpression: ...

class MatrixContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> ObjectExpression: ...
    def __getattr__(self, key: str) -> ObjectExpression: ...

class NeedsJobIdOutputsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> StringExpression: ...
    def __getattr__(self, key: str) -> StringExpression: ...

class NeedsJobIdContext:
    @property
    def expr(self) -> ObjectExpression: ...
    @property
    def outputs(self) -> NeedsJobIdOutputsContext: ...
    @property
    def result(self) -> StringExpression: ...

class NeedsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> NeedsJobIdContext: ...
    def __getattr__(self, key: str) -> NeedsJobIdContext: ...

class InputsContext:
    @property
    def expr(self) -> ObjectExpression: ...
    def __getitem__(self, key: str) -> ObjectExpression: ...
    def __getattr__(self, key: str) -> ObjectExpression: ...

class context:  # noqa: N801
    github: ClassVar[GithubContext]
    env: ClassVar[EnvContext]
    vars: ClassVar[VarsContext]
    job: ClassVar[JobContext]
    jobs: ClassVar[JobsContext]
    steps: ClassVar[StepsContext]
    runner: ClassVar[RunnerContext]
    secrets: ClassVar[SecretsContext]
    strategy: ClassVar[StrategyContext]
    matrix: ClassVar[MatrixContext]
    needs: ClassVar[NeedsContext]
    inputs: ClassVar[InputsContext]

def success() -> BooleanExpression: ...
def always() -> BooleanExpression: ...
def cancelled() -> BooleanExpression: ...
def failure() -> BooleanExpression: ...
def lit_str(s: str) -> StringExpression: ...
def lit_bool(b: bool) -> BooleanExpression: ...
def lit_num(n: float) -> NumberExpression: ...

__all__ = [
    'ArrayExpression',
    'BooleanExpression',
    'NumberExpression',
    'ObjectExpression',
    'StringExpression',
    'always',
    'cancelled',
    'context',
    'failure',
    'lit_bool',
    'lit_num',
    'lit_str',
    'success',
]
