# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Type, Iterable, Optional, cast
from typing_extensions import Literal

import httpx

from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ......_utils import path_template, maybe_transform, async_maybe_transform
from ......_compat import cached_property
from ......_resource import SyncAPIResource, AsyncAPIResource
from ......_response import (
    to_raw_response_wrapper,
    to_streamed_response_wrapper,
    async_to_raw_response_wrapper,
    async_to_streamed_response_wrapper,
)
from ......_wrappers import ResultWrapper
from ......pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ......_base_client import AsyncPaginator, make_request_options
from ......types.zero_trust.access.ai_controls.mcp import server_list_params, server_create_params, server_update_params
from ......types.zero_trust.access.ai_controls.mcp.server_list_response import ServerListResponse
from ......types.zero_trust.access.ai_controls.mcp.server_read_response import ServerReadResponse
from ......types.zero_trust.access.ai_controls.mcp.server_sync_response import ServerSyncResponse
from ......types.zero_trust.access.ai_controls.mcp.server_create_response import ServerCreateResponse
from ......types.zero_trust.access.ai_controls.mcp.server_delete_response import ServerDeleteResponse
from ......types.zero_trust.access.ai_controls.mcp.server_update_response import ServerUpdateResponse

__all__ = ["ServersResource", "AsyncServersResource"]


class ServersResource(SyncAPIResource):
    @cached_property
    def with_raw_response(self) -> ServersResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
        """
        return ServersResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> ServersResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
        """
        return ServersResourceWithStreamingResponse(self)

    def create(
        self,
        *,
        account_id: str,
        id: str,
        auth_type: Literal["oauth", "bearer", "unauthenticated"],
        hostname: str,
        name: str,
        auth_credentials: str | Omit = omit,
        description: Optional[str] | Omit = omit,
        is_shared_oauth_callback_enabled: bool | Omit = omit,
        secure_web_gateway: bool | Omit = omit,
        updated_prompts: Iterable[server_create_params.UpdatedPrompt] | Omit = omit,
        updated_tools: Iterable[server_create_params.UpdatedTool] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerCreateResponse:
        """
        Creates a new MCP portal for managing AI tool access through Cloudflare Access.

        Args:
          id: server id

          is_shared_oauth_callback_enabled: When true, the gateway worker uses the shared Cloudflare-owned OAuth callback
              endpoint as the redirect_uri for upstream on-behalf OAuth, instead of the
              customer portal hostname. New public server creates default to true; existing
              servers default to false from migration until explicitly updated. Effective
              behavior is gated by the gateway worker's per-env rollout mode KV key.

          secure_web_gateway: Route outbound traffic to this MCP server through Zero Trust Secure Web Gateway

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        return self._post(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id),
            body=maybe_transform(
                {
                    "id": id,
                    "auth_type": auth_type,
                    "hostname": hostname,
                    "name": name,
                    "auth_credentials": auth_credentials,
                    "description": description,
                    "is_shared_oauth_callback_enabled": is_shared_oauth_callback_enabled,
                    "secure_web_gateway": secure_web_gateway,
                    "updated_prompts": updated_prompts,
                    "updated_tools": updated_tools,
                },
                server_create_params.ServerCreateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerCreateResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerCreateResponse], ResultWrapper[ServerCreateResponse]),
        )

    def update(
        self,
        id: str,
        *,
        account_id: str,
        auth_credentials: str | Omit = omit,
        description: Optional[str] | Omit = omit,
        is_shared_oauth_callback_enabled: bool | Omit = omit,
        name: str | Omit = omit,
        secure_web_gateway: bool | Omit = omit,
        updated_prompts: Iterable[server_update_params.UpdatedPrompt] | Omit = omit,
        updated_tools: Iterable[server_update_params.UpdatedTool] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerUpdateResponse:
        """
        Updates an MCP portal configuration.

        Args:
          id: server id

          is_shared_oauth_callback_enabled: When true, the gateway worker uses the shared Cloudflare-owned OAuth callback
              endpoint as the redirect_uri for upstream on-behalf OAuth, instead of the
              customer portal hostname. New public server creates default to true; existing
              servers default to false from migration until explicitly updated. Effective
              behavior is gated by the gateway worker's per-env rollout mode KV key.

          secure_web_gateway: Route outbound traffic to this MCP server through Zero Trust Secure Web Gateway

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return self._put(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id),
            body=maybe_transform(
                {
                    "auth_credentials": auth_credentials,
                    "description": description,
                    "is_shared_oauth_callback_enabled": is_shared_oauth_callback_enabled,
                    "name": name,
                    "secure_web_gateway": secure_web_gateway,
                    "updated_prompts": updated_prompts,
                    "updated_tools": updated_tools,
                },
                server_update_params.ServerUpdateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerUpdateResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerUpdateResponse], ResultWrapper[ServerUpdateResponse]),
        )

    def list(
        self,
        *,
        account_id: str,
        page: int | Omit = omit,
        per_page: int | Omit = omit,
        search: str | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> SyncV4PagePaginationArray[ServerListResponse]:
        """
        Lists all MCP portals configured for the account.

        Args:
          search: Search by id, name

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        return self._get_api_list(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id),
            page=SyncV4PagePaginationArray[ServerListResponse],
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "page": page,
                        "per_page": per_page,
                        "search": search,
                    },
                    server_list_params.ServerListParams,
                ),
            ),
            model=ServerListResponse,
        )

    def delete(
        self,
        id: str,
        *,
        account_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerDeleteResponse:
        """
        Deletes an MCP portal from the account.

        Args:
          id: server id

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return self._delete(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerDeleteResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerDeleteResponse], ResultWrapper[ServerDeleteResponse]),
        )

    def read(
        self,
        id: str,
        *,
        account_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerReadResponse:
        """
        Retrieves gateway configuration for MCP portals.

        Args:
          id: server id

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return self._get(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerReadResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerReadResponse], ResultWrapper[ServerReadResponse]),
        )

    def sync(
        self,
        id: str,
        *,
        account_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerSyncResponse:
        """
        Syncs an MCP server's capabilities and returns the updated server state,
        including any connection errors.

        Args:
          id: portal id

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return self._post(
            path_template(
                "/accounts/{account_id}/access/ai-controls/mcp/servers/{id}/sync", account_id=account_id, id=id
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerSyncResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerSyncResponse], ResultWrapper[ServerSyncResponse]),
        )


class AsyncServersResource(AsyncAPIResource):
    @cached_property
    def with_raw_response(self) -> AsyncServersResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
        """
        return AsyncServersResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncServersResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
        """
        return AsyncServersResourceWithStreamingResponse(self)

    async def create(
        self,
        *,
        account_id: str,
        id: str,
        auth_type: Literal["oauth", "bearer", "unauthenticated"],
        hostname: str,
        name: str,
        auth_credentials: str | Omit = omit,
        description: Optional[str] | Omit = omit,
        is_shared_oauth_callback_enabled: bool | Omit = omit,
        secure_web_gateway: bool | Omit = omit,
        updated_prompts: Iterable[server_create_params.UpdatedPrompt] | Omit = omit,
        updated_tools: Iterable[server_create_params.UpdatedTool] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerCreateResponse:
        """
        Creates a new MCP portal for managing AI tool access through Cloudflare Access.

        Args:
          id: server id

          is_shared_oauth_callback_enabled: When true, the gateway worker uses the shared Cloudflare-owned OAuth callback
              endpoint as the redirect_uri for upstream on-behalf OAuth, instead of the
              customer portal hostname. New public server creates default to true; existing
              servers default to false from migration until explicitly updated. Effective
              behavior is gated by the gateway worker's per-env rollout mode KV key.

          secure_web_gateway: Route outbound traffic to this MCP server through Zero Trust Secure Web Gateway

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        return await self._post(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id),
            body=await async_maybe_transform(
                {
                    "id": id,
                    "auth_type": auth_type,
                    "hostname": hostname,
                    "name": name,
                    "auth_credentials": auth_credentials,
                    "description": description,
                    "is_shared_oauth_callback_enabled": is_shared_oauth_callback_enabled,
                    "secure_web_gateway": secure_web_gateway,
                    "updated_prompts": updated_prompts,
                    "updated_tools": updated_tools,
                },
                server_create_params.ServerCreateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerCreateResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerCreateResponse], ResultWrapper[ServerCreateResponse]),
        )

    async def update(
        self,
        id: str,
        *,
        account_id: str,
        auth_credentials: str | Omit = omit,
        description: Optional[str] | Omit = omit,
        is_shared_oauth_callback_enabled: bool | Omit = omit,
        name: str | Omit = omit,
        secure_web_gateway: bool | Omit = omit,
        updated_prompts: Iterable[server_update_params.UpdatedPrompt] | Omit = omit,
        updated_tools: Iterable[server_update_params.UpdatedTool] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerUpdateResponse:
        """
        Updates an MCP portal configuration.

        Args:
          id: server id

          is_shared_oauth_callback_enabled: When true, the gateway worker uses the shared Cloudflare-owned OAuth callback
              endpoint as the redirect_uri for upstream on-behalf OAuth, instead of the
              customer portal hostname. New public server creates default to true; existing
              servers default to false from migration until explicitly updated. Effective
              behavior is gated by the gateway worker's per-env rollout mode KV key.

          secure_web_gateway: Route outbound traffic to this MCP server through Zero Trust Secure Web Gateway

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return await self._put(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id),
            body=await async_maybe_transform(
                {
                    "auth_credentials": auth_credentials,
                    "description": description,
                    "is_shared_oauth_callback_enabled": is_shared_oauth_callback_enabled,
                    "name": name,
                    "secure_web_gateway": secure_web_gateway,
                    "updated_prompts": updated_prompts,
                    "updated_tools": updated_tools,
                },
                server_update_params.ServerUpdateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerUpdateResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerUpdateResponse], ResultWrapper[ServerUpdateResponse]),
        )

    def list(
        self,
        *,
        account_id: str,
        page: int | Omit = omit,
        per_page: int | Omit = omit,
        search: str | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> AsyncPaginator[ServerListResponse, AsyncV4PagePaginationArray[ServerListResponse]]:
        """
        Lists all MCP portals configured for the account.

        Args:
          search: Search by id, name

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        return self._get_api_list(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers", account_id=account_id),
            page=AsyncV4PagePaginationArray[ServerListResponse],
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "page": page,
                        "per_page": per_page,
                        "search": search,
                    },
                    server_list_params.ServerListParams,
                ),
            ),
            model=ServerListResponse,
        )

    async def delete(
        self,
        id: str,
        *,
        account_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerDeleteResponse:
        """
        Deletes an MCP portal from the account.

        Args:
          id: server id

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return await self._delete(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerDeleteResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerDeleteResponse], ResultWrapper[ServerDeleteResponse]),
        )

    async def read(
        self,
        id: str,
        *,
        account_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerReadResponse:
        """
        Retrieves gateway configuration for MCP portals.

        Args:
          id: server id

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return await self._get(
            path_template("/accounts/{account_id}/access/ai-controls/mcp/servers/{id}", account_id=account_id, id=id),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerReadResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerReadResponse], ResultWrapper[ServerReadResponse]),
        )

    async def sync(
        self,
        id: str,
        *,
        account_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> ServerSyncResponse:
        """
        Syncs an MCP server's capabilities and returns the updated server state,
        including any connection errors.

        Args:
          id: portal id

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not account_id:
            raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
        if not id:
            raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
        return await self._post(
            path_template(
                "/accounts/{account_id}/access/ai-controls/mcp/servers/{id}/sync", account_id=account_id, id=id
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[ServerSyncResponse]._unwrapper,
            ),
            cast_to=cast(Type[ServerSyncResponse], ResultWrapper[ServerSyncResponse]),
        )


class ServersResourceWithRawResponse:
    def __init__(self, servers: ServersResource) -> None:
        self._servers = servers

        self.create = to_raw_response_wrapper(
            servers.create,
        )
        self.update = to_raw_response_wrapper(
            servers.update,
        )
        self.list = to_raw_response_wrapper(
            servers.list,
        )
        self.delete = to_raw_response_wrapper(
            servers.delete,
        )
        self.read = to_raw_response_wrapper(
            servers.read,
        )
        self.sync = to_raw_response_wrapper(
            servers.sync,
        )


class AsyncServersResourceWithRawResponse:
    def __init__(self, servers: AsyncServersResource) -> None:
        self._servers = servers

        self.create = async_to_raw_response_wrapper(
            servers.create,
        )
        self.update = async_to_raw_response_wrapper(
            servers.update,
        )
        self.list = async_to_raw_response_wrapper(
            servers.list,
        )
        self.delete = async_to_raw_response_wrapper(
            servers.delete,
        )
        self.read = async_to_raw_response_wrapper(
            servers.read,
        )
        self.sync = async_to_raw_response_wrapper(
            servers.sync,
        )


class ServersResourceWithStreamingResponse:
    def __init__(self, servers: ServersResource) -> None:
        self._servers = servers

        self.create = to_streamed_response_wrapper(
            servers.create,
        )
        self.update = to_streamed_response_wrapper(
            servers.update,
        )
        self.list = to_streamed_response_wrapper(
            servers.list,
        )
        self.delete = to_streamed_response_wrapper(
            servers.delete,
        )
        self.read = to_streamed_response_wrapper(
            servers.read,
        )
        self.sync = to_streamed_response_wrapper(
            servers.sync,
        )


class AsyncServersResourceWithStreamingResponse:
    def __init__(self, servers: AsyncServersResource) -> None:
        self._servers = servers

        self.create = async_to_streamed_response_wrapper(
            servers.create,
        )
        self.update = async_to_streamed_response_wrapper(
            servers.update,
        )
        self.list = async_to_streamed_response_wrapper(
            servers.list,
        )
        self.delete = async_to_streamed_response_wrapper(
            servers.delete,
        )
        self.read = async_to_streamed_response_wrapper(
            servers.read,
        )
        self.sync = async_to_streamed_response_wrapper(
            servers.sync,
        )
