"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.


https://chromedevtools.github.io/devtools-protocol/tot/Tracing/

***************************************************
                    Methods
***************************************************
"""
from __future__ import annotations

from typing import Literal

from cdpkit.protocol._types import (
    Tracing,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class End(CDPMethod[None]):
    """ Stop trace events collection. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class GetCategoriesOutput(OutputModel):

    categories: list[str]


class GetCategories(CDPMethod[GetCategoriesOutput]):  # experimental
    """ Gets supported tracing categories. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetCategoriesOutput


class GetTrackEventDescriptorOutput(OutputModel):

    descriptor: str


class GetTrackEventDescriptor(CDPMethod[GetTrackEventDescriptorOutput]):  # experimental
    """ Return a descriptor for all available tracing categories. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetTrackEventDescriptorOutput


class RecordClockSyncMarkerInput(InputModel):

    syncId: str


class RecordClockSyncMarker(CDPMethod[None]):  # experimental
    """ Record a clock sync marker in the trace. """

    INPUT_VALIDATOR = RecordClockSyncMarkerInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        sync_id: str
    ):
        super().__init__(
            syncId=sync_id
        )


class RequestMemoryDumpInput(InputModel):

    deterministic: bool | None = None
    levelOfDetail: Tracing.MemoryDumpLevelOfDetail | None = None


class RequestMemoryDumpOutput(OutputModel):

    dumpGuid: str
    success: bool


class RequestMemoryDump(CDPMethod[RequestMemoryDumpOutput]):  # experimental
    """ Request a global memory dump. """

    INPUT_VALIDATOR = RequestMemoryDumpInput
    OUTPUT_VALIDATOR = RequestMemoryDumpOutput

    def __init__(
        self,
        *,
        deterministic: bool | None = None,
        level_of_detail: Tracing.MemoryDumpLevelOfDetail | None = None
    ):
        super().__init__(
            deterministic=deterministic,
            levelOfDetail=level_of_detail
        )


class StartInput(InputModel):

    categories: str | None = None  # experimental deprecated
    options: str | None = None  # experimental deprecated
    bufferUsageReportingInterval: float | None = None  # experimental
    transferMode: Literal['ReportEvents', 'ReturnAsStream'] | None = None
    streamFormat: Tracing.StreamFormat | None = None
    streamCompression: Tracing.StreamCompression | None = None  # experimental
    traceConfig: Tracing.TraceConfig | None = None
    perfettoConfig: str | None = None  # experimental
    tracingBackend: Tracing.TracingBackend | None = None  # experimental


class Start(CDPMethod[None]):
    """ Start trace events collection. """

    INPUT_VALIDATOR = StartInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        categories: str | None = None,
        options: str | None = None,
        buffer_usage_reporting_interval: float | None = None,
        transfer_mode: Literal['ReportEvents', 'ReturnAsStream'] | None = None,
        stream_format: Tracing.StreamFormat | None = None,
        stream_compression: Tracing.StreamCompression | None = None,
        trace_config: Tracing.TraceConfig | None = None,
        perfetto_config: str | None = None,
        tracing_backend: Tracing.TracingBackend | None = None
    ):
        super().__init__(
            categories=categories,
            options=options,
            bufferUsageReportingInterval=buffer_usage_reporting_interval,
            transferMode=transfer_mode,
            streamFormat=stream_format,
            streamCompression=stream_compression,
            traceConfig=trace_config,
            perfettoConfig=perfetto_config,
            tracingBackend=tracing_backend
        )
