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


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

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

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


class DeleteCacheInput(InputModel):

    cacheId: CacheStorage.CacheId


class DeleteCache(CDPMethod[None]):
    """ Deletes a cache. """

    INPUT_VALIDATOR = DeleteCacheInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        cache_id: CacheStorage.CacheId
    ):
        super().__init__(
            cacheId=cache_id
        )


class DeleteEntryInput(InputModel):

    cacheId: CacheStorage.CacheId
    request: str


class DeleteEntry(CDPMethod[None]):
    """ Deletes a cache entry. """

    INPUT_VALIDATOR = DeleteEntryInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        cache_id: CacheStorage.CacheId,
        request: str
    ):
        super().__init__(
            cacheId=cache_id,
            request=request
        )


class RequestCacheNamesInput(InputModel):

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


class RequestCacheNamesOutput(OutputModel):

    caches: list[CacheStorage.Cache]


class RequestCacheNames(CDPMethod[RequestCacheNamesOutput]):
    """ Requests cache names. """

    INPUT_VALIDATOR = RequestCacheNamesInput
    OUTPUT_VALIDATOR = RequestCacheNamesOutput

    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
        )


class RequestCachedResponseInput(InputModel):

    cacheId: CacheStorage.CacheId
    requestURL: str
    requestHeaders: list[CacheStorage.Header]


class RequestCachedResponseOutput(OutputModel):

    response: CacheStorage.CachedResponse


class RequestCachedResponse(CDPMethod[RequestCachedResponseOutput]):
    """ Fetches cache entry. """

    INPUT_VALIDATOR = RequestCachedResponseInput
    OUTPUT_VALIDATOR = RequestCachedResponseOutput

    def __init__(
        self,
        *,
        cache_id: CacheStorage.CacheId,
        request_url: str,
        request_headers: list[CacheStorage.Header]
    ):
        super().__init__(
            cacheId=cache_id,
            requestURL=request_url,
            requestHeaders=request_headers
        )


class RequestEntriesInput(InputModel):

    cacheId: CacheStorage.CacheId
    skipCount: int | None = None
    pageSize: int | None = None
    pathFilter: str | None = None


class RequestEntriesOutput(OutputModel):

    cacheDataEntries: list[CacheStorage.DataEntry]
    returnCount: float


class RequestEntries(CDPMethod[RequestEntriesOutput]):
    """ Requests data from cache. """

    INPUT_VALIDATOR = RequestEntriesInput
    OUTPUT_VALIDATOR = RequestEntriesOutput

    def __init__(
        self,
        *,
        cache_id: CacheStorage.CacheId,
        skip_count: int | None = None,
        page_size: int | None = None,
        path_filter: str | None = None
    ):
        super().__init__(
            cacheId=cache_id,
            skipCount=skip_count,
            pageSize=page_size,
            pathFilter=path_filter
        )
