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

from __future__ import annotations

import httpx

from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given
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 ..._base_client import make_request_options
from ...types.dataframer.red_team_spec_list_response import RedTeamSpecListResponse
from ...types.dataframer.red_team_spec_create_response import RedTeamSpecCreateResponse
from ...types.dataframer.red_team_spec_update_response import RedTeamSpecUpdateResponse
from ...types.dataframer.red_team_spec_retrieve_response import RedTeamSpecRetrieveResponse

__all__ = ["RedTeamSpecsResource", "AsyncRedTeamSpecsResource"]


class RedTeamSpecsResource(SyncAPIResource):
    @cached_property
    def with_raw_response(self) -> RedTeamSpecsResourceWithRawResponse:
        """
        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/aimonlabs/dataframer-python-sdk#accessing-raw-response-data-eg-headers
        """
        return RedTeamSpecsResourceWithRawResponse(self)

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

        For more information, see https://www.github.com/aimonlabs/dataframer-python-sdk#with_streaming_response
        """
        return RedTeamSpecsResourceWithStreamingResponse(self)

    def create(
        self,
        *,
        # 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,
    ) -> RedTeamSpecCreateResponse:
        """Create a new red team spec"""
        return self._post(
            "/api/dataframer/red-team-specs/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecCreateResponse,
        )

    def retrieve(
        self,
        spec_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,
    ) -> RedTeamSpecRetrieveResponse:
        """
        Retrieve a red team spec

        Args:
          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 spec_id:
            raise ValueError(f"Expected a non-empty value for `spec_id` but received {spec_id!r}")
        return self._get(
            f"/api/dataframer/red-team-specs/{spec_id}/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecRetrieveResponse,
        )

    def update(
        self,
        spec_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,
    ) -> RedTeamSpecUpdateResponse:
        """
        Update a red team spec

        Args:
          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 spec_id:
            raise ValueError(f"Expected a non-empty value for `spec_id` but received {spec_id!r}")
        return self._patch(
            f"/api/dataframer/red-team-specs/{spec_id}/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecUpdateResponse,
        )

    def list(
        self,
        *,
        # 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,
    ) -> RedTeamSpecListResponse:
        """List all red team specs for the user's company"""
        return self._get(
            "/api/dataframer/red-team-specs/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecListResponse,
        )

    def delete(
        self,
        spec_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,
    ) -> None:
        """
        Delete a red team spec

        Args:
          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 spec_id:
            raise ValueError(f"Expected a non-empty value for `spec_id` but received {spec_id!r}")
        extra_headers = {"Accept": "*/*", **(extra_headers or {})}
        return self._delete(
            f"/api/dataframer/red-team-specs/{spec_id}/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=NoneType,
        )


class AsyncRedTeamSpecsResource(AsyncAPIResource):
    @cached_property
    def with_raw_response(self) -> AsyncRedTeamSpecsResourceWithRawResponse:
        """
        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/aimonlabs/dataframer-python-sdk#accessing-raw-response-data-eg-headers
        """
        return AsyncRedTeamSpecsResourceWithRawResponse(self)

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

        For more information, see https://www.github.com/aimonlabs/dataframer-python-sdk#with_streaming_response
        """
        return AsyncRedTeamSpecsResourceWithStreamingResponse(self)

    async def create(
        self,
        *,
        # 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,
    ) -> RedTeamSpecCreateResponse:
        """Create a new red team spec"""
        return await self._post(
            "/api/dataframer/red-team-specs/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecCreateResponse,
        )

    async def retrieve(
        self,
        spec_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,
    ) -> RedTeamSpecRetrieveResponse:
        """
        Retrieve a red team spec

        Args:
          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 spec_id:
            raise ValueError(f"Expected a non-empty value for `spec_id` but received {spec_id!r}")
        return await self._get(
            f"/api/dataframer/red-team-specs/{spec_id}/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecRetrieveResponse,
        )

    async def update(
        self,
        spec_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,
    ) -> RedTeamSpecUpdateResponse:
        """
        Update a red team spec

        Args:
          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 spec_id:
            raise ValueError(f"Expected a non-empty value for `spec_id` but received {spec_id!r}")
        return await self._patch(
            f"/api/dataframer/red-team-specs/{spec_id}/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecUpdateResponse,
        )

    async def list(
        self,
        *,
        # 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,
    ) -> RedTeamSpecListResponse:
        """List all red team specs for the user's company"""
        return await self._get(
            "/api/dataframer/red-team-specs/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=RedTeamSpecListResponse,
        )

    async def delete(
        self,
        spec_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,
    ) -> None:
        """
        Delete a red team spec

        Args:
          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 spec_id:
            raise ValueError(f"Expected a non-empty value for `spec_id` but received {spec_id!r}")
        extra_headers = {"Accept": "*/*", **(extra_headers or {})}
        return await self._delete(
            f"/api/dataframer/red-team-specs/{spec_id}/",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=NoneType,
        )


class RedTeamSpecsResourceWithRawResponse:
    def __init__(self, red_team_specs: RedTeamSpecsResource) -> None:
        self._red_team_specs = red_team_specs

        self.create = to_raw_response_wrapper(
            red_team_specs.create,
        )
        self.retrieve = to_raw_response_wrapper(
            red_team_specs.retrieve,
        )
        self.update = to_raw_response_wrapper(
            red_team_specs.update,
        )
        self.list = to_raw_response_wrapper(
            red_team_specs.list,
        )
        self.delete = to_raw_response_wrapper(
            red_team_specs.delete,
        )


class AsyncRedTeamSpecsResourceWithRawResponse:
    def __init__(self, red_team_specs: AsyncRedTeamSpecsResource) -> None:
        self._red_team_specs = red_team_specs

        self.create = async_to_raw_response_wrapper(
            red_team_specs.create,
        )
        self.retrieve = async_to_raw_response_wrapper(
            red_team_specs.retrieve,
        )
        self.update = async_to_raw_response_wrapper(
            red_team_specs.update,
        )
        self.list = async_to_raw_response_wrapper(
            red_team_specs.list,
        )
        self.delete = async_to_raw_response_wrapper(
            red_team_specs.delete,
        )


class RedTeamSpecsResourceWithStreamingResponse:
    def __init__(self, red_team_specs: RedTeamSpecsResource) -> None:
        self._red_team_specs = red_team_specs

        self.create = to_streamed_response_wrapper(
            red_team_specs.create,
        )
        self.retrieve = to_streamed_response_wrapper(
            red_team_specs.retrieve,
        )
        self.update = to_streamed_response_wrapper(
            red_team_specs.update,
        )
        self.list = to_streamed_response_wrapper(
            red_team_specs.list,
        )
        self.delete = to_streamed_response_wrapper(
            red_team_specs.delete,
        )


class AsyncRedTeamSpecsResourceWithStreamingResponse:
    def __init__(self, red_team_specs: AsyncRedTeamSpecsResource) -> None:
        self._red_team_specs = red_team_specs

        self.create = async_to_streamed_response_wrapper(
            red_team_specs.create,
        )
        self.retrieve = async_to_streamed_response_wrapper(
            red_team_specs.retrieve,
        )
        self.update = async_to_streamed_response_wrapper(
            red_team_specs.update,
        )
        self.list = async_to_streamed_response_wrapper(
            red_team_specs.list,
        )
        self.delete = async_to_streamed_response_wrapper(
            red_team_specs.delete,
        )
