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


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

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

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


class ClearObjectStoreInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None
    databaseName: str
    objectStoreName: str


class ClearObjectStore(CDPMethod[None]):
    """ Clears all entries from an object store. """

    INPUT_VALIDATOR = ClearObjectStoreInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None,
        database_name: str,
        object_store_name: str
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket,
            databaseName=database_name,
            objectStoreName=object_store_name
        )


class DeleteDatabaseInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None
    databaseName: str


class DeleteDatabase(CDPMethod[None]):
    """ Deletes a database. """

    INPUT_VALIDATOR = DeleteDatabaseInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None,
        database_name: str
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket,
            databaseName=database_name
        )


class DeleteObjectStoreEntriesInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None
    databaseName: str
    objectStoreName: str
    keyRange: IndexedDB.KeyRange


class DeleteObjectStoreEntries(CDPMethod[None]):
    """ Delete a range of entries from an object store """

    INPUT_VALIDATOR = DeleteObjectStoreEntriesInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None,
        database_name: str,
        object_store_name: str,
        key_range: IndexedDB.KeyRange
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket,
            databaseName=database_name,
            objectStoreName=object_store_name,
            keyRange=key_range
        )


class Disable(CDPMethod[None]):
    """ Disables events from backend. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class Enable(CDPMethod[None]):
    """ Enables events from backend. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class RequestDataInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None
    databaseName: str
    objectStoreName: str
    indexName: str | None = None
    skipCount: int
    pageSize: int
    keyRange: IndexedDB.KeyRange | None = None


class RequestDataOutput(OutputModel):

    objectStoreDataEntries: list[IndexedDB.DataEntry]
    hasMore: bool


class RequestData(CDPMethod[RequestDataOutput]):
    """ Requests data from object store or index. """

    INPUT_VALIDATOR = RequestDataInput
    OUTPUT_VALIDATOR = RequestDataOutput

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None,
        database_name: str,
        object_store_name: str,
        index_name: str | None = None,
        skip_count: int,
        page_size: int,
        key_range: IndexedDB.KeyRange | None = None
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket,
            databaseName=database_name,
            objectStoreName=object_store_name,
            indexName=index_name,
            skipCount=skip_count,
            pageSize=page_size,
            keyRange=key_range
        )


class GetMetadataInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None
    databaseName: str
    objectStoreName: str


class GetMetadataOutput(OutputModel):

    entriesCount: float
    keyGeneratorValue: float


class GetMetadata(CDPMethod[GetMetadataOutput]):
    """ Gets metadata of an object store. """

    INPUT_VALIDATOR = GetMetadataInput
    OUTPUT_VALIDATOR = GetMetadataOutput

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None,
        database_name: str,
        object_store_name: str
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket,
            databaseName=database_name,
            objectStoreName=object_store_name
        )


class RequestDatabaseInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None
    databaseName: str


class RequestDatabaseOutput(OutputModel):

    databaseWithObjectStores: IndexedDB.DatabaseWithObjectStores


class RequestDatabase(CDPMethod[RequestDatabaseOutput]):
    """ Requests database with given name in given frame. """

    INPUT_VALIDATOR = RequestDatabaseInput
    OUTPUT_VALIDATOR = RequestDatabaseOutput

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None,
        database_name: str
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket,
            databaseName=database_name
        )


class RequestDatabaseNamesInput(InputModel):

    securityOrigin: str | None = None
    storageKey: str | None = None
    storageBucket: Storage.StorageBucket | None = None


class RequestDatabaseNamesOutput(OutputModel):

    databaseNames: list[str]


class RequestDatabaseNames(CDPMethod[RequestDatabaseNamesOutput]):
    """ Requests database names for given security origin. """

    INPUT_VALIDATOR = RequestDatabaseNamesInput
    OUTPUT_VALIDATOR = RequestDatabaseNamesOutput

    def __init__(
        self,
        *,
        security_origin: str | None = None,
        storage_key: str | None = None,
        storage_bucket: Storage.StorageBucket | None = None
    ):
        super().__init__(
            securityOrigin=security_origin,
            storageKey=storage_key,
            storageBucket=storage_bucket
        )
