"""
@generated by mypy-protobuf.  Do not edit manually!
isort:skip_file
"""

import builtins
import sys
import typing

import google.protobuf.descriptor
import google.protobuf.internal.enum_type_wrapper
import google.protobuf.message

import temporalio.api.common.v1.message_pb2
import temporalio.api.failure.v1.message_pb2
import temporalio.api.nexus.v1.message_pb2
import temporalio.api.workflowservice.v1.request_response_pb2

if sys.version_info >= (3, 10):
    import typing as typing_extensions
else:
    import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

class _NexusTaskCancelReason:
    ValueType = typing.NewType("ValueType", builtins.int)
    V: typing_extensions.TypeAlias = ValueType

class _NexusTaskCancelReasonEnumTypeWrapper(
    google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[
        _NexusTaskCancelReason.ValueType
    ],
    builtins.type,
):  # noqa: F821
    DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
    TIMED_OUT: _NexusTaskCancelReason.ValueType  # 0
    """The nexus task is known to have timed out"""
    WORKER_SHUTDOWN: _NexusTaskCancelReason.ValueType  # 1
    """The worker is shutting down"""

class NexusTaskCancelReason(
    _NexusTaskCancelReason, metaclass=_NexusTaskCancelReasonEnumTypeWrapper
): ...

TIMED_OUT: NexusTaskCancelReason.ValueType  # 0
"""The nexus task is known to have timed out"""
WORKER_SHUTDOWN: NexusTaskCancelReason.ValueType  # 1
"""The worker is shutting down"""
global___NexusTaskCancelReason = NexusTaskCancelReason

class _NexusOperationCancellationType:
    ValueType = typing.NewType("ValueType", builtins.int)
    V: typing_extensions.TypeAlias = ValueType

class _NexusOperationCancellationTypeEnumTypeWrapper(
    google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[
        _NexusOperationCancellationType.ValueType
    ],
    builtins.type,
):  # noqa: F821
    DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
    WAIT_CANCELLATION_COMPLETED: _NexusOperationCancellationType.ValueType  # 0
    """Wait for operation cancellation completion. Default."""
    ABANDON: _NexusOperationCancellationType.ValueType  # 1
    """Do not request cancellation of the nexus operation if already scheduled"""
    TRY_CANCEL: _NexusOperationCancellationType.ValueType  # 2
    """Initiate a cancellation request for the Nexus operation and immediately report cancellation
    to the caller. Note that it doesn't guarantee that cancellation is delivered to the operation if calling workflow exits before the delivery is done.
    If you want to ensure that cancellation is delivered to the operation, use WAIT_CANCELLATION_REQUESTED.
    """
    WAIT_CANCELLATION_REQUESTED: _NexusOperationCancellationType.ValueType  # 3
    """Request cancellation of the operation and wait for confirmation that the request was received."""

class NexusOperationCancellationType(
    _NexusOperationCancellationType,
    metaclass=_NexusOperationCancellationTypeEnumTypeWrapper,
):
    """Controls at which point to report back to lang when a nexus operation is cancelled"""

WAIT_CANCELLATION_COMPLETED: NexusOperationCancellationType.ValueType  # 0
"""Wait for operation cancellation completion. Default."""
ABANDON: NexusOperationCancellationType.ValueType  # 1
"""Do not request cancellation of the nexus operation if already scheduled"""
TRY_CANCEL: NexusOperationCancellationType.ValueType  # 2
"""Initiate a cancellation request for the Nexus operation and immediately report cancellation
to the caller. Note that it doesn't guarantee that cancellation is delivered to the operation if calling workflow exits before the delivery is done.
If you want to ensure that cancellation is delivered to the operation, use WAIT_CANCELLATION_REQUESTED.
"""
WAIT_CANCELLATION_REQUESTED: NexusOperationCancellationType.ValueType  # 3
"""Request cancellation of the operation and wait for confirmation that the request was received."""
global___NexusOperationCancellationType = NexusOperationCancellationType

class NexusOperationResult(google.protobuf.message.Message):
    """Used by core to resolve nexus operations."""

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    COMPLETED_FIELD_NUMBER: builtins.int
    FAILED_FIELD_NUMBER: builtins.int
    CANCELLED_FIELD_NUMBER: builtins.int
    TIMED_OUT_FIELD_NUMBER: builtins.int
    @property
    def completed(self) -> temporalio.api.common.v1.message_pb2.Payload: ...
    @property
    def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: ...
    @property
    def cancelled(self) -> temporalio.api.failure.v1.message_pb2.Failure: ...
    @property
    def timed_out(self) -> temporalio.api.failure.v1.message_pb2.Failure: ...
    def __init__(
        self,
        *,
        completed: temporalio.api.common.v1.message_pb2.Payload | None = ...,
        failed: temporalio.api.failure.v1.message_pb2.Failure | None = ...,
        cancelled: temporalio.api.failure.v1.message_pb2.Failure | None = ...,
        timed_out: temporalio.api.failure.v1.message_pb2.Failure | None = ...,
    ) -> None: ...
    def HasField(
        self,
        field_name: typing_extensions.Literal[
            "cancelled",
            b"cancelled",
            "completed",
            b"completed",
            "failed",
            b"failed",
            "status",
            b"status",
            "timed_out",
            b"timed_out",
        ],
    ) -> builtins.bool: ...
    def ClearField(
        self,
        field_name: typing_extensions.Literal[
            "cancelled",
            b"cancelled",
            "completed",
            b"completed",
            "failed",
            b"failed",
            "status",
            b"status",
            "timed_out",
            b"timed_out",
        ],
    ) -> None: ...
    def WhichOneof(
        self, oneof_group: typing_extensions.Literal["status", b"status"]
    ) -> (
        typing_extensions.Literal["completed", "failed", "cancelled", "timed_out"]
        | None
    ): ...

global___NexusOperationResult = NexusOperationResult

class NexusTaskCompletion(google.protobuf.message.Message):
    """A response to a Nexus task"""

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    TASK_TOKEN_FIELD_NUMBER: builtins.int
    COMPLETED_FIELD_NUMBER: builtins.int
    ERROR_FIELD_NUMBER: builtins.int
    ACK_CANCEL_FIELD_NUMBER: builtins.int
    task_token: builtins.bytes
    """The unique identifier for this task provided in the poll response"""
    @property
    def completed(self) -> temporalio.api.nexus.v1.message_pb2.Response:
        """The handler completed (successfully or not). Note that the response kind must match the
        request kind (start or cancel).
        """
    @property
    def error(self) -> temporalio.api.nexus.v1.message_pb2.HandlerError:
        """The handler could not complete the request for some reason."""
    ack_cancel: builtins.bool
    """The lang SDK acknowledges that it is responding to a `CancelNexusTask` and thus the
    response is irrelevant. This is not the only way to respond to a cancel, the other
    variants can still be used, but this variant should be used when the handler was aborted
    by cancellation.
    """
    def __init__(
        self,
        *,
        task_token: builtins.bytes = ...,
        completed: temporalio.api.nexus.v1.message_pb2.Response | None = ...,
        error: temporalio.api.nexus.v1.message_pb2.HandlerError | None = ...,
        ack_cancel: builtins.bool = ...,
    ) -> None: ...
    def HasField(
        self,
        field_name: typing_extensions.Literal[
            "ack_cancel",
            b"ack_cancel",
            "completed",
            b"completed",
            "error",
            b"error",
            "status",
            b"status",
        ],
    ) -> builtins.bool: ...
    def ClearField(
        self,
        field_name: typing_extensions.Literal[
            "ack_cancel",
            b"ack_cancel",
            "completed",
            b"completed",
            "error",
            b"error",
            "status",
            b"status",
            "task_token",
            b"task_token",
        ],
    ) -> None: ...
    def WhichOneof(
        self, oneof_group: typing_extensions.Literal["status", b"status"]
    ) -> typing_extensions.Literal["completed", "error", "ack_cancel"] | None: ...

global___NexusTaskCompletion = NexusTaskCompletion

class NexusTask(google.protobuf.message.Message):
    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    TASK_FIELD_NUMBER: builtins.int
    CANCEL_TASK_FIELD_NUMBER: builtins.int
    @property
    def task(
        self,
    ) -> temporalio.api.workflowservice.v1.request_response_pb2.PollNexusTaskQueueResponse:
        """A nexus task from server"""
    @property
    def cancel_task(self) -> global___CancelNexusTask:
        """A request by Core to notify an in-progress operation handler that it should cancel. This
        is distinct from a `CancelOperationRequest` from the server, which results from the user
        requesting the cancellation of an operation. Handling this variant should result in
        something like cancelling a cancellation token given to the user's operation handler.

        These do not count as a separate task for the purposes of completing all issued tasks,
        but rather count as a sort of modification to the already-issued task which is being
        cancelled.

        EX: Core knows the nexus operation has timed out, and it does not make sense for the
        user's operation handler to continue doing work.
        """
    def __init__(
        self,
        *,
        task: temporalio.api.workflowservice.v1.request_response_pb2.PollNexusTaskQueueResponse
        | None = ...,
        cancel_task: global___CancelNexusTask | None = ...,
    ) -> None: ...
    def HasField(
        self,
        field_name: typing_extensions.Literal[
            "cancel_task", b"cancel_task", "task", b"task", "variant", b"variant"
        ],
    ) -> builtins.bool: ...
    def ClearField(
        self,
        field_name: typing_extensions.Literal[
            "cancel_task", b"cancel_task", "task", b"task", "variant", b"variant"
        ],
    ) -> None: ...
    def WhichOneof(
        self, oneof_group: typing_extensions.Literal["variant", b"variant"]
    ) -> typing_extensions.Literal["task", "cancel_task"] | None: ...

global___NexusTask = NexusTask

class CancelNexusTask(google.protobuf.message.Message):
    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    TASK_TOKEN_FIELD_NUMBER: builtins.int
    REASON_FIELD_NUMBER: builtins.int
    task_token: builtins.bytes
    """The task token from the PollNexusTaskQueueResponse"""
    reason: global___NexusTaskCancelReason.ValueType
    """Why Core is asking for this operation to be cancelled"""
    def __init__(
        self,
        *,
        task_token: builtins.bytes = ...,
        reason: global___NexusTaskCancelReason.ValueType = ...,
    ) -> None: ...
    def ClearField(
        self,
        field_name: typing_extensions.Literal[
            "reason", b"reason", "task_token", b"task_token"
        ],
    ) -> None: ...

global___CancelNexusTask = CancelNexusTask
