# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pyformat: disable

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from .types import (
    AfterErrorContext,
    AfterParseErrorContext,
    AfterSuccessContext,
    BeforeRequestContext,
)
from abc import ABC, abstractmethod
import httpx
from typing import Optional, Tuple, Union


class AsyncBeforeRequestHook(ABC):
    @abstractmethod
    async def before_request(
        self, hook_ctx: BeforeRequestContext, request: httpx.Request
    ) -> Union[httpx.Request, Exception]:
        pass


class AsyncAfterSuccessHook(ABC):
    @abstractmethod
    async def after_success(
        self, hook_ctx: AfterSuccessContext, response: httpx.Response
    ) -> Union[httpx.Response, Exception]:
        pass


class AsyncAfterErrorHook(ABC):
    @abstractmethod
    async def after_error(
        self,
        hook_ctx: AfterErrorContext,
        response: Optional[httpx.Response],
        error: Optional[Exception],
    ) -> Union[Tuple[Optional[httpx.Response], Optional[Exception]], Exception]:
        pass


class AsyncAfterParseErrorHook(ABC):
    @abstractmethod
    async def after_parse_error(
        self,
        hook_ctx: AfterParseErrorContext,
        response: httpx.Response,
        error: Exception,
    ) -> Exception:
        pass


class AsyncHooks(ABC):
    @abstractmethod
    def register_before_request_hook(self, hook: AsyncBeforeRequestHook):
        pass

    @abstractmethod
    def register_after_success_hook(self, hook: AsyncAfterSuccessHook):
        pass

    @abstractmethod
    def register_after_error_hook(self, hook: AsyncAfterErrorHook):
        pass

    @abstractmethod
    def register_after_parse_error_hook(self, hook: AsyncAfterParseErrorHook):
        pass
