"""
This type stub file was generated by pyright.
"""

import temporalio.api.common.v1
import temporalio.api.enums.v1
import temporalio.api.history.v1
import temporalio.api.schedule.v1
import temporalio.api.workflow.v1
import temporalio.api.workflowservice.v1
import temporalio.common
import temporalio.converter
import temporalio.exceptions
import temporalio.runtime
import temporalio.service
import temporalio.workflow
from abc import ABC
from dataclasses import dataclass
from datetime import datetime, timedelta
from enum import Enum, IntEnum
from typing import (
    Any,
    AsyncIterator,
    Awaitable,
    Callable,
    Dict,
    FrozenSet,
    Generic,
    Mapping,
    Optional,
    Sequence,
    Type,
    Union,
    overload,
    TypeVarTuple,
    Unpack,
)
from typing_extensions import Concatenate, TypedDict
from temporalio.service import KeepAliveConfig, RetryConfig, TLSConfig
from .types import (
    AnyType,
    LocalReturnType,
    MethodAsyncNoParam,
    MethodAsyncSingleParam,
    MethodSyncOrAsyncNoParam,
    MethodSyncOrAsyncSingleParam,
    MultiParamSpec,
    ParamType,
    ReturnType,
    SelfType,
)

"""Client for accessing Temporal."""

class Client:
    """Client for accessing Temporal.

    Most users will use :py:meth:`connect` to create a client. The
    :py:attr:`service` property provides access to a raw gRPC client. To create
    another client, like for a different namespace, :py:func:`Client` may be
    directly instantiated with a :py:attr:`service` of another.

    Clients are not thread-safe and should only be used in the event loop they
    are first connected in. If a client needs to be used from another thread
    than where it was created, make sure the event loop where it was created is
    captured, and then call :py:func:`asyncio.run_coroutine_threadsafe` with the
    client call and that event loop.

    Clients do not work across forks since runtimes do not work across forks.
    """

    @staticmethod
    async def connect(
        target_host: str,
        *,
        namespace: str = ...,
        data_converter: temporalio.converter.DataConverter = ...,
        interceptors: Sequence[Interceptor] = ...,
        default_workflow_query_reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
        tls: Union[bool, TLSConfig] = ...,
        retry_config: Optional[RetryConfig] = ...,
        keep_alive_config: Optional[KeepAliveConfig] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        identity: Optional[str] = ...,
        lazy: bool = ...,
        runtime: Optional[temporalio.runtime.Runtime] = ...,
    ) -> Client:
        """Connect to a Temporal server.

        Args:
            target_host: ``host:port`` for the Temporal server. For local
                development, this is often "localhost:7233".
            namespace: Namespace to use for client calls.
            data_converter: Data converter to use for all data conversions
                to/from payloads.
            interceptors: Set of interceptors that are chained together to allow
                intercepting of client calls. The earlier interceptors wrap the
                later ones.

                Any interceptors that also implement
                :py:class:`temporalio.worker.Interceptor` will be used as worker
                interceptors too so they should not be given when creating a
                worker.
            default_workflow_query_reject_condition: The default rejection
                condition for workflow queries if not set during query. See
                :py:meth:`WorkflowHandle.query` for details on the rejection
                condition.
            tls: If false, the default, do not use TLS. If true, use system
                default TLS configuration. If TLS configuration present, that
                TLS configuration will be used.
            retry_config: Retry configuration for direct service calls (when
                opted in) or all high-level calls made by this client (which all
                opt-in to retries by default). If unset, a default retry
                configuration is used.
            keep_alive_config: Keep-alive configuration for the client
                connection. Default is to check every 30s and kill the
                connection if a response doesn't come back in 15s. Can be set to
                ``None`` to disable.
            rpc_metadata: Headers to use for all calls to the server. Keys here
                can be overriden by per-call RPC metadata keys.
            identity: Identity for this client. If unset, a default is created
                based on the version of the SDK.
            lazy: If true, the client will not connect until the first call is
                attempted or a worker is created with it. Lazy clients cannot be
                used for workers.
            runtime: The runtime for this client, or the default if unset.
        """
        ...
    def __init__(
        self,
        service_client: temporalio.service.ServiceClient,
        *,
        namespace: str = ...,
        data_converter: temporalio.converter.DataConverter = ...,
        interceptors: Sequence[Interceptor] = ...,
        default_workflow_query_reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
    ) -> None:
        """Create a Temporal client from a service client.

        See :py:meth:`connect` for details on the parameters.
        """
        ...
    def config(self) -> ClientConfig:
        """Config, as a dictionary, used to create this client.

        This makes a shallow copy of the config each call.
        """
        ...
    @property
    def service_client(self) -> temporalio.service.ServiceClient:
        """Raw gRPC service client."""
        ...
    @property
    def workflow_service(self) -> temporalio.service.WorkflowService:
        """Raw gRPC workflow service client."""
        ...
    @property
    def operator_service(self) -> temporalio.service.OperatorService:
        """Raw gRPC operator service client."""
        ...
    @property
    def test_service(self) -> temporalio.service.TestService:
        """Raw gRPC test service client."""
        ...
    @property
    def namespace(self) -> str:
        """Namespace used in calls by this client."""
        ...
    @property
    def identity(self) -> str:
        """Identity used in calls by this client."""
        ...
    @property
    def data_converter(self) -> temporalio.converter.DataConverter:
        """Data converter used by this client."""
        ...
    @property
    def rpc_metadata(self) -> Mapping[str, str]:
        """Headers for every call made by this client.

        Do not use mutate this mapping. Rather, set this property with an
        entirely new mapping to change the headers.
        """
        ...
    @rpc_metadata.setter
    def rpc_metadata(self, value: Mapping[str, str]) -> None:
        """Update the headers for this client.

        Do not mutate this mapping after set. Rather, set an entirely new
        mapping if changes are needed.
        """
        ...
    @overload
    async def start_workflow(
        self,
        workflow: MethodAsyncNoParam[SelfType, ReturnType],
        *,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowHandle[SelfType, ReturnType]: ...
    @overload
    async def start_workflow(
        self,
        workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
        arg: ParamType,
        *,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowHandle[SelfType, ReturnType]: ...

    Ts = TypeVarTuple("Ts")
    @overload
    async def start_workflow(
        self,
        workflow: Callable[[SelfType, Unpack[Ts]], Awaitable[ReturnType]],
        *,
        args: tuple[Unpack[Ts]],
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowHandle[SelfType, ReturnType]: ...
    @overload
    async def start_workflow(
        self,
        workflow: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: str,
        task_queue: str,
        result_type: Optional[Type] = ...,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowHandle[Any, Any]: ...
    async def start_workflow(
        self,
        workflow: Union[str, Callable[[Unpack[Ts]], Awaitable[Any]]],
        arg: Any = ...,
        *,
        args: Sequence[Unpack[Ts]] = ...,
        id: str,
        task_queue: str,
        result_type: Optional[Type] = ...,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
        stack_level: int = ...,
    ) -> WorkflowHandle[Any, Any]:
        """Start a workflow and return its handle.

        Args:
            workflow: String name or class method decorated with
                ``@workflow.run`` for the workflow to start.
            arg: Single argument to the workflow.
            args: Multiple arguments to the workflow. Cannot be set if arg is.
            id: Unique identifier for the workflow execution.
            task_queue: Task queue to run the workflow on.
            result_type: For string workflows, this can set the specific result
                type hint to deserialize into.
            execution_timeout: Total workflow execution timeout including
                retries and continue as new.
            run_timeout: Timeout of a single workflow run.
            task_timeout: Timeout of a single workflow task.
            id_reuse_policy: How already-existing IDs are treated.
            retry_policy: Retry policy for the workflow.
            cron_schedule: See https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
            memo: Memo for the workflow.
            search_attributes: Search attributes for the workflow. The
                dictionary form of this is deprecated, use
                :py:class:`temporalio.common.TypedSearchAttributes`.
            start_delay: Amount of time to wait before starting the workflow.
                This does not work with ``cron_schedule``. This is currently
                experimental.
            start_signal: If present, this signal is sent as signal-with-start
                instead of traditional workflow start.
            start_signal_args: Arguments for start_signal if start_signal
                present.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Returns:
            A workflow handle to the started workflow.

        Raises:
            temporalio.exceptions.WorkflowAlreadyStartedError: Workflow has
                already been started.
            RPCError: Workflow could not be started for some other reason.
        """
        ...
    @overload
    async def execute_workflow(
        self,
        workflow: MethodAsyncNoParam[SelfType, ReturnType],
        *,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> ReturnType: ...
    @overload
    async def execute_workflow(
        self,
        workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
        arg: ParamType,
        *,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> ReturnType: ...
    @overload
    async def execute_workflow(
        self,
        workflow: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
        *,
        args: Sequence[Any],
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> ReturnType: ...
    @overload
    async def execute_workflow(
        self,
        workflow: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: str,
        task_queue: str,
        result_type: Optional[Type] = ...,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> Any: ...
    async def execute_workflow(
        self,
        workflow: Union[str, Callable[..., Awaitable[Any]]],
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: str,
        task_queue: str,
        result_type: Optional[Type] = ...,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        cron_schedule: str = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        start_delay: Optional[timedelta] = ...,
        start_signal: Optional[str] = ...,
        start_signal_args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> Any:
        """Start a workflow and wait for completion.

        This is a shortcut for :py:meth:`start_workflow` +
        :py:meth:`WorkflowHandle.result`.
        """
        ...
    def get_workflow_handle(
        self,
        workflow_id: str,
        *,
        run_id: Optional[str] = ...,
        first_execution_run_id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
    ) -> WorkflowHandle[Any, Any]:
        """Get a workflow handle to an existing workflow by its ID.

        Args:
            workflow_id: Workflow ID to get a handle to.
            run_id: Run ID that will be used for all calls.
            first_execution_run_id: First execution run ID used for cancellation
                and termination.
            result_type: The result type to deserialize into if known.

        Returns:
            The workflow handle.
        """
        ...
    def get_workflow_handle_for(
        self,
        workflow: Union[
            MethodAsyncNoParam[SelfType, ReturnType],
            MethodAsyncSingleParam[SelfType, Any, ReturnType],
        ],
        workflow_id: str,
        *,
        run_id: Optional[str] = ...,
        first_execution_run_id: Optional[str] = ...,
    ) -> WorkflowHandle[SelfType, ReturnType]:
        """Get a typed workflow handle to an existing workflow by its ID.

        This is the same as :py:meth:`get_workflow_handle` but typed.

        Args:
            workflow: The workflow run method to use for typing the handle.
            workflow_id: Workflow ID to get a handle to.
            run_id: Run ID that will be used for all calls.
            first_execution_run_id: First execution run ID used for cancellation
                and termination.

        Returns:
            The workflow handle.
        """
        ...
    def list_workflows(
        self,
        query: Optional[str] = ...,
        *,
        page_size: int = ...,
        next_page_token: Optional[bytes] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowExecutionAsyncIterator:
        """List workflows.

        This does not make a request until the first iteration is attempted.
        Therefore any errors will not occur until then.

        Args:
            query: A Temporal visibility list filter. See Temporal documentation
                concerning visibility list filters including behavior when left
                unset.
            page_size: Maximum number of results for each page.
            next_page_token: A previously obtained next page token if doing
                pagination. Usually not needed as the iterator automatically
                starts from the beginning.
            rpc_metadata: Headers used on each RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call.

        Returns:
            An async iterator that can be used with ``async for``.
        """
        ...
    @overload
    def get_async_activity_handle(
        self, *, workflow_id: str, run_id: Optional[str], activity_id: str
    ) -> AsyncActivityHandle: ...
    @overload
    def get_async_activity_handle(self, *, task_token: bytes) -> AsyncActivityHandle: ...
    def get_async_activity_handle(
        self,
        *,
        workflow_id: Optional[str] = ...,
        run_id: Optional[str] = ...,
        activity_id: Optional[str] = ...,
        task_token: Optional[bytes] = ...,
    ) -> AsyncActivityHandle:
        """Get an async activity handle.

        Either the workflow_id, run_id, and activity_id can be provided, or a
        singular task_token can be provided.

        Args:
            workflow_id: Workflow ID for the activity. Cannot be set if
                task_token is set.
            run_id: Run ID for the activity. Cannot be set if task_token is set.
            activity_id: ID for the activity. Cannot be set if task_token is
                set.
            task_token: Task token for the activity. Cannot be set if any of the
                id parameters are set.

        Returns:
            A handle that can be used for completion or heartbeat.
        """
        ...
    async def create_schedule(
        self,
        id: str,
        schedule: Schedule,
        *,
        trigger_immediately: bool = ...,
        backfill: Sequence[ScheduleBackfill] = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        search_attributes: Optional[
            Union[
                temporalio.common.TypedSearchAttributes,
                temporalio.common.SearchAttributes,
            ]
        ] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> ScheduleHandle:
        """Create a schedule and return its handle.

        Args:
            id: Unique identifier of the schedule.
            schedule: Schedule to create.
            trigger_immediately: If true, trigger one action immediately when
                creating the schedule.
            backfill: Set of time periods to take actions on as if that time
                passed right now.
            memo: Memo for the schedule. Memo for a scheduled workflow is part
                of the schedule action.
            search_attributes: Search attributes for the schedule. Search
                attributes for a scheduled workflow are part of the scheduled
                action. The dictionary form of this is DEPRECATED, use
                :py:class:`temporalio.common.TypedSearchAttributes`.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Returns:
            A handle to the created schedule.

        Raises:
            ScheduleAlreadyRunningError: If a schedule with this ID is already
                running.
        """
        ...
    def get_schedule_handle(self, id: str) -> ScheduleHandle:
        """Get a schedule handle for the given ID."""
        ...
    async def list_schedules(
        self,
        *,
        page_size: int = ...,
        next_page_token: Optional[bytes] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> ScheduleAsyncIterator:
        """List schedules.

        This does not make a request until the first iteration is attempted.
        Therefore any errors will not occur until then.

        Note, this list is eventually consistent. Therefore if a schedule is
        added or deleted, it may not be available in the list immediately.

        Args:
            page_size: Maximum number of results for each page.
            next_page_token: A previously obtained next page token if doing
                pagination. Usually not needed as the iterator automatically
                starts from the beginning.
            rpc_metadata: Headers used on each RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call.

        Returns:
            An async iterator that can be used with ``async for``.
        """
        ...
    async def update_worker_build_id_compatibility(
        self,
        task_queue: str,
        operation: BuildIdOp,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Used to add new Build IDs or otherwise update the relative compatibility of Build Ids as
        defined on a specific task queue for the Worker Versioning feature.

        For more on this feature, see https://docs.temporal.io/workers#worker-versioning

        .. warning::
           This API is experimental

        Args:
            task_queue: The task queue to target.
            operation: The operation to perform.
            rpc_metadata: Headers used on each RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call.
        """
        ...
    async def get_worker_build_id_compatibility(
        self,
        task_queue: str,
        max_sets: Optional[int] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkerBuildIdVersionSets:
        """Get the Build ID compatibility sets for a specific task queue.

        For more on this feature, see https://docs.temporal.io/workers#worker-versioning

        .. warning::
           This API is experimental

        Args:
            task_queue: The task queue to target.
            max_sets: The maximum number of sets to return. If not specified, all sets will be
                returned.
            rpc_metadata: Headers used on each RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call.
        """
        ...
    async def get_worker_task_reachability(
        self,
        build_ids: Sequence[str],
        task_queues: Sequence[str] = ...,
        reachability_type: Optional[TaskReachabilityType] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkerTaskReachability:
        """Determine if some Build IDs for certain Task Queues could have tasks dispatched to them.

        For more on this feature, see https://docs.temporal.io/workers#worker-versioning

        .. warning::
           This API is experimental

        Args:
            build_ids: The Build IDs to query the reachability of. At least one must be specified.
            task_queues: Task Queues to restrict the query to. If not specified, all Task Queues
                will be searched. When requesting a large number of task queues or all task queues
                associated with the given Build IDs in a namespace, all Task Queues will be listed
                in the response but some of them may not contain reachability information due to a
                server enforced limit. When reaching the limit, task queues that reachability
                information could not be retrieved for will be marked with a ``NotFetched`` entry in
                {@link BuildIdReachability.taskQueueReachability}. The caller may issue another call
                to get the reachability for those task queues.
            reachability_type: The kind of reachability this request is concerned with.
            rpc_metadata: Headers used on each RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call.
        """
        ...

class ClientConfig(TypedDict, total=False):
    """TypedDict of config originally passed to :py:meth:`Client`."""

    service_client: temporalio.service.ServiceClient
    namespace: str
    data_converter: temporalio.converter.DataConverter
    interceptors: Sequence[Interceptor]
    default_workflow_query_reject_condition: Optional[temporalio.common.QueryRejectCondition]
    ...

class WorkflowHistoryEventFilterType(IntEnum):
    """Type of history events to get for a workflow.

    See :py:class:`temporalio.api.enums.v1.HistoryEventFilterType`.
    """

    ALL_EVENT = ...
    CLOSE_EVENT = ...

class WorkflowHandle(Generic[SelfType, ReturnType]):
    """Handle for interacting with a workflow.

    This is usually created via :py:meth:`Client.get_workflow_handle` or
    returned from :py:meth:`Client.start_workflow`.
    """

    def __init__(
        self,
        client: Client,
        id: str,
        *,
        run_id: Optional[str] = ...,
        result_run_id: Optional[str] = ...,
        first_execution_run_id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
    ) -> None:
        """Create workflow handle."""
        ...
    @property
    def id(self) -> str:
        """ID for the workflow."""
        ...
    @property
    def run_id(self) -> Optional[str]:
        """Run ID used for :py:meth:`signal` and :py:meth:`query` calls if
        present to ensure the query or signal happen on this exact run.

        This is only created via :py:meth:`Client.get_workflow_handle`.
        :py:meth:`Client.start_workflow` will not set this value.

        This cannot be mutated. If a different run ID is needed,
        :py:meth:`Client.get_workflow_handle` must be used instead.
        """
        ...
    @property
    def result_run_id(self) -> Optional[str]:
        """Run ID used for :py:meth:`result` calls if present to ensure result
        is for a workflow starting from this run.

        When this handle is created via :py:meth:`Client.get_workflow_handle`,
        this is the same as run_id. When this handle is created via
        :py:meth:`Client.start_workflow`, this value will be the resulting run
        ID.

        This cannot be mutated. If a different run ID is needed,
        :py:meth:`Client.get_workflow_handle` must be used instead.
        """
        ...
    @property
    def first_execution_run_id(self) -> Optional[str]:
        """Run ID used for :py:meth:`cancel` and :py:meth:`terminate` calls if
        present to ensure the cancel and terminate happen for a workflow ID
        started with this run ID.

        This can be set when using :py:meth:`Client.get_workflow_handle`. When
        :py:meth:`Client.start_workflow` is called without a start signal, this
        is set to the resulting run.

        This cannot be mutated. If a different first execution run ID is needed,
        :py:meth:`Client.get_workflow_handle` must be used instead.
        """
        ...
    async def result(
        self, *, follow_runs: bool = ..., rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> ReturnType:
        """Wait for result of the workflow.

        This will use :py:attr:`result_run_id` if present to base the result on.
        To use another run ID, a new handle must be created via
        :py:meth:`Client.get_workflow_handle`.

        Args:
            follow_runs: If true (default), workflow runs will be continually
                fetched, until the most recent one is found. If false, the first
                result is used.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call. Note,
                this is the timeout for each history RPC call not this overall
                function.

        Returns:
            Result of the workflow after being converted by the data converter.

        Raises:
            WorkflowFailureError: Workflow failed, was cancelled, was
                terminated, or timed out. Use the
                :py:attr:`WorkflowFailureError.cause` to see the underlying
                reason.
            Exception: Other possible failures during result fetching.
        """
        ...
    async def cancel(self, *, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...) -> None:
        """Cancel the workflow.

        This will issue a cancellation for :py:attr:`run_id` if present. This
        call will make sure to use the run chain starting from
        :py:attr:`first_execution_run_id` if present. To create handles with
        these values, use :py:meth:`Client.get_workflow_handle`.

        .. warning::
            Handles created as a result of :py:meth:`Client.start_workflow` with
            a start signal will cancel the latest workflow with the same
            workflow ID even if it is unrelated to the started workflow.

        Args:
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Raises:
            RPCError: Workflow could not be cancelled.
        """
        ...
    async def describe(
        self, *, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> WorkflowExecutionDescription:
        """Get workflow details.

        This will get details for :py:attr:`run_id` if present. To use a
        different run ID, create a new handle with via
        :py:meth:`Client.get_workflow_handle`.

        .. warning::
            Handles created as a result of :py:meth:`Client.start_workflow` will
            describe the latest workflow with the same workflow ID even if it is
            unrelated to the started workflow.

        Args:
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Returns:
            Workflow details.

        Raises:
            RPCError: Workflow details could not be fetched.
        """
        ...
    async def fetch_history(
        self,
        *,
        event_filter_type: WorkflowHistoryEventFilterType = ...,
        skip_archival: bool = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowHistory:
        """Get workflow history.

        This is a shortcut for :py:meth:`fetch_history_events` that just fetches
        all events.
        """
        ...
    def fetch_history_events(
        self,
        *,
        page_size: Optional[int] = ...,
        next_page_token: Optional[bytes] = ...,
        wait_new_event: bool = ...,
        event_filter_type: WorkflowHistoryEventFilterType = ...,
        skip_archival: bool = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowHistoryEventAsyncIterator:
        """Get workflow history events as an async iterator.

        This does not make a request until the first iteration is attempted.
        Therefore any errors will not occur until then.

        Args:
            page_size: Maximum amount to fetch per request if any maximum.
            next_page_token: A specific page token to fetch.
            wait_new_event: Whether the event fetching request will wait for new
                events or just return right away.
            event_filter_type: Which events to obtain.
            skip_archival: Whether to skip archival.
            rpc_metadata: Headers used on each RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call.

        Returns:
            An async iterator that doesn't begin fetching until iterated on.
        """
        ...
    @overload
    async def query(
        self,
        query: MethodSyncOrAsyncNoParam[SelfType, LocalReturnType],
        *,
        reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> LocalReturnType: ...
    @overload
    async def query(
        self,
        query: MethodSyncOrAsyncSingleParam[SelfType, ParamType, LocalReturnType],
        arg: ParamType,
        *,
        reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> LocalReturnType: ...
    @overload
    async def query(
        self,
        query: Callable[
            Concatenate[SelfType, MultiParamSpec],
            Union[Awaitable[LocalReturnType], LocalReturnType],
        ],
        *,
        args: Sequence[Any],
        reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> LocalReturnType: ...
    @overload
    async def query(
        self,
        query: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        result_type: Optional[Type] = ...,
        reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> Any: ...
    async def query(
        self,
        query: Union[str, Callable],
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        result_type: Optional[Type] = ...,
        reject_condition: Optional[temporalio.common.QueryRejectCondition] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> Any:
        """Query the workflow.

        This will query for :py:attr:`run_id` if present. To use a different
        run ID, create a new handle with via
        :py:meth:`Client.get_workflow_handle`.

        .. warning::
            Handles created as a result of :py:meth:`Client.start_workflow` will
            query the latest workflow with the same workflow ID even if it is
            unrelated to the started workflow.

        Args:
            query: Query function or name on the workflow.
            arg: Single argument to the query.
            args: Multiple arguments to the query. Cannot be set if arg is.
            result_type: For string queries, this can set the specific result
                type hint to deserialize into.
            reject_condition: Condition for rejecting the query. If unset/None,
                defaults to the client's default (which is defaulted to None).
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Returns:
            Result of the query.

        Raises:
            WorkflowQueryRejectedError: A query reject condition was satisfied.
            RPCError: Workflow details could not be fetched.
        """
        ...
    @overload
    async def signal(
        self,
        signal: MethodSyncOrAsyncNoParam[SelfType, None],
        *,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None: ...
    @overload
    async def signal(
        self,
        signal: MethodSyncOrAsyncSingleParam[SelfType, ParamType, None],
        arg: ParamType,
        *,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None: ...
    @overload
    async def signal(
        self,
        signal: Callable[Concatenate[SelfType, MultiParamSpec], Union[Awaitable[None], None]],
        *,
        args: Sequence[Any],
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None: ...
    @overload
    async def signal(
        self,
        signal: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None: ...
    async def signal(
        self,
        signal: Union[str, Callable],
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Send a signal to the workflow.

        This will signal for :py:attr:`run_id` if present. To use a different
        run ID, create a new handle with via
        :py:meth:`Client.get_workflow_handle`.

        .. warning::
            Handles created as a result of :py:meth:`Client.start_workflow` will
            signal the latest workflow with the same workflow ID even if it is
            unrelated to the started workflow.

        Args:
            signal: Signal function or name on the workflow.
            arg: Single argument to the signal.
            args: Multiple arguments to the signal. Cannot be set if arg is.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Raises:
            RPCError: Workflow could not be signalled.
        """
        ...
    async def terminate(
        self,
        *args: Any,
        reason: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Terminate the workflow.

        This will issue a termination for :py:attr:`run_id` if present. This
        call will make sure to use the run chain starting from
        :py:attr:`first_execution_run_id` if present. To create handles with
        these values, use :py:meth:`Client.get_workflow_handle`.

        .. warning::
            Handles created as a result of :py:meth:`Client.start_workflow` with
            a start signal will terminate the latest workflow with the same
            workflow ID even if it is unrelated to the started workflow.

        Args:
            args: Details to store on the termination.
            reason: Reason for the termination.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Raises:
            RPCError: Workflow could not be terminated.
        """
        ...
    @overload
    async def execute_update(
        self,
        update: temporalio.workflow.UpdateMethodMultiParam[[SelfType], LocalReturnType],
        *,
        id: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> LocalReturnType: ...
    @overload
    async def execute_update(
        self,
        update: temporalio.workflow.UpdateMethodMultiParam[[SelfType, ParamType], LocalReturnType],
        arg: ParamType,
        *,
        id: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> LocalReturnType: ...
    @overload
    async def execute_update(
        self,
        update: temporalio.workflow.UpdateMethodMultiParam[MultiParamSpec, LocalReturnType],
        *,
        args: MultiParamSpec.args,
        id: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> LocalReturnType: ...
    @overload
    async def execute_update(
        self,
        update: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> Any: ...
    async def execute_update(
        self,
        update: Union[str, Callable],
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> Any:
        """Send an update request to the workflow and wait for it to complete.

        This will target the workflow with :py:attr:`run_id` if present. To use a
        different run ID, create a new handle with via :py:meth:`Client.get_workflow_handle`.

        .. warning::
           This API is experimental

        .. warning::
            WorkflowHandles created as a result of :py:meth:`Client.start_workflow` will
            send updates to the latest workflow with the same workflow ID even if it is
            unrelated to the started workflow.

        Args:
            update: Update function or name on the workflow.
            arg: Single argument to the update.
            args: Multiple arguments to the update. Cannot be set if arg is.
            id: ID of the update. If not set, the server will set a UUID as the ID.
            result_type: For string updates, this can set the specific result
                type hint to deserialize into.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Raises:
            WorkflowUpdateFailedError: If the update failed
            RPCError: There was some issue sending the update to the workflow.
        """
        ...
    @overload
    async def start_update(
        self,
        update: temporalio.workflow.UpdateMethodMultiParam[[SelfType], LocalReturnType],
        *,
        id: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowUpdateHandle[LocalReturnType]: ...
    @overload
    async def start_update(
        self,
        update: temporalio.workflow.UpdateMethodMultiParam[[SelfType, ParamType], LocalReturnType],
        arg: ParamType,
        *,
        id: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowUpdateHandle[LocalReturnType]: ...
    @overload
    async def start_update(
        self,
        update: temporalio.workflow.UpdateMethodMultiParam[MultiParamSpec, LocalReturnType],
        *,
        args: MultiParamSpec.args,
        id: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowUpdateHandle[LocalReturnType]: ...
    @overload
    async def start_update(
        self,
        update: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowUpdateHandle[Any]: ...
    async def start_update(
        self,
        update: Union[str, Callable],
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> WorkflowUpdateHandle[Any]:
        """Send an update request to the workflow and return a handle to it.

        This will target the workflow with :py:attr:`run_id` if present. To use a
        different run ID, create a new handle with via :py:meth:`Client.get_workflow_handle`.

        .. warning::
           This API is experimental

        .. warning::
            WorkflowHandles created as a result of :py:meth:`Client.start_workflow` will
            send updates to the latest workflow with the same workflow ID even if it is
            unrelated to the started workflow.

        Args:
            update: Update function or name on the workflow.
            arg: Single argument to the update.
            args: Multiple arguments to the update. Cannot be set if arg is.
            id: ID of the update. If not set, the server will set a UUID as the ID.
            result_type: For string updates, this can set the specific result
                type hint to deserialize into.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.

        Raises:
            RPCError: There was some issue sending the update to the workflow.
        """
        ...

@dataclass(frozen=True)
class AsyncActivityIDReference:
    """Reference to an async activity by its qualified ID."""

    workflow_id: str
    run_id: Optional[str]
    activity_id: str
    ...

class AsyncActivityHandle:
    """Handle representing an external activity for completion and heartbeat."""

    def __init__(self, client: Client, id_or_token: Union[AsyncActivityIDReference, bytes]) -> None:
        """Create an async activity handle."""
        ...
    async def heartbeat(
        self, *details: Any, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> None:
        """Record a heartbeat for the activity.

        Args:
            details: Details of the heartbeat.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def complete(
        self,
        result: Optional[Any] = ...,
        *,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Complete the activity.

        Args:
            result: Result of the activity if any.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def fail(
        self,
        error: Exception,
        *,
        last_heartbeat_details: Sequence[Any] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Fail the activity.

        Args:
            error: Error for the activity.
            last_heartbeat_details: Last heartbeat details for the activity.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def report_cancellation(
        self, *details: Any, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> None:
        """Report the activity as cancelled.

        Args:
            details: Cancellation details.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...

@dataclass
class WorkflowExecution:
    """Info for a single workflow execution run."""

    close_time: Optional[datetime]
    data_converter: temporalio.converter.DataConverter
    execution_time: Optional[datetime]
    history_length: int
    id: str
    parent_id: Optional[str]
    parent_run_id: Optional[str]
    raw_info: temporalio.api.workflow.v1.WorkflowExecutionInfo
    run_id: str
    search_attributes: temporalio.common.SearchAttributes
    start_time: datetime
    status: Optional[WorkflowExecutionStatus]
    task_queue: str
    typed_search_attributes: temporalio.common.TypedSearchAttributes
    workflow_type: str
    async def memo(self) -> Mapping[str, Any]:
        """Workflow's memo values, converted without type hints.

        Since type hints are not used, the default converted values will come
        back. For example, if the memo was originally created with a dataclass,
        the value will be a dict. To convert using proper type hints, use
        :py:meth:`memo_value`.

        Returns:
            Mapping of all memo keys and they values without type hints.
        """
        ...
    @overload
    async def memo_value(self, key: str, default: Any = ...) -> Any: ...
    @overload
    async def memo_value(self, key: str, *, type_hint: Type[ParamType]) -> ParamType: ...
    @overload
    async def memo_value(
        self, key: str, default: AnyType, *, type_hint: Type[ParamType]
    ) -> Union[AnyType, ParamType]: ...
    async def memo_value(self, key: str, default: Any = ..., *, type_hint: Optional[Type] = ...) -> Any:
        """Memo value for the given key, optional default, and optional type
        hint.

        Args:
            key: Key to get memo value for.
            default: Default to use if key is not present. If unset, a
                :py:class:`KeyError` is raised when the key does not exist.
            type_hint: Type hint to use when converting.

        Returns:
            Memo value, converted with the type hint if present.

        Raises:
            KeyError: Key not present and default not set.
        """
        ...

@dataclass
class WorkflowExecutionDescription(WorkflowExecution):
    """Description for a single workflow execution run."""

    raw_description: temporalio.api.workflowservice.v1.DescribeWorkflowExecutionResponse
    ...

class WorkflowExecutionStatus(IntEnum):
    """Status of a workflow execution.

    See :py:class:`temporalio.api.enums.v1.WorkflowExecutionStatus`.
    """

    RUNNING = ...
    COMPLETED = ...
    FAILED = ...
    CANCELED = ...
    TERMINATED = ...
    CONTINUED_AS_NEW = ...
    TIMED_OUT = ...

class WorkflowExecutionAsyncIterator:
    """Asynchronous iterator for :py:class:`WorkflowExecution` values.

    Most users should use ``async for`` on this iterator and not call any of the
    methods within. To consume the workflows as histories, call
    :py:meth:`map_histories`.
    """

    def __init__(self, client: Client, input: ListWorkflowsInput) -> None:
        """Create an asynchronous iterator for the given input.

        Users should not create this directly, but rather use
        :py:meth:`Client.list_workflows`.
        """
        ...
    @property
    def current_page_index(self) -> int:
        """Index of the entry in the current page that will be returned from
        the next :py:meth:`__anext__` call.
        """
        ...
    @property
    def current_page(self) -> Optional[Sequence[WorkflowExecution]]:
        """Current page, if it has been fetched yet."""
        ...
    @property
    def next_page_token(self) -> Optional[bytes]:
        """Token for the next page request if any."""
        ...
    async def fetch_next_page(self, *, page_size: Optional[int] = ...) -> None:
        """Fetch the next page if any.

        Args:
            page_size: Override the page size this iterator was originally
                created with.
        """
        ...
    def __aiter__(self) -> WorkflowExecutionAsyncIterator:
        """Return self as the iterator."""
        ...
    async def __anext__(self) -> WorkflowExecution:
        """Get the next execution on this iterator, fetching next page if
        necessary.
        """
        ...
    async def map_histories(
        self,
        *,
        event_filter_type: WorkflowHistoryEventFilterType = ...,
        skip_archival: bool = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> AsyncIterator[WorkflowHistory]:
        """Create an async iterator consuming all workflows and calling
        :py:meth:`WorkflowHandle.fetch_history` on each one.

        This is just a shortcut for ``fetch_history``, see that method for
        parameter details.
        """
        ...

@dataclass(frozen=True)
class WorkflowHistory:
    """A workflow's ID and immutable history."""

    workflow_id: str
    events: Sequence[temporalio.api.history.v1.HistoryEvent]
    @property
    def run_id(self) -> str:
        """Run ID extracted from the first event."""
        ...
    @staticmethod
    def from_json(workflow_id: str, history: Union[str, Dict[str, Any]]) -> WorkflowHistory:
        """Construct a WorkflowHistory from an ID and a json dump of history.

        This is built to work both with Temporal UI/tctl JSON as well as
        :py:meth:`to_json` even though they are slightly different.

        Args:
            workflow_id: The workflow's ID
            history: A string or parsed-to-dict representation of workflow
                history

        Returns:
            Workflow history
        """
        ...
    def to_json(self) -> str:
        """Convert this history to JSON.

        Note, this does not include the workflow ID.
        """
        ...
    def to_json_dict(self) -> Dict[str, Any]:
        """Convert this history to JSON-compatible dict.

        Note, this does not include the workflow ID.
        """
        ...

@dataclass
class WorkflowHistoryEventAsyncIterator:
    """Asynchronous iterator for history events of a workflow.

    Most users should use ``async for`` on this iterator and not call any of the
    methods within.
    """

    def __init__(self, client: Client, input: FetchWorkflowHistoryEventsInput) -> None:
        """Create an asynchronous iterator for the given input.

        Users should not create this directly, but rather use
        :py:meth:`WorkflowHandle.fetch_history_events`.
        """
        ...
    @property
    def current_page_index(self) -> int:
        """Index of the entry in the current page that will be returned from
        the next :py:meth:`__anext__` call.
        """
        ...
    @property
    def current_page(self) -> Optional[Sequence[temporalio.api.history.v1.HistoryEvent]]:
        """Current page, if it has been fetched yet."""
        ...
    @property
    def next_page_token(self) -> Optional[bytes]:
        """Token for the next page request if any."""
        ...
    async def fetch_next_page(self, *, page_size: Optional[int] = ...) -> None:
        """Fetch the next page if any.

        Args:
            page_size: Override the page size this iterator was originally
                created with.
        """
        ...
    def __aiter__(self) -> WorkflowHistoryEventAsyncIterator:
        """Return self as the iterator."""
        ...
    async def __anext__(self) -> temporalio.api.history.v1.HistoryEvent:
        """Get the next execution on this iterator, fetching next page if
        necessary.
        """
        ...

class ScheduleHandle:
    """Handle for interacting with a schedule.

    This is usually created via :py:meth:`Client.get_schedule_handle` or
    returned from :py:meth:`Client.create_schedule`.

    Attributes:
        id: ID of the schedule.
    """

    def __init__(self, client: Client, id: str) -> None:
        """Create schedule handle."""
        ...
    async def backfill(
        self, *backfill: ScheduleBackfill, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> None:
        """Backfill the schedule by going through the specified time periods as
        if they passed right now.

        Args:
            backfill: Backfill periods.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def delete(self, *, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...) -> None:
        """Delete this schedule.

        Args:
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def describe(
        self, *, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> ScheduleDescription:
        """Fetch this schedule's description.

        Args:
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def pause(
        self,
        *,
        note: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Pause the schedule and set a note.

        Args:
            note: Note to set on the schedule.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def trigger(
        self,
        *,
        overlap: Optional[ScheduleOverlapPolicy] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Trigger an action on this schedule to happen immediately.

        Args:
            overlap: If set, overrides the schedule's overlap policy.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    async def unpause(
        self,
        *,
        note: Optional[str] = ...,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Unpause the schedule and set a note.

        Args:
            note: Note to set on the schedule.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for the RPC call.
        """
        ...
    @overload
    async def update(
        self,
        updater: Callable[[ScheduleUpdateInput], Optional[ScheduleUpdate]],
        *,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None: ...
    @overload
    async def update(
        self,
        updater: Callable[[ScheduleUpdateInput], Awaitable[Optional[ScheduleUpdate]]],
        *,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None: ...
    async def update(
        self,
        updater: Callable[
            [ScheduleUpdateInput],
            Union[Optional[ScheduleUpdate], Awaitable[Optional[ScheduleUpdate]]],
        ],
        *,
        rpc_metadata: Mapping[str, str] = ...,
        rpc_timeout: Optional[timedelta] = ...,
    ) -> None:
        """Update a schedule using a callback to build the update from the
        description.

        The callback may be invoked multiple times in a conflict-resolution
        loop.

        Args:
            updater: Callback that returns the update. It accepts a
                :py:class:`ScheduleUpdateInput` and returns a
                :py:class:`ScheduleUpdate`. If None is returned or an error
                occurs, the update is not attempted. This may be called multiple
                times.
            rpc_metadata: Headers used on the RPC call. Keys here override
                client-level RPC metadata keys. This is for every call made
                within.
            rpc_timeout: Optional RPC deadline to set for the RPC call. This is
                for each call made within, not overall.
        """
        ...

@dataclass
class ScheduleSpec:
    """Specification of the times scheduled actions may occur.

    The times are the union of :py:attr:`calendars`, :py:attr:`intervals`, and
    :py:attr:`cron_expressions` excluding anything in :py:attr:`skip`.
    """

    calendars: Sequence[ScheduleCalendarSpec] = ...
    intervals: Sequence[ScheduleIntervalSpec] = ...
    cron_expressions: Sequence[str] = ...
    skip: Sequence[ScheduleCalendarSpec] = ...
    start_at: Optional[datetime] = ...
    end_at: Optional[datetime] = ...
    jitter: Optional[timedelta] = ...
    time_zone_name: Optional[str] = ...

@dataclass(frozen=True)
class ScheduleRange:
    """Inclusive range for a schedule match value."""

    start: int
    end: int = ...
    step: int = ...
    def __post_init__(self):  # -> None:
        """Set field defaults."""
        ...

@dataclass
class ScheduleCalendarSpec:
    """Specification relative to calendar time when to run an action.

    A timestamp matches if at least one range of each field matches except for
    year. If year is missing, that means all years match. For all fields besides
    year, at least one range must be present to match anything.
    """

    second: Sequence[ScheduleRange] = ...
    minute: Sequence[ScheduleRange] = ...
    hour: Sequence[ScheduleRange] = ...
    day_of_month: Sequence[ScheduleRange] = ...
    month: Sequence[ScheduleRange] = ...
    year: Sequence[ScheduleRange] = ...
    day_of_week: Sequence[ScheduleRange] = ...
    comment: Optional[str] = ...

@dataclass
class ScheduleIntervalSpec:
    """Specification for scheduling on an interval.

    Matches times expressed as epoch + (n * every) + offset.
    """

    every: timedelta
    offset: Optional[timedelta] = ...

class ScheduleAction(ABC):
    """Base class for an action a schedule can take.

    See :py:class:`ScheduleActionStartWorkflow` for the most commonly used
    implementation.
    """

    ...

@dataclass
class ScheduleActionStartWorkflow(ScheduleAction):
    """Schedule action to start a workflow."""

    workflow: str | Callable[..., Any]
    args: Union[Sequence[Any], Sequence[temporalio.api.common.v1.Payload]]
    id: str
    task_queue: str
    execution_timeout: Optional[timedelta]
    run_timeout: Optional[timedelta]
    task_timeout: Optional[timedelta]
    retry_policy: Optional[temporalio.common.RetryPolicy]
    memo: Optional[Union[Mapping[str, Any], Mapping[str, temporalio.api.common.v1.Payload]]]
    typed_search_attributes: temporalio.common.TypedSearchAttributes
    untyped_search_attributes: temporalio.common.SearchAttributes
    headers: Optional[Mapping[str, temporalio.api.common.v1.Payload]]
    @overload
    def __init__(
        self,
        workflow: Callable[[Any], Awaitable[ReturnType]],
        *,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        typed_search_attributes: temporalio.common.TypedSearchAttributes = ...,
    ) -> None: ...
    @overload
    def __init__(
        self,
        workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
        arg: ParamType,
        *,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        typed_search_attributes: temporalio.common.TypedSearchAttributes = ...,
    ) -> None: ...

    Ts = TypeVarTuple("Ts")
    @overload
    def __init__(
        self,
        workflow: Callable[[SelfType, Unpack[Ts]], Awaitable[ReturnType]],
        *,
        args: tuple[Unpack[Ts]],
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        typed_search_attributes: temporalio.common.TypedSearchAttributes = ...,
    ) -> None: ...
    @overload
    def __init__(
        self,
        workflow: str,
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: str,
        task_queue: str,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        typed_search_attributes: temporalio.common.TypedSearchAttributes = ...,
    ) -> None: ...
    @overload
    def __init__(self, workflow: str, *, raw_info: temporalio.api.workflow.v1.NewWorkflowExecutionInfo) -> None: ...
    def __init__(
        self,
        workflow: Union[str, Callable[..., Awaitable[Any]]],
        arg: Any = ...,
        *,
        args: Sequence[Any] = ...,
        id: Optional[str] = ...,
        task_queue: Optional[str] = ...,
        execution_timeout: Optional[timedelta] = ...,
        run_timeout: Optional[timedelta] = ...,
        task_timeout: Optional[timedelta] = ...,
        retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
        memo: Optional[Mapping[str, Any]] = ...,
        typed_search_attributes: temporalio.common.TypedSearchAttributes = ...,
        untyped_search_attributes: temporalio.common.SearchAttributes = ...,
        headers: Optional[Mapping[str, temporalio.api.common.v1.Payload]] = ...,
        raw_info: Optional[temporalio.api.workflow.v1.NewWorkflowExecutionInfo] = ...,
    ) -> None:
        """Create a start-workflow action.

        See :py:meth:`Client.start_workflow` for details on these parameter
        values.
        """
        ...

@dataclass
class ScheduleOverlapPolicy(IntEnum):
    """Controls what happens when a workflow would be started by a schedule but
    one is already running.
    """

    SKIP = ...
    BUFFER_ONE = ...
    BUFFER_ALL = ...
    CANCEL_OTHER = ...
    TERMINATE_OTHER = ...
    ALLOW_ALL = ...

@dataclass
class ScheduleBackfill:
    """Time period and policy for actions taken as if the time passed right
    now.
    """

    start_at: datetime
    end_at: datetime
    overlap: Optional[ScheduleOverlapPolicy] = ...

@dataclass
class SchedulePolicy:
    """Policies of a schedule."""

    overlap: ScheduleOverlapPolicy = ...
    catchup_window: timedelta = ...
    pause_on_failure: bool = ...

@dataclass
class ScheduleState:
    """State of a schedule."""

    note: Optional[str] = ...
    paused: bool = ...
    limited_actions: bool = ...
    remaining_actions: int = ...

@dataclass
class Schedule:
    """A schedule for periodically running an action."""

    action: ScheduleAction
    spec: ScheduleSpec
    policy: SchedulePolicy = ...
    state: ScheduleState = ...

@dataclass
class ScheduleDescription:
    """Description of a schedule."""

    id: str
    schedule: Schedule
    info: ScheduleInfo
    typed_search_attributes: temporalio.common.TypedSearchAttributes
    search_attributes: temporalio.common.SearchAttributes
    data_converter: temporalio.converter.DataConverter
    raw_description: temporalio.api.workflowservice.v1.DescribeScheduleResponse
    async def memo(self) -> Mapping[str, Any]:
        """Schedule's memo values, converted without type hints.

        Since type hints are not used, the default converted values will come
        back. For example, if the memo was originally created with a dataclass,
        the value will be a dict. To convert using proper type hints, use
        :py:meth:`memo_value`.

        Returns:
            Mapping of all memo keys and they values without type hints.
        """
        ...
    @overload
    async def memo_value(self, key: str, default: Any = ...) -> Any: ...
    @overload
    async def memo_value(self, key: str, *, type_hint: Type[ParamType]) -> ParamType: ...
    @overload
    async def memo_value(
        self, key: str, default: AnyType, *, type_hint: Type[ParamType]
    ) -> Union[AnyType, ParamType]: ...
    async def memo_value(self, key: str, default: Any = ..., *, type_hint: Optional[Type] = ...) -> Any:
        """Memo value for the given key, optional default, and optional type
        hint.

        Args:
            key: Key to get memo value for.
            default: Default to use if key is not present. If unset, a
                :py:class:`KeyError` is raised when the key does not exist.
            type_hint: Type hint to use when converting.

        Returns:
            Memo value, converted with the type hint if present.

        Raises:
            KeyError: Key not present and default not set.
        """
        ...

@dataclass
class ScheduleInfo:
    """Information about a schedule."""

    num_actions: int
    num_actions_missed_catchup_window: int
    num_actions_skipped_overlap: int
    running_actions: Sequence[ScheduleActionExecution]
    recent_actions: Sequence[ScheduleActionResult]
    next_action_times: Sequence[datetime]
    created_at: datetime
    last_updated_at: Optional[datetime]
    ...

class ScheduleActionExecution(ABC):
    """Base class for an action execution."""

    ...

@dataclass
class ScheduleActionExecutionStartWorkflow(ScheduleActionExecution):
    """Execution of a scheduled workflow start."""

    workflow_id: str
    first_execution_run_id: str
    ...

@dataclass
class ScheduleActionResult:
    """Information about when an action took place."""

    scheduled_at: datetime
    started_at: datetime
    action: ScheduleActionExecution
    ...

@dataclass
class ScheduleUpdateInput:
    """Parameter for an update callback for :py:meth:`ScheduleHandle.update`."""

    description: ScheduleDescription
    ...

@dataclass
class ScheduleUpdate:
    """Result of an update callback for :py:meth:`ScheduleHandle.update`."""

    schedule: Schedule
    ...

@dataclass
class ScheduleListDescription:
    """Description of a listed schedule."""

    id: str
    schedule: Optional[ScheduleListSchedule]
    info: Optional[ScheduleListInfo]
    typed_search_attributes: temporalio.common.TypedSearchAttributes
    search_attributes: temporalio.common.SearchAttributes
    data_converter: temporalio.converter.DataConverter
    raw_entry: temporalio.api.schedule.v1.ScheduleListEntry
    async def memo(self) -> Mapping[str, Any]:
        """Schedule's memo values, converted without type hints.

        Since type hints are not used, the default converted values will come
        back. For example, if the memo was originally created with a dataclass,
        the value will be a dict. To convert using proper type hints, use
        :py:meth:`memo_value`.

        Returns:
            Mapping of all memo keys and they values without type hints.
        """
        ...
    @overload
    async def memo_value(self, key: str, default: Any = ...) -> Any: ...
    @overload
    async def memo_value(self, key: str, *, type_hint: Type[ParamType]) -> ParamType: ...
    @overload
    async def memo_value(
        self, key: str, default: AnyType, *, type_hint: Type[ParamType]
    ) -> Union[AnyType, ParamType]: ...
    async def memo_value(self, key: str, default: Any = ..., *, type_hint: Optional[Type] = ...) -> Any:
        """Memo value for the given key, optional default, and optional type
        hint.

        Args:
            key: Key to get memo value for.
            default: Default to use if key is not present. If unset, a
                :py:class:`KeyError` is raised when the key does not exist.
            type_hint: Type hint to use when converting.

        Returns:
            Memo value, converted with the type hint if present.

        Raises:
            KeyError: Key not present and default not set.
        """
        ...

@dataclass
class ScheduleListSchedule:
    """Details for a listed schedule."""

    action: ScheduleListAction
    spec: ScheduleSpec
    state: ScheduleListState
    ...

class ScheduleListAction(ABC):
    """Base class for an action a listed schedule can take."""

    ...

@dataclass
class ScheduleListActionStartWorkflow(ScheduleListAction):
    """Action to start a workflow on a listed schedule."""

    workflow: str
    ...

@dataclass
class ScheduleListInfo:
    """Information about a listed schedule."""

    recent_actions: Sequence[ScheduleActionResult]
    next_action_times: Sequence[datetime]
    ...

@dataclass
class ScheduleListState:
    """State of a listed schedule."""

    note: Optional[str]
    paused: bool
    ...

class ScheduleAsyncIterator:
    """Asynchronous iterator for :py:class:`ScheduleListDescription` values.

    Most users should use ``async for`` on this iterator and not call any of the
    methods within.
    """

    def __init__(self, client: Client, input: ListSchedulesInput) -> None:
        """Create an asynchronous iterator for the given input.

        Users should not create this directly, but rather use
        :py:meth:`Client.list_schedules`.
        """
        ...
    @property
    def current_page_index(self) -> int:
        """Index of the entry in the current page that will be returned from
        the next :py:meth:`__anext__` call.
        """
        ...
    @property
    def current_page(self) -> Optional[Sequence[ScheduleListDescription]]:
        """Current page, if it has been fetched yet."""
        ...
    @property
    def next_page_token(self) -> Optional[bytes]:
        """Token for the next page request if any."""
        ...
    async def fetch_next_page(self, *, page_size: Optional[int] = ...) -> None:
        """Fetch the next page if any.

        Args:
            page_size: Override the page size this iterator was originally
                created with.
        """
        ...
    def __aiter__(self) -> ScheduleAsyncIterator:
        """Return self as the iterator."""
        ...
    async def __anext__(self) -> ScheduleListDescription:
        """Get the next execution on this iterator, fetching next page if
        necessary.
        """
        ...

class WorkflowUpdateHandle(Generic[LocalReturnType]):
    """Handle for a workflow update execution request."""

    def __init__(
        self,
        client: Client,
        id: str,
        workflow_id: str,
        *,
        workflow_run_id: Optional[str] = ...,
        result_type: Optional[Type] = ...,
    ) -> None:
        """Create a workflow update handle.

        Users should not create this directly, but rather use
        :py:meth:`Client.start_workflow_update`.
        """
        ...
    @property
    def id(self) -> str:
        """ID of this Update request."""
        ...
    @property
    def workflow_id(self) -> str:
        """The ID of the Workflow targeted by this Update."""
        ...
    @property
    def workflow_run_id(self) -> Optional[str]:
        """If specified, the specific run of the Workflow targeted by this Update."""
        ...
    async def result(
        self, *, rpc_metadata: Mapping[str, str] = ..., rpc_timeout: Optional[timedelta] = ...
    ) -> LocalReturnType:
        """Wait for and return the result of the update. The result may already be known in which case no network call
        is made. Otherwise the result will be polled for until it is returned.

        Args:
            rpc_metadata: Headers used on the RPC call. Keys here override client-level RPC metadata keys.
            rpc_timeout: Optional RPC deadline to set for each RPC call. Note: this is the timeout for each
                RPC call while polling, not a timeout for the function as a whole. If an individual RPC times out,
                it will be retried until the result is available.

        Raises:
            WorkflowUpdateFailedError: If the update failed
            RPCError: Update result could not be fetched for some other reason.
        """
        ...

class WorkflowFailureError(temporalio.exceptions.TemporalError):
    """Error that occurs when a workflow is unsuccessful."""

    def __init__(self, *, cause: BaseException) -> None:
        """Create workflow failure error."""
        ...
    @property
    def cause(self) -> BaseException:
        """Cause of the workflow failure."""
        ...

class WorkflowContinuedAsNewError(temporalio.exceptions.TemporalError):
    """Error that occurs when a workflow was continued as new."""

    def __init__(self, new_execution_run_id: str) -> None:
        """Create workflow continue as new error."""
        ...
    @property
    def new_execution_run_id(self) -> str:
        """New execution run ID the workflow continued to"""
        ...

class WorkflowQueryRejectedError(temporalio.exceptions.TemporalError):
    """Error that occurs when a query was rejected."""

    def __init__(self, status: Optional[WorkflowExecutionStatus]) -> None:
        """Create workflow query rejected error."""
        ...
    @property
    def status(self) -> Optional[WorkflowExecutionStatus]:
        """Get workflow execution status causing rejection."""
        ...

class WorkflowQueryFailedError(temporalio.exceptions.TemporalError):
    """Error that occurs when a query fails."""

    def __init__(self, message: str) -> None:
        """Create workflow query failed error."""
        ...
    @property
    def message(self) -> str:
        """Get query failed message."""
        ...

class WorkflowUpdateFailedError(temporalio.exceptions.TemporalError):
    """Error that occurs when an update fails."""

    def __init__(self, cause: BaseException) -> None:
        """Create workflow update failed error."""
        ...
    @property
    def cause(self) -> BaseException:
        """Cause of the update failure."""
        ...

class AsyncActivityCancelledError(temporalio.exceptions.TemporalError):
    """Error that occurs when async activity attempted heartbeat but was cancelled."""

    def __init__(self) -> None:
        """Create async activity cancelled error."""
        ...

class ScheduleAlreadyRunningError(temporalio.exceptions.TemporalError):
    """Error when a schedule is already running."""

    def __init__(self) -> None:
        """Create schedule already running error."""
        ...

@dataclass
class StartWorkflowInput:
    """Input for :py:meth:`OutboundInterceptor.start_workflow`."""

    workflow: str
    args: Sequence[Any]
    id: str
    task_queue: str
    execution_timeout: Optional[timedelta]
    run_timeout: Optional[timedelta]
    task_timeout: Optional[timedelta]
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy
    retry_policy: Optional[temporalio.common.RetryPolicy]
    cron_schedule: str
    memo: Optional[Mapping[str, Any]]
    search_attributes: Optional[Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]]
    start_delay: Optional[timedelta]
    headers: Mapping[str, temporalio.api.common.v1.Payload]
    start_signal: Optional[str]
    start_signal_args: Sequence[Any]
    ret_type: Optional[Type]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class CancelWorkflowInput:
    """Input for :py:meth:`OutboundInterceptor.cancel_workflow`."""

    id: str
    run_id: Optional[str]
    first_execution_run_id: Optional[str]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class DescribeWorkflowInput:
    """Input for :py:meth:`OutboundInterceptor.describe_workflow`."""

    id: str
    run_id: Optional[str]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class FetchWorkflowHistoryEventsInput:
    """Input for :py:meth:`OutboundInterceptor.fetch_workflow_history_events`."""

    id: str
    run_id: Optional[str]
    page_size: Optional[int]
    next_page_token: Optional[bytes]
    wait_new_event: bool
    event_filter_type: WorkflowHistoryEventFilterType
    skip_archival: bool
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class ListWorkflowsInput:
    """Input for :py:meth:`OutboundInterceptor.list_workflows`."""

    query: Optional[str]
    page_size: int
    next_page_token: Optional[bytes]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class QueryWorkflowInput:
    """Input for :py:meth:`OutboundInterceptor.query_workflow`."""

    id: str
    run_id: Optional[str]
    query: str
    args: Sequence[Any]
    reject_condition: Optional[temporalio.common.QueryRejectCondition]
    headers: Mapping[str, temporalio.api.common.v1.Payload]
    ret_type: Optional[Type]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class SignalWorkflowInput:
    """Input for :py:meth:`OutboundInterceptor.signal_workflow`."""

    id: str
    run_id: Optional[str]
    signal: str
    args: Sequence[Any]
    headers: Mapping[str, temporalio.api.common.v1.Payload]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class TerminateWorkflowInput:
    """Input for :py:meth:`OutboundInterceptor.terminate_workflow`."""

    id: str
    run_id: Optional[str]
    first_execution_run_id: Optional[str]
    args: Sequence[Any]
    reason: Optional[str]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class StartWorkflowUpdateInput:
    """Input for :py:meth:`OutboundInterceptor.start_workflow_update`."""

    id: str
    run_id: Optional[str]
    update_id: Optional[str]
    update: str
    args: Sequence[Any]
    wait_for_stage: Optional[temporalio.api.enums.v1.UpdateWorkflowExecutionLifecycleStage.ValueType]
    headers: Mapping[str, temporalio.api.common.v1.Payload]
    ret_type: Optional[Type]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class HeartbeatAsyncActivityInput:
    """Input for :py:meth:`OutboundInterceptor.heartbeat_async_activity`."""

    id_or_token: Union[AsyncActivityIDReference, bytes]
    details: Sequence[Any]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class CompleteAsyncActivityInput:
    """Input for :py:meth:`OutboundInterceptor.complete_async_activity`."""

    id_or_token: Union[AsyncActivityIDReference, bytes]
    result: Optional[Any]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class FailAsyncActivityInput:
    """Input for :py:meth:`OutboundInterceptor.fail_async_activity`."""

    id_or_token: Union[AsyncActivityIDReference, bytes]
    error: Exception
    last_heartbeat_details: Sequence[Any]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class ReportCancellationAsyncActivityInput:
    """Input for :py:meth:`OutboundInterceptor.report_cancellation_async_activity`."""

    id_or_token: Union[AsyncActivityIDReference, bytes]
    details: Sequence[Any]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class CreateScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.create_schedule`."""

    id: str
    schedule: Schedule
    trigger_immediately: bool
    backfill: Sequence[ScheduleBackfill]
    memo: Optional[Mapping[str, Any]]
    search_attributes: Optional[Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class ListSchedulesInput:
    """Input for :py:meth:`OutboundInterceptor.list_schedules`."""

    page_size: int
    next_page_token: Optional[bytes]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class BackfillScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.backfill_schedule`."""

    id: str
    backfills: Sequence[ScheduleBackfill]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class DeleteScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.delete_schedule`."""

    id: str
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class DescribeScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.describe_schedule`."""

    id: str
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class PauseScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.pause_schedule`."""

    id: str
    note: Optional[str]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class TriggerScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.trigger_schedule`."""

    id: str
    overlap: Optional[ScheduleOverlapPolicy]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class UnpauseScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.unpause_schedule`."""

    id: str
    note: Optional[str]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class UpdateScheduleInput:
    """Input for :py:meth:`OutboundInterceptor.update_schedule`."""

    id: str
    updater: Callable[
        [ScheduleUpdateInput],
        Union[Optional[ScheduleUpdate], Awaitable[Optional[ScheduleUpdate]]],
    ]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class UpdateWorkerBuildIdCompatibilityInput:
    """Input for :py:meth:`OutboundInterceptor.update_worker_build_id_compatibility`."""

    task_queue: str
    operation: BuildIdOp
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class GetWorkerBuildIdCompatibilityInput:
    """Input for :py:meth:`OutboundInterceptor.get_worker_build_id_compatibility`."""

    task_queue: str
    max_sets: Optional[int]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class GetWorkerTaskReachabilityInput:
    """Input for :py:meth:`OutboundInterceptor.get_worker_task_reachability`."""

    build_ids: Sequence[str]
    task_queues: Sequence[str]
    reachability: Optional[TaskReachabilityType]
    rpc_metadata: Mapping[str, str]
    rpc_timeout: Optional[timedelta]
    ...

@dataclass
class Interceptor:
    """Interceptor for clients.

    This should be extended by any client interceptors.
    """

    def intercept_client(self, next: OutboundInterceptor) -> OutboundInterceptor:
        """Method called for intercepting a client.

        Args:
            next: The underlying outbound interceptor this interceptor should
                delegate to.

        Returns:
            The new interceptor that will be called for each client call.
        """
        ...

class OutboundInterceptor:
    """OutboundInterceptor for intercepting client calls.

    This should be extended by any client outbound interceptors.
    """

    def __init__(self, next: OutboundInterceptor) -> None:
        """Create the outbound interceptor.

        Args:
            next: The next interceptor in the chain. The default implementation
                of all calls is to delegate to the next interceptor.
        """
        ...
    async def start_workflow(self, input: StartWorkflowInput) -> WorkflowHandle[Any, Any]:
        """Called for every :py:meth:`Client.start_workflow` call."""
        ...
    async def cancel_workflow(self, input: CancelWorkflowInput) -> None:
        """Called for every :py:meth:`WorkflowHandle.cancel` call."""
        ...
    async def describe_workflow(self, input: DescribeWorkflowInput) -> WorkflowExecutionDescription:
        """Called for every :py:meth:`WorkflowHandle.describe` call."""
        ...
    def fetch_workflow_history_events(
        self, input: FetchWorkflowHistoryEventsInput
    ) -> WorkflowHistoryEventAsyncIterator:
        """Called for every :py:meth:`WorkflowHandle.fetch_history_events` call."""
        ...
    def list_workflows(self, input: ListWorkflowsInput) -> WorkflowExecutionAsyncIterator:
        """Called for every :py:meth:`Client.list_workflows` call."""
        ...
    async def query_workflow(self, input: QueryWorkflowInput) -> Any:
        """Called for every :py:meth:`WorkflowHandle.query` call."""
        ...
    async def signal_workflow(self, input: SignalWorkflowInput) -> None:
        """Called for every :py:meth:`WorkflowHandle.signal` call."""
        ...
    async def terminate_workflow(self, input: TerminateWorkflowInput) -> None:
        """Called for every :py:meth:`WorkflowHandle.terminate` call."""
        ...
    async def start_workflow_update(self, input: StartWorkflowUpdateInput) -> WorkflowUpdateHandle[Any]:
        """Called for every :py:meth:`WorkflowHandle.update` and :py:meth:`WorkflowHandle.start_update` call."""
        ...
    async def heartbeat_async_activity(self, input: HeartbeatAsyncActivityInput) -> None:
        """Called for every :py:meth:`AsyncActivityHandle.heartbeat` call."""
        ...
    async def complete_async_activity(self, input: CompleteAsyncActivityInput) -> None:
        """Called for every :py:meth:`AsyncActivityHandle.complete` call."""
        ...
    async def fail_async_activity(self, input: FailAsyncActivityInput) -> None:
        """Called for every :py:meth:`AsyncActivityHandle.fail` call."""
        ...
    async def report_cancellation_async_activity(self, input: ReportCancellationAsyncActivityInput) -> None:
        """Called for every :py:meth:`AsyncActivityHandle.report_cancellation` call."""
        ...
    async def create_schedule(self, input: CreateScheduleInput) -> ScheduleHandle:
        """Called for every :py:meth:`Client.create_schedule` call."""
        ...
    def list_schedules(self, input: ListSchedulesInput) -> ScheduleAsyncIterator:
        """Called for every :py:meth:`Client.list_schedules` call."""
        ...
    async def backfill_schedule(self, input: BackfillScheduleInput) -> None:
        """Called for every :py:meth:`ScheduleHandle.backfill` call."""
        ...
    async def delete_schedule(self, input: DeleteScheduleInput) -> None:
        """Called for every :py:meth:`ScheduleHandle.delete` call."""
        ...
    async def describe_schedule(self, input: DescribeScheduleInput) -> ScheduleDescription:
        """Called for every :py:meth:`ScheduleHandle.describe` call."""
        ...
    async def pause_schedule(self, input: PauseScheduleInput) -> None:
        """Called for every :py:meth:`ScheduleHandle.pause` call."""
        ...
    async def trigger_schedule(self, input: TriggerScheduleInput) -> None:
        """Called for every :py:meth:`ScheduleHandle.trigger` call."""
        ...
    async def unpause_schedule(self, input: UnpauseScheduleInput) -> None:
        """Called for every :py:meth:`ScheduleHandle.unpause` call."""
        ...
    async def update_schedule(self, input: UpdateScheduleInput) -> None:
        """Called for every :py:meth:`ScheduleHandle.update` call."""
        ...
    async def update_worker_build_id_compatibility(self, input: UpdateWorkerBuildIdCompatibilityInput) -> None:
        """Called for every :py:meth:`Client.update_worker_build_id_compatibility` call."""
        ...
    async def get_worker_build_id_compatibility(
        self, input: GetWorkerBuildIdCompatibilityInput
    ) -> WorkerBuildIdVersionSets:
        """Called for every :py:meth:`Client.get_worker_build_id_compatibility` call."""
        ...
    async def get_worker_task_reachability(self, input: GetWorkerTaskReachabilityInput) -> WorkerTaskReachability:
        """Called for every :py:meth:`Client.get_worker_task_reachability` call."""
        ...

class _ClientImpl(OutboundInterceptor):
    def __init__(self, client: Client) -> None: ...
    async def start_workflow(self, input: StartWorkflowInput) -> WorkflowHandle[Any, Any]: ...
    async def cancel_workflow(self, input: CancelWorkflowInput) -> None: ...
    async def describe_workflow(self, input: DescribeWorkflowInput) -> WorkflowExecutionDescription: ...
    def fetch_workflow_history_events(
        self, input: FetchWorkflowHistoryEventsInput
    ) -> WorkflowHistoryEventAsyncIterator: ...
    def list_workflows(self, input: ListWorkflowsInput) -> WorkflowExecutionAsyncIterator: ...
    async def query_workflow(self, input: QueryWorkflowInput) -> Any: ...
    async def signal_workflow(self, input: SignalWorkflowInput) -> None: ...
    async def terminate_workflow(self, input: TerminateWorkflowInput) -> None: ...
    async def start_workflow_update(self, input: StartWorkflowUpdateInput) -> WorkflowUpdateHandle[Any]: ...
    async def heartbeat_async_activity(self, input: HeartbeatAsyncActivityInput) -> None: ...
    async def complete_async_activity(self, input: CompleteAsyncActivityInput) -> None: ...
    async def fail_async_activity(self, input: FailAsyncActivityInput) -> None: ...
    async def report_cancellation_async_activity(self, input: ReportCancellationAsyncActivityInput) -> None: ...
    async def create_schedule(self, input: CreateScheduleInput) -> ScheduleHandle: ...
    def list_schedules(self, input: ListSchedulesInput) -> ScheduleAsyncIterator: ...
    async def backfill_schedule(self, input: BackfillScheduleInput) -> None: ...
    async def delete_schedule(self, input: DeleteScheduleInput) -> None: ...
    async def describe_schedule(self, input: DescribeScheduleInput) -> ScheduleDescription: ...
    async def pause_schedule(self, input: PauseScheduleInput) -> None: ...
    async def trigger_schedule(self, input: TriggerScheduleInput) -> None: ...
    async def unpause_schedule(self, input: UnpauseScheduleInput) -> None: ...
    async def update_schedule(self, input: UpdateScheduleInput) -> None: ...
    async def update_worker_build_id_compatibility(self, input: UpdateWorkerBuildIdCompatibilityInput) -> None: ...
    async def get_worker_build_id_compatibility(
        self, input: GetWorkerBuildIdCompatibilityInput
    ) -> WorkerBuildIdVersionSets: ...
    async def get_worker_task_reachability(self, input: GetWorkerTaskReachabilityInput) -> WorkerTaskReachability: ...

_pascal_case_match = ...

@dataclass(frozen=True)
class WorkerBuildIdVersionSets:
    """Represents the sets of compatible Build ID versions associated with some Task Queue, as
    fetched by :py:meth:`Client.get_worker_build_id_compatibility`.
    """

    version_sets: Sequence[BuildIdVersionSet]
    def default_set(self) -> BuildIdVersionSet:
        """Returns the default version set for this task queue."""
        ...
    def default_build_id(self) -> str:
        """Returns the default Build ID for this task queue."""
        ...

@dataclass(frozen=True)
class BuildIdVersionSet:
    """A set of Build IDs which are compatible with each other."""

    build_ids: Sequence[str]
    def default(self) -> str:
        """Returns the default Build ID for this set."""
        ...

class BuildIdOp(ABC):
    """Base class for Build ID operations as used by
    :py:meth:`Client.update_worker_build_id_compatibility`.
    """

    ...

@dataclass(frozen=True)
class BuildIdOpAddNewDefault(BuildIdOp):
    """Adds a new Build Id into a new set, which will be used as the default set for
    the queue. This means all new workflows will start on this Build Id.
    """

    build_id: str
    ...

@dataclass(frozen=True)
class BuildIdOpAddNewCompatible(BuildIdOp):
    """Adds a new Build Id into an existing compatible set. The newly added ID becomes
    the default for that compatible set, and thus new workflow tasks for workflows which have been
    executing on workers in that set will now start on this new Build Id.
    """

    build_id: str
    existing_compatible_build_id: str
    promote_set: bool = ...

@dataclass(frozen=True)
class BuildIdOpPromoteSetByBuildId(BuildIdOp):
    """Promotes a set of compatible Build Ids to become the current default set for the task queue.
    Any Build Id in the set may be used to target it.
    """

    build_id: str
    ...

@dataclass(frozen=True)
class BuildIdOpPromoteBuildIdWithinSet(BuildIdOp):
    """Promotes a Build Id within an existing set to become the default ID for that set."""

    build_id: str
    ...

@dataclass(frozen=True)
class BuildIdOpMergeSets(BuildIdOp):
    """Merges two sets into one set, thus declaring all the Build Ids in both as compatible with one
    another. The default of the primary set is maintained as the merged set's overall default.
    """

    primary_build_id: str
    secondary_build_id: str
    ...

@dataclass(frozen=True)
class WorkerTaskReachability:
    """Contains information about the reachability of some Build IDs"""

    build_id_reachability: Mapping[str, BuildIdReachability]
    ...

@dataclass(frozen=True)
class BuildIdReachability:
    """Contains information about the reachability of a specific Build ID"""

    task_queue_reachability: Mapping[str, Sequence[TaskReachabilityType]]
    unretrieved_task_queues: FrozenSet[str]
    ...

class TaskReachabilityType(Enum):
    """Enumerates how a task might reach certain kinds of workflows"""

    NEW_WORKFLOWS = ...
    EXISTING_WORKFLOWS = ...
    OPEN_WORKFLOWS = ...
    CLOSED_WORKFLOWS = ...
