# DO NOT EDIT THIS FILE!
#
# This code is generated off of PyCDP modules. If you need to make
# changes, edit the generator and regenerate all of the modules.

from __future__ import annotations
import typing

from ..context import get_connection_context, get_session_context

import cdp.dom_debugger
from cdp.dom_debugger import (
    DOMBreakpointType,
    EventListener
)


async def get_event_listeners(
        object_id: cdp.runtime.RemoteObjectId,
        depth: typing.Optional[int] = None,
        pierce: typing.Optional[bool] = None
    ) -> typing.List[EventListener]:
    '''
    Returns event listeners of the given object.

    :param object_id: Identifier of the object to return listeners for.
    :param depth: *(Optional)* The maximum depth at which Node children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
    :param pierce: *(Optional)* Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Reports listeners for all contexts if pierce is enabled.
    :returns: Array of relevant listeners.
    '''
    session = get_session_context('dom_debugger.get_event_listeners')
    return await session.execute(cdp.dom_debugger.get_event_listeners(object_id, depth, pierce))


async def remove_dom_breakpoint(
        node_id: cdp.dom.NodeId,
        type_: DOMBreakpointType
    ) -> None:
    '''
    Removes DOM breakpoint that was set using ``setDOMBreakpoint``.

    :param node_id: Identifier of the node to remove breakpoint from.
    :param type_: Type of the breakpoint to remove.
    '''
    session = get_session_context('dom_debugger.remove_dom_breakpoint')
    return await session.execute(cdp.dom_debugger.remove_dom_breakpoint(node_id, type_))


async def remove_event_listener_breakpoint(
        event_name: str,
        target_name: typing.Optional[str] = None
    ) -> None:
    '''
    Removes breakpoint on particular DOM event.

    :param event_name: Event name.
    :param target_name: **(EXPERIMENTAL)** *(Optional)* EventTarget interface name.
    '''
    session = get_session_context('dom_debugger.remove_event_listener_breakpoint')
    return await session.execute(cdp.dom_debugger.remove_event_listener_breakpoint(event_name, target_name))


async def remove_instrumentation_breakpoint(
        event_name: str
    ) -> None:
    '''
    Removes breakpoint on particular native event.

    **EXPERIMENTAL**

    :param event_name: Instrumentation name to stop on.
    '''
    session = get_session_context('dom_debugger.remove_instrumentation_breakpoint')
    return await session.execute(cdp.dom_debugger.remove_instrumentation_breakpoint(event_name))


async def remove_xhr_breakpoint(
        url: str
    ) -> None:
    '''
    Removes breakpoint from XMLHttpRequest.

    :param url: Resource URL substring.
    '''
    session = get_session_context('dom_debugger.remove_xhr_breakpoint')
    return await session.execute(cdp.dom_debugger.remove_xhr_breakpoint(url))


async def set_dom_breakpoint(
        node_id: cdp.dom.NodeId,
        type_: DOMBreakpointType
    ) -> None:
    '''
    Sets breakpoint on particular operation with DOM.

    :param node_id: Identifier of the node to set breakpoint on.
    :param type_: Type of the operation to stop upon.
    '''
    session = get_session_context('dom_debugger.set_dom_breakpoint')
    return await session.execute(cdp.dom_debugger.set_dom_breakpoint(node_id, type_))


async def set_event_listener_breakpoint(
        event_name: str,
        target_name: typing.Optional[str] = None
    ) -> None:
    '''
    Sets breakpoint on particular DOM event.

    :param event_name: DOM Event name to stop on (any DOM event will do).
    :param target_name: **(EXPERIMENTAL)** *(Optional)* EventTarget interface name to stop on. If equal to ```"*"``` or not provided, will stop on any EventTarget.
    '''
    session = get_session_context('dom_debugger.set_event_listener_breakpoint')
    return await session.execute(cdp.dom_debugger.set_event_listener_breakpoint(event_name, target_name))


async def set_instrumentation_breakpoint(
        event_name: str
    ) -> None:
    '''
    Sets breakpoint on particular native event.

    **EXPERIMENTAL**

    :param event_name: Instrumentation name to stop on.
    '''
    session = get_session_context('dom_debugger.set_instrumentation_breakpoint')
    return await session.execute(cdp.dom_debugger.set_instrumentation_breakpoint(event_name))


async def set_xhr_breakpoint(
        url: str
    ) -> None:
    '''
    Sets breakpoint on XMLHttpRequest.

    :param url: Resource URL substring. All XHRs having this substring in the URL will get stopped upon.
    '''
    session = get_session_context('dom_debugger.set_xhr_breakpoint')
    return await session.execute(cdp.dom_debugger.set_xhr_breakpoint(url))
