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

Network domain allows tracking network activities of the page. It exposes information about http,
file, data and other requests and responses, their headers, bodies, timing, etc.
https://chromedevtools.github.io/devtools-protocol/tot/Network/

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

from cdpkit.protocol._types import (
    IO,
    Debugger,
    Emulation,
    Network,
    Page,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class SetAcceptedEncodingsInput(InputModel):

    encodings: list[Network.ContentEncoding]  # deprecated


class SetAcceptedEncodings(CDPMethod[None]):  # experimental deprecated
    """ Sets a list of content encodings that will be accepted. Empty list means no encoding is accepted. """

    INPUT_VALIDATOR = SetAcceptedEncodingsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        encodings: list[Network.ContentEncoding]
    ):
        super().__init__(
            encodings=encodings
        )


class ClearAcceptedEncodingsOverride(CDPMethod[None]):  # experimental deprecated
    """ Clears accepted encodings set by setAcceptedEncodings """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class CanClearBrowserCacheOutput(OutputModel):

    result: bool  # deprecated


class CanClearBrowserCache(CDPMethod[CanClearBrowserCacheOutput]):  # deprecated
    """ Tells whether clearing browser cache is supported. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = CanClearBrowserCacheOutput


class CanClearBrowserCookiesOutput(OutputModel):

    result: bool  # deprecated


class CanClearBrowserCookies(CDPMethod[CanClearBrowserCookiesOutput]):  # deprecated
    """ Tells whether clearing browser cookies is supported. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = CanClearBrowserCookiesOutput


class CanEmulateNetworkConditionsOutput(OutputModel):

    result: bool  # deprecated


class CanEmulateNetworkConditions(CDPMethod[CanEmulateNetworkConditionsOutput]):  # deprecated
    """ Tells whether emulation of network conditions is supported. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = CanEmulateNetworkConditionsOutput


class ClearBrowserCache(CDPMethod[None]):  # deprecated
    """ Clears browser cache. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class ClearBrowserCookies(CDPMethod[None]):  # deprecated
    """ Clears browser cookies. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class ContinueInterceptedRequestInput(InputModel):

    interceptionId: Network.InterceptionId
    errorReason: Network.ErrorReason | None = None  # deprecated
    rawResponse: str | None = None  # deprecated
    url: str | None = None  # deprecated
    method: str | None = None  # deprecated
    postData: str | None = None  # deprecated
    headers: Network.Headers | None = None  # deprecated
    authChallengeResponse: Network.AuthChallengeResponse | None = None  # deprecated


class ContinueInterceptedRequest(CDPMethod[None]):  # experimental deprecated
    """ Response to Network.requestIntercepted which either modifies the request to continue with any
    modifications, or blocks it, or completes it with the provided response bytes. If a network
    fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted
    event will be sent with the same InterceptionId.
    Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead. """

    INPUT_VALIDATOR = ContinueInterceptedRequestInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        interception_id: Network.InterceptionId,
        error_reason: Network.ErrorReason | None = None,
        raw_response: str | None = None,
        url: str | None = None,
        method: str | None = None,
        post_data: str | None = None,
        headers: Network.Headers | None = None,
        auth_challenge_response: Network.AuthChallengeResponse | None = None
    ):
        super().__init__(
            interceptionId=interception_id,
            errorReason=error_reason,
            rawResponse=raw_response,
            url=url,
            method=method,
            postData=post_data,
            headers=headers,
            authChallengeResponse=auth_challenge_response
        )


class DeleteCookiesInput(InputModel):

    name: str  # deprecated
    url: str | None = None  # deprecated
    domain: str | None = None  # deprecated
    path: str | None = None  # deprecated
    partitionKey: Network.CookiePartitionKey | None = None  # experimental deprecated


class DeleteCookies(CDPMethod[None]):  # deprecated
    """ Deletes browser cookies with matching name and url or domain/path/partitionKey pair. """

    INPUT_VALIDATOR = DeleteCookiesInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        name: str,
        url: str | None = None,
        domain: str | None = None,
        path: str | None = None,
        partition_key: Network.CookiePartitionKey | None = None
    ):
        super().__init__(
            name=name,
            url=url,
            domain=domain,
            path=path,
            partitionKey=partition_key
        )


class Disable(CDPMethod[None]):  # deprecated
    """ Disables network tracking, prevents network events from being sent to the client. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class EmulateNetworkConditionsInput(InputModel):

    offline: bool  # deprecated
    latency: float  # deprecated
    downloadThroughput: float  # deprecated
    uploadThroughput: float  # deprecated
    connectionType: Network.ConnectionType | None = None  # deprecated
    packetLoss: float | None = None  # experimental deprecated
    packetQueueLength: int | None = None  # experimental deprecated
    packetReordering: bool | None = None  # experimental deprecated


class EmulateNetworkConditions(CDPMethod[None]):  # deprecated
    """ Activates emulation of network conditions. """

    INPUT_VALIDATOR = EmulateNetworkConditionsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        offline: bool,
        latency: float,
        download_throughput: float,
        upload_throughput: float,
        connection_type: Network.ConnectionType | None = None,
        packet_loss: float | None = None,
        packet_queue_length: int | None = None,
        packet_reordering: bool | None = None
    ):
        super().__init__(
            offline=offline,
            latency=latency,
            downloadThroughput=download_throughput,
            uploadThroughput=upload_throughput,
            connectionType=connection_type,
            packetLoss=packet_loss,
            packetQueueLength=packet_queue_length,
            packetReordering=packet_reordering
        )


class EnableInput(InputModel):

    maxTotalBufferSize: int | None = None  # experimental deprecated
    maxResourceBufferSize: int | None = None  # experimental deprecated
    maxPostDataSize: int | None = None  # deprecated
    reportDirectSocketTraffic: bool | None = None  # experimental deprecated


class Enable(CDPMethod[None]):  # deprecated
    """ Enables network tracking, network events will now be delivered to the client. """

    INPUT_VALIDATOR = EnableInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        max_total_buffer_size: int | None = None,
        max_resource_buffer_size: int | None = None,
        max_post_data_size: int | None = None,
        report_direct_socket_traffic: bool | None = None
    ):
        super().__init__(
            maxTotalBufferSize=max_total_buffer_size,
            maxResourceBufferSize=max_resource_buffer_size,
            maxPostDataSize=max_post_data_size,
            reportDirectSocketTraffic=report_direct_socket_traffic
        )


class GetAllCookiesOutput(OutputModel):

    cookies: list[Network.Cookie]  # deprecated


class GetAllCookies(CDPMethod[GetAllCookiesOutput]):  # deprecated
    """ Returns all browser cookies. Depending on the backend support, will return detailed cookie
    information in the `cookies` field.
    Deprecated. Use Storage.getCookies instead. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = GetAllCookiesOutput


class GetCertificateInput(InputModel):

    origin: str  # deprecated


class GetCertificateOutput(OutputModel):

    tableNames: list[str]


class GetCertificate(CDPMethod[GetCertificateOutput]):  # experimental deprecated
    """ Returns the DER-encoded certificate. """

    INPUT_VALIDATOR = GetCertificateInput
    OUTPUT_VALIDATOR = GetCertificateOutput

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


class GetCookiesInput(InputModel):

    urls: list[str] | None = None  # deprecated


class GetCookiesOutput(OutputModel):

    cookies: list[Network.Cookie]  # deprecated


class GetCookies(CDPMethod[GetCookiesOutput]):  # deprecated
    """ Returns all browser cookies for the current URL. Depending on the backend support, will return
    detailed cookie information in the `cookies` field. """

    INPUT_VALIDATOR = GetCookiesInput
    OUTPUT_VALIDATOR = GetCookiesOutput

    def __init__(
        self,
        *,
        urls: list[str] | None = None
    ):
        super().__init__(
            urls=urls
        )


class GetResponseBodyInput(InputModel):

    requestId: Network.RequestId  # deprecated


class GetResponseBodyOutput(OutputModel):

    body: str  # deprecated
    base64Encoded: bool  # deprecated


class GetResponseBody(CDPMethod[GetResponseBodyOutput]):  # deprecated
    """ Returns content served for the given request. """

    INPUT_VALIDATOR = GetResponseBodyInput
    OUTPUT_VALIDATOR = GetResponseBodyOutput

    def __init__(
        self,
        *,
        request_id: Network.RequestId
    ):
        super().__init__(
            requestId=request_id
        )


class GetRequestPostDataInput(InputModel):

    requestId: Network.RequestId  # deprecated


class GetRequestPostDataOutput(OutputModel):

    postData: str  # deprecated


class GetRequestPostData(CDPMethod[GetRequestPostDataOutput]):  # deprecated
    """ Returns post data sent with the request. Returns an error when no data was sent with the request. """

    INPUT_VALIDATOR = GetRequestPostDataInput
    OUTPUT_VALIDATOR = GetRequestPostDataOutput

    def __init__(
        self,
        *,
        request_id: Network.RequestId
    ):
        super().__init__(
            requestId=request_id
        )


class GetResponseBodyForInterceptionInput(InputModel):

    interceptionId: Network.InterceptionId  # deprecated


class GetResponseBodyForInterceptionOutput(OutputModel):

    body: str  # deprecated
    base64Encoded: bool  # deprecated


class GetResponseBodyForInterception(CDPMethod[GetResponseBodyForInterceptionOutput]):  # experimental deprecated
    """ Returns content served for the given currently intercepted request. """

    INPUT_VALIDATOR = GetResponseBodyForInterceptionInput
    OUTPUT_VALIDATOR = GetResponseBodyForInterceptionOutput

    def __init__(
        self,
        *,
        interception_id: Network.InterceptionId
    ):
        super().__init__(
            interceptionId=interception_id
        )


class TakeResponseBodyForInterceptionAsStreamInput(InputModel):

    interceptionId: Network.InterceptionId


class TakeResponseBodyForInterceptionAsStreamOutput(OutputModel):

    stream: IO.StreamHandle


class TakeResponseBodyForInterceptionAsStream(CDPMethod[TakeResponseBodyForInterceptionAsStreamOutput]):  # experimental deprecated
    """ Returns a handle to the stream representing the response body. Note that after this command,
    the intercepted request can't be continued as is -- you either need to cancel it or to provide
    the response body. The stream only supports sequential read, IO.read will fail if the position
    is specified. """

    INPUT_VALIDATOR = TakeResponseBodyForInterceptionAsStreamInput
    OUTPUT_VALIDATOR = TakeResponseBodyForInterceptionAsStreamOutput

    def __init__(
        self,
        *,
        interception_id: Network.InterceptionId
    ):
        super().__init__(
            interceptionId=interception_id
        )


class ReplayXHRInput(InputModel):

    requestId: Network.RequestId  # deprecated


class ReplayXHR(CDPMethod[None]):  # experimental deprecated
    """ This method sends a new XMLHttpRequest which is identical to the original one. The following
    parameters should be identical: method, url, async, request body, extra headers, withCredentials
    attribute, user, password. """

    INPUT_VALIDATOR = ReplayXHRInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        request_id: Network.RequestId
    ):
        super().__init__(
            requestId=request_id
        )


class SearchInResponseBodyInput(InputModel):

    requestId: Network.RequestId  # deprecated
    query: str  # deprecated
    caseSensitive: bool | None = None  # deprecated
    isRegex: bool | None = None  # deprecated


class SearchInResponseBodyOutput(OutputModel):

    result: list[Debugger.SearchMatch]  # deprecated


class SearchInResponseBody(CDPMethod[SearchInResponseBodyOutput]):  # experimental deprecated
    """ Searches for given string in response content. """

    INPUT_VALIDATOR = SearchInResponseBodyInput
    OUTPUT_VALIDATOR = SearchInResponseBodyOutput

    def __init__(
        self,
        *,
        request_id: Network.RequestId,
        query: str,
        case_sensitive: bool | None = None,
        is_regex: bool | None = None
    ):
        super().__init__(
            requestId=request_id,
            query=query,
            caseSensitive=case_sensitive,
            isRegex=is_regex
        )


class SetBlockedURLsInput(InputModel):

    urls: list[str]  # deprecated


class SetBlockedURLs(CDPMethod[None]):  # experimental deprecated
    """ Blocks URLs from loading. """

    INPUT_VALIDATOR = SetBlockedURLsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        urls: list[str]
    ):
        super().__init__(
            urls=urls
        )


class SetBypassServiceWorkerInput(InputModel):

    bypass: bool  # deprecated


class SetBypassServiceWorker(CDPMethod[None]):  # deprecated
    """ Toggles ignoring of service worker for each request. """

    INPUT_VALIDATOR = SetBypassServiceWorkerInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        bypass: bool
    ):
        super().__init__(
            bypass=bypass
        )


class SetCacheDisabledInput(InputModel):

    cacheDisabled: bool  # deprecated


class SetCacheDisabled(CDPMethod[None]):  # deprecated
    """ Toggles ignoring cache for each request. If `true`, cache will not be used. """

    INPUT_VALIDATOR = SetCacheDisabledInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        cache_disabled: bool
    ):
        super().__init__(
            cacheDisabled=cache_disabled
        )


class SetCookieInput(InputModel):

    name: str  # deprecated
    value: str  # deprecated
    url: str | None = None  # deprecated
    domain: str | None = None  # deprecated
    path: str | None = None  # deprecated
    secure: bool | None = None  # deprecated
    httpOnly: bool | None = None  # deprecated
    sameSite: Network.CookieSameSite | None = None  # deprecated
    expires: Network.TimeSinceEpoch | None = None  # deprecated
    priority: Network.CookiePriority | None = None  # experimental deprecated
    sameParty: bool | None = None  # experimental deprecated
    sourceScheme: Network.CookieSourceScheme | None = None  # experimental deprecated
    sourcePort: int | None = None  # experimental deprecated
    partitionKey: Network.CookiePartitionKey | None = None  # experimental deprecated


class SetCookieOutput(OutputModel):

    success: bool  # deprecated


class SetCookie(CDPMethod[SetCookieOutput]):  # deprecated
    """ Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. """

    INPUT_VALIDATOR = SetCookieInput
    OUTPUT_VALIDATOR = SetCookieOutput

    def __init__(
        self,
        *,
        name: str,
        value: str,
        url: str | None = None,
        domain: str | None = None,
        path: str | None = None,
        secure: bool | None = None,
        http_only: bool | None = None,
        same_site: Network.CookieSameSite | None = None,
        expires: Network.TimeSinceEpoch | None = None,
        priority: Network.CookiePriority | None = None,
        same_party: bool | None = None,
        source_scheme: Network.CookieSourceScheme | None = None,
        source_port: int | None = None,
        partition_key: Network.CookiePartitionKey | None = None
    ):
        super().__init__(
            name=name,
            value=value,
            url=url,
            domain=domain,
            path=path,
            secure=secure,
            httpOnly=http_only,
            sameSite=same_site,
            expires=expires,
            priority=priority,
            sameParty=same_party,
            sourceScheme=source_scheme,
            sourcePort=source_port,
            partitionKey=partition_key
        )


class SetCookiesInput(InputModel):

    cookies: list[Network.CookieParam]  # deprecated


class SetCookies(CDPMethod[None]):  # deprecated
    """ Sets given cookies. """

    INPUT_VALIDATOR = SetCookiesInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        cookies: list[Network.CookieParam]
    ):
        super().__init__(
            cookies=cookies
        )


class SetExtraHTTPHeadersInput(InputModel):

    headers: Network.Headers  # deprecated


class SetExtraHTTPHeaders(CDPMethod[None]):  # deprecated
    """ Specifies whether to always send extra HTTP headers with the requests from this page. """

    INPUT_VALIDATOR = SetExtraHTTPHeadersInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        headers: Network.Headers
    ):
        super().__init__(
            headers=headers
        )


class SetAttachDebugStackInput(InputModel):

    enabled: bool  # deprecated


class SetAttachDebugStack(CDPMethod[None]):  # experimental deprecated
    """ Specifies whether to attach a page script stack id in requests """

    INPUT_VALIDATOR = SetAttachDebugStackInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        enabled: bool
    ):
        super().__init__(
            enabled=enabled
        )


class SetRequestInterceptionInput(InputModel):

    patterns: list[Network.RequestPattern]  # deprecated


class SetRequestInterception(CDPMethod[None]):  # experimental deprecated
    """ Sets the requests to intercept that match the provided patterns and optionally resource types.
    Deprecated, please use Fetch.enable instead. """

    INPUT_VALIDATOR = SetRequestInterceptionInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        patterns: list[Network.RequestPattern]
    ):
        super().__init__(
            patterns=patterns
        )


class SetUserAgentOverrideInput(InputModel):

    userAgent: str  # deprecated
    acceptLanguage: str | None = None  # deprecated
    platform: str | None = None  # deprecated
    userAgentMetadata: Emulation.UserAgentMetadata | None = None  # experimental deprecated


class SetUserAgentOverride(CDPMethod[None]):  # deprecated
    """ Allows overriding user agent with the given string. """

    INPUT_VALIDATOR = SetUserAgentOverrideInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        user_agent: str,
        accept_language: str | None = None,
        platform: str | None = None,
        user_agent_metadata: Emulation.UserAgentMetadata | None = None
    ):
        super().__init__(
            userAgent=user_agent,
            acceptLanguage=accept_language,
            platform=platform,
            userAgentMetadata=user_agent_metadata
        )


class StreamResourceContentInput(InputModel):

    requestId: Network.RequestId  # deprecated


class StreamResourceContentOutput(OutputModel):

    bufferedData: str  # deprecated


class StreamResourceContent(CDPMethod[StreamResourceContentOutput]):  # experimental deprecated
    """ Enables streaming of the response for the given requestId.
    If enabled, the dataReceived event contains the data that was received during streaming. """

    INPUT_VALIDATOR = StreamResourceContentInput
    OUTPUT_VALIDATOR = StreamResourceContentOutput

    def __init__(
        self,
        *,
        request_id: Network.RequestId
    ):
        super().__init__(
            requestId=request_id
        )


class GetSecurityIsolationStatusInput(InputModel):

    frameId: Page.FrameId | None = None  # deprecated


class GetSecurityIsolationStatusOutput(OutputModel):

    status: Network.SecurityIsolationStatus


class GetSecurityIsolationStatus(CDPMethod[GetSecurityIsolationStatusOutput]):  # experimental deprecated
    """ Returns information about the COEP/COOP isolation status. """

    INPUT_VALIDATOR = GetSecurityIsolationStatusInput
    OUTPUT_VALIDATOR = GetSecurityIsolationStatusOutput

    def __init__(
        self,
        *,
        frame_id: Page.FrameId | None = None
    ):
        super().__init__(
            frameId=frame_id
        )


class EnableReportingApiInput(InputModel):

    enable: bool  # deprecated


class EnableReportingApi(CDPMethod[None]):  # experimental deprecated
    """ Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client.
    Enabling triggers 'reportingApiReportAdded' for all existing reports. """

    INPUT_VALIDATOR = EnableReportingApiInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        enable: bool
    ):
        super().__init__(
            enable=enable
        )


class LoadNetworkResourceInput(InputModel):

    frameId: Page.FrameId | None = None  # deprecated
    url: str  # deprecated
    options: Network.LoadNetworkResourceOptions  # deprecated


class LoadNetworkResourceOutput(OutputModel):

    resource: Network.LoadNetworkResourcePageResult


class LoadNetworkResource(CDPMethod[LoadNetworkResourceOutput]):  # experimental deprecated
    """ Fetches the resource and returns the content. """

    INPUT_VALIDATOR = LoadNetworkResourceInput
    OUTPUT_VALIDATOR = LoadNetworkResourceOutput

    def __init__(
        self,
        *,
        frame_id: Page.FrameId | None = None,
        url: str,
        options: Network.LoadNetworkResourceOptions
    ):
        super().__init__(
            frameId=frame_id,
            url=url,
            options=options
        )


class SetCookieControlsInput(InputModel):

    enableThirdPartyCookieRestriction: bool  # deprecated
    disableThirdPartyCookieMetadata: bool  # deprecated
    disableThirdPartyCookieHeuristics: bool  # deprecated


class SetCookieControls(CDPMethod[None]):  # experimental deprecated
    """ Sets Controls for third-party cookie access
    Page reload is required before the new cookie behavior will be observed """

    INPUT_VALIDATOR = SetCookieControlsInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        enable_third_party_cookie_restriction: bool,
        disable_third_party_cookie_metadata: bool,
        disable_third_party_cookie_heuristics: bool
    ):
        super().__init__(
            enableThirdPartyCookieRestriction=enable_third_party_cookie_restriction,
            disableThirdPartyCookieMetadata=disable_third_party_cookie_metadata,
            disableThirdPartyCookieHeuristics=disable_third_party_cookie_heuristics
        )
