# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._stripe_object import StripeObject, UntypedStripeObject
from typing import ClassVar, Optional
from typing_extensions import Literal


class BatchJob(StripeObject):
    """
    A batch job allows you to perform an API operation on a large set of records asynchronously.
    """

    OBJECT_NAME: ClassVar[Literal["v2.core.batch_job"]] = "v2.core.batch_job"

    class StatusDetails(StripeObject):
        class BatchFailed(StripeObject):
            error: str
            """
            Details about the `batch_job` failure.
            """

        class Canceled(StripeObject):
            class OutputFile(StripeObject):
                class DownloadUrl(StripeObject):
                    expires_at: Optional[str]
                    """
                    The time that the URL expires.
                    """
                    url: str
                    """
                    The URL that can be used for accessing the file.
                    """

                content_type: str
                """
                The content type of the file.
                """
                download_url: DownloadUrl
                """
                A pre-signed URL that allows secure, time-limited access to download the file.
                """
                size: int
                """
                The total size of the file in bytes.
                """
                _inner_class_types = {"download_url": DownloadUrl}
                _field_encodings = {"size": "int64_string"}

            failure_count: int
            """
            The total number of records that failed processing.
            """
            output_file: OutputFile
            """
            The output file details. If the `batch_job` is canceled, this is provided only if there is already output at this point.
            """
            success_count: int
            """
            The total number of records that were successfully processed.
            """
            _inner_class_types = {"output_file": OutputFile}
            _field_encodings = {
                "failure_count": "int64_string",
                "success_count": "int64_string",
            }

        class Complete(StripeObject):
            class OutputFile(StripeObject):
                class DownloadUrl(StripeObject):
                    expires_at: Optional[str]
                    """
                    The time that the URL expires.
                    """
                    url: str
                    """
                    The URL that can be used for accessing the file.
                    """

                content_type: str
                """
                The content type of the file.
                """
                download_url: DownloadUrl
                """
                A pre-signed URL that allows secure, time-limited access to download the file.
                """
                size: int
                """
                The total size of the file in bytes.
                """
                _inner_class_types = {"download_url": DownloadUrl}
                _field_encodings = {"size": "int64_string"}

            failure_count: int
            """
            The total number of records that failed processing.
            """
            output_file: OutputFile
            """
            The output file details. If the `batch_job` is canceled, this is provided only if there is already output at this point.
            """
            success_count: int
            """
            The total number of records that were successfully processed.
            """
            _inner_class_types = {"output_file": OutputFile}
            _field_encodings = {
                "failure_count": "int64_string",
                "success_count": "int64_string",
            }

        class InProgress(StripeObject):
            failure_count: int
            """
            The number of records that failed processing so far.
            """
            success_count: int
            """
            The number of records that were successfully processed so far.
            """
            _field_encodings = {
                "failure_count": "int64_string",
                "success_count": "int64_string",
            }

        class ReadyForUpload(StripeObject):
            class UploadUrl(StripeObject):
                expires_at: Optional[str]
                """
                The time that the URL expires.
                """
                url: str
                """
                The URL that can be used for accessing the file.
                """

            upload_url: UploadUrl
            """
            The upload file details.
            """
            _inner_class_types = {"upload_url": UploadUrl}

        class Timeout(StripeObject):
            class OutputFile(StripeObject):
                class DownloadUrl(StripeObject):
                    expires_at: Optional[str]
                    """
                    The time that the URL expires.
                    """
                    url: str
                    """
                    The URL that can be used for accessing the file.
                    """

                content_type: str
                """
                The content type of the file.
                """
                download_url: DownloadUrl
                """
                A pre-signed URL that allows secure, time-limited access to download the file.
                """
                size: int
                """
                The total size of the file in bytes.
                """
                _inner_class_types = {"download_url": DownloadUrl}
                _field_encodings = {"size": "int64_string"}

            failure_count: int
            """
            The total number of records that failed processing.
            """
            output_file: OutputFile
            """
            The output file details. If the `batch_job` is canceled, this is provided only if there is already output at this point.
            """
            success_count: int
            """
            The total number of records that were successfully processed.
            """
            _inner_class_types = {"output_file": OutputFile}
            _field_encodings = {
                "failure_count": "int64_string",
                "success_count": "int64_string",
            }

        class Validating(StripeObject):
            validated_count: int
            """
            The number of records that were validated. Note that there is no failure counter here;
            once we have any validation failures we give up.
            """
            _field_encodings = {"validated_count": "int64_string"}

        class ValidationFailed(StripeObject):
            class OutputFile(StripeObject):
                class DownloadUrl(StripeObject):
                    expires_at: Optional[str]
                    """
                    The time that the URL expires.
                    """
                    url: str
                    """
                    The URL that can be used for accessing the file.
                    """

                content_type: str
                """
                The content type of the file.
                """
                download_url: DownloadUrl
                """
                A pre-signed URL that allows secure, time-limited access to download the file.
                """
                size: int
                """
                The total size of the file in bytes.
                """
                _inner_class_types = {"download_url": DownloadUrl}
                _field_encodings = {"size": "int64_string"}

            failure_count: int
            """
            The total number of records that failed processing.
            """
            output_file: OutputFile
            """
            The output file details. If the `batch_job` is canceled, this is provided only if there is already output at this point.
            """
            success_count: int
            """
            The total number of records that were successfully processed.
            """
            _inner_class_types = {"output_file": OutputFile}
            _field_encodings = {
                "failure_count": "int64_string",
                "success_count": "int64_string",
            }

        batch_failed: Optional[BatchFailed]
        """
        Additional details for the `BATCH_FAILED` status of the `batch_job`.
        """
        canceled: Optional[Canceled]
        """
        Additional details for the `CANCELED` status of the `batch_job`.
        """
        complete: Optional[Complete]
        """
        Additional details for the `COMPLETE` status of the `batch_job`.
        """
        in_progress: Optional[InProgress]
        """
        Additional details for the `IN_PROGRESS` status of the `batch_job`.
        """
        ready_for_upload: Optional[ReadyForUpload]
        """
        Additional details for the `READY_FOR_UPLOAD` status of the `batch_job`.
        """
        timeout: Optional[Timeout]
        """
        Additional details for the `TIMEOUT` status of the `batch_job`.
        """
        validating: Optional[Validating]
        """
        Additional details for the `VALIDATING` status of the `batch_job`.
        """
        validation_failed: Optional[ValidationFailed]
        """
        Additional details for the `VALIDATION_FAILED` status of the `batch_job`.
        """
        _inner_class_types = {
            "batch_failed": BatchFailed,
            "canceled": Canceled,
            "complete": Complete,
            "in_progress": InProgress,
            "ready_for_upload": ReadyForUpload,
            "timeout": Timeout,
            "validating": Validating,
            "validation_failed": ValidationFailed,
        }

    created: str
    """
    Timestamp at which the `batch_job` was created.
    """
    id: str
    """
    Unique identifier for the `batch_job`.
    """
    livemode: bool
    """
    Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
    """
    metadata: UntypedStripeObject[str]
    """
    The metadata of the `batch_job`.
    """
    object: Literal["v2.core.batch_job"]
    """
    String representing the object's type. Objects of the same type share the same value of the object field.
    """
    skip_validation: bool
    """
    Whether validation runs before executing the `batch_job`.
    """
    status: Literal[
        "batch_failed",
        "canceled",
        "cancelling",
        "complete",
        "in_progress",
        "ready_for_upload",
        "timeout",
        "upload_timeout",
        "validating",
        "validation_failed",
    ]
    """
    The current status of the `batch_job`.
    """
    status_details: Optional[StatusDetails]
    """
    Additional details about the current state of the `batch_job`.
    """
    _inner_class_types = {"status_details": StatusDetails}
