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

from __future__ import annotations

from typing import List, Type, Union, cast
from datetime import datetime
from typing_extensions import Literal

import httpx

from .summary import (
    SummaryResource,
    AsyncSummaryResource,
    SummaryResourceWithRawResponse,
    AsyncSummaryResourceWithRawResponse,
    SummaryResourceWithStreamingResponse,
    AsyncSummaryResourceWithStreamingResponse,
)
from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, 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 ....._base_client import make_request_options
from .....types.radar.ai import bot_summary_v2_params, bot_timeseries_params, bot_timeseries_groups_params
from .....types.radar.ai.bot_summary_v2_response import BotSummaryV2Response
from .....types.radar.ai.bot_timeseries_response import BotTimeseriesResponse
from .....types.radar.ai.bot_timeseries_groups_response import BotTimeseriesGroupsResponse

__all__ = ["BotsResource", "AsyncBotsResource"]


class BotsResource(SyncAPIResource):
    @cached_property
    def summary(self) -> SummaryResource:
        return SummaryResource(self._client)

    @cached_property
    def with_raw_response(self) -> BotsResourceWithRawResponse:
        """
        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 BotsResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> BotsResourceWithStreamingResponse:
        """
        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 BotsResourceWithStreamingResponse(self)

    def summary_v2(
        self,
        dimension: Literal[
            "USER_AGENT",
            "CRAWL_PURPOSE",
            "INDUSTRY",
            "VERTICAL",
            "CONTENT_TYPE",
            "RESPONSE_STATUS",
            "RESPONSE_STATUS_CATEGORY",
        ],
        *,
        asn: SequenceNotStr[str] | Omit = omit,
        content_type: List[
            Literal[
                "HTML",
                "IMAGES",
                "JSON",
                "JAVASCRIPT",
                "CSS",
                "PLAIN_TEXT",
                "FONTS",
                "XML",
                "YAML",
                "VIDEO",
                "AUDIO",
                "MARKDOWN",
                "DOCUMENTS",
                "BINARY",
                "SERIALIZATION",
                "OTHER",
            ]
        ]
        | Omit = omit,
        continent: SequenceNotStr[str] | Omit = omit,
        crawl_purpose: SequenceNotStr[str] | Omit = omit,
        date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        date_range: SequenceNotStr[str] | Omit = omit,
        date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        format: Literal["JSON", "CSV"] | Omit = omit,
        industry: SequenceNotStr[str] | Omit = omit,
        limit_per_group: int | Omit = omit,
        location: SequenceNotStr[str] | Omit = omit,
        name: SequenceNotStr[str] | Omit = omit,
        response_status: SequenceNotStr[str] | Omit = omit,
        response_status_category: List[
            Literal["INFORMATIONAL", "SUCCESS", "REDIRECTION", "CLIENT_ERROR", "SERVER_ERROR"]
        ]
        | Omit = omit,
        user_agent: SequenceNotStr[str] | Omit = omit,
        vertical: SequenceNotStr[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,
    ) -> BotSummaryV2Response:
        """
        Retrieves an aggregated summary of AI bots HTTP requests grouped by the
        specified dimension.

        Args:
          dimension: Specifies the attribute by which to group the results.

          asn: Filters results by Autonomous System. Specify one or more Autonomous System
              Numbers (ASNs) as a comma-separated list. Prefix with `-` to exclude ASNs from
              results. For example, `-174, 3356` excludes results from AS174, but includes
              results from AS3356.

          content_type: Filters results by content type category. When set, results can only be further
              filtered by location, continent, or Autonomous System.

          continent: Filters results by continent. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude continents from results. For example, `-EU,NA`
              excludes results from EU, but includes results from NA.

          crawl_purpose: Filters results by bot crawl purpose.

          date_end: End of the date range (inclusive). Alternative to `dateRange`; provide together
              with `dateStart`. When requesting comparison series, every series must resolve
              to the same duration as the main series. Each `dateStart`/`dateEnd` is floored
              to the nearest 15 minutes before evaluation, so windows whose durations match
              only before alignment may be rejected.

          date_range: Filters results by relative date range ending at the current time, with each
              value producing a separate series. Use `<n>d` for days (up to `364d`) or `<n>w`
              for weeks (up to `52w`). Append `control` to request the equivalent previous
              period for comparison: the comparison window is shifted back by the current
              window's length rounded up to a whole number of weeks, so it keeps the same
              weekday alignment and does not overlap the current window (e.g. `7dcontrol`
              covers days -14 to -7, `10dcontrol` covers days -24 to -14). For example, pass
              `7d` and `7dcontrol` to compare this week with the previous week. All series
              must resolve to the same duration as the main series; relative ranges (including
              `control`) satisfy this automatically. Use this parameter or set specific start
              and end dates (`dateStart` and `dateEnd` parameters).

          date_start: Start of the date range. Alternative to `dateRange`; provide together with
              `dateEnd`. When requesting comparison series, every series must resolve to the
              same duration as the main series. Each `dateStart`/`dateEnd` is floored to the
              nearest 15 minutes before evaluation, so windows whose durations match only
              before alignment may be rejected.

          format: Format in which results will be returned.

          industry: Filters results by industry.

          limit_per_group: Limits the number of objects per group to the top items within the specified
              time range. When item count exceeds the limit, extra items appear grouped under
              an "other" category. Only supported on high-cardinality dimensions; otherwise
              the request is rejected. Minimum value is 2.

          location: Filters results by location. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude locations from results. For example, `-US,PT`
              excludes results from the US, but includes results from PT.

          name: Array of names used to label the series in the response.

          response_status: Filters results by HTTP response status code (e.g. 200, 403, 404). Only
              [IANA-registered codes](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
              are accepted.

          response_status_category: Filters results by HTTP response status code category.

          user_agent: Filters results by user agent.

          vertical: Filters results by vertical.

          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 dimension:
            raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}")
        return self._get(
            path_template("/radar/ai/bots/summary/{dimension}", dimension=dimension),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "asn": asn,
                        "content_type": content_type,
                        "continent": continent,
                        "crawl_purpose": crawl_purpose,
                        "date_end": date_end,
                        "date_range": date_range,
                        "date_start": date_start,
                        "format": format,
                        "industry": industry,
                        "limit_per_group": limit_per_group,
                        "location": location,
                        "name": name,
                        "response_status": response_status,
                        "response_status_category": response_status_category,
                        "user_agent": user_agent,
                        "vertical": vertical,
                    },
                    bot_summary_v2_params.BotSummaryV2Params,
                ),
                post_parser=ResultWrapper[BotSummaryV2Response]._unwrapper,
            ),
            cast_to=cast(Type[BotSummaryV2Response], ResultWrapper[BotSummaryV2Response]),
        )

    def timeseries(
        self,
        *,
        agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit,
        asn: SequenceNotStr[str] | Omit = omit,
        content_type: List[
            Literal[
                "HTML",
                "IMAGES",
                "JSON",
                "JAVASCRIPT",
                "CSS",
                "PLAIN_TEXT",
                "FONTS",
                "XML",
                "YAML",
                "VIDEO",
                "AUDIO",
                "MARKDOWN",
                "DOCUMENTS",
                "BINARY",
                "SERIALIZATION",
                "OTHER",
            ]
        ]
        | Omit = omit,
        continent: SequenceNotStr[str] | Omit = omit,
        crawl_purpose: SequenceNotStr[str] | Omit = omit,
        date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        date_range: SequenceNotStr[str] | Omit = omit,
        date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        format: Literal["JSON", "CSV"] | Omit = omit,
        industry: SequenceNotStr[str] | Omit = omit,
        limit_per_group: int | Omit = omit,
        location: SequenceNotStr[str] | Omit = omit,
        name: SequenceNotStr[str] | Omit = omit,
        response_status: SequenceNotStr[str] | Omit = omit,
        response_status_category: List[
            Literal["INFORMATIONAL", "SUCCESS", "REDIRECTION", "CLIENT_ERROR", "SERVER_ERROR"]
        ]
        | Omit = omit,
        user_agent: SequenceNotStr[str] | Omit = omit,
        vertical: SequenceNotStr[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,
    ) -> BotTimeseriesResponse:
        """
        Retrieves AI bots HTTP request volume over time.

        Args:
          agg_interval: Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals).
              Refer to
              [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/).
              When omitted, the interval is auto-selected from the requested date range; finer
              intervals are only available for shorter ranges. If the requested interval is
              too granular for the date range, the request is rejected.

          asn: Filters results by Autonomous System. Specify one or more Autonomous System
              Numbers (ASNs) as a comma-separated list. Prefix with `-` to exclude ASNs from
              results. For example, `-174, 3356` excludes results from AS174, but includes
              results from AS3356.

          content_type: Filters results by content type category. When set, results can only be further
              filtered by location, continent, or Autonomous System.

          continent: Filters results by continent. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude continents from results. For example, `-EU,NA`
              excludes results from EU, but includes results from NA.

          crawl_purpose: Filters results by bot crawl purpose.

          date_end: End of the date range (inclusive). Alternative to `dateRange`; provide together
              with `dateStart`. When requesting comparison series, every series must resolve
              to the same duration as the main series. Each `dateStart`/`dateEnd` is floored
              to the nearest 15 minutes before evaluation, so windows whose durations match
              only before alignment may be rejected.

          date_range: Filters results by relative date range ending at the current time, with each
              value producing a separate series. Use `<n>d` for days (up to `364d`) or `<n>w`
              for weeks (up to `52w`). Append `control` to request the equivalent previous
              period for comparison: the comparison window is shifted back by the current
              window's length rounded up to a whole number of weeks, so it keeps the same
              weekday alignment and does not overlap the current window (e.g. `7dcontrol`
              covers days -14 to -7, `10dcontrol` covers days -24 to -14). For example, pass
              `7d` and `7dcontrol` to compare this week with the previous week. All series
              must resolve to the same duration as the main series; relative ranges (including
              `control`) satisfy this automatically. Use this parameter or set specific start
              and end dates (`dateStart` and `dateEnd` parameters).

          date_start: Start of the date range. Alternative to `dateRange`; provide together with
              `dateEnd`. When requesting comparison series, every series must resolve to the
              same duration as the main series. Each `dateStart`/`dateEnd` is floored to the
              nearest 15 minutes before evaluation, so windows whose durations match only
              before alignment may be rejected.

          format: Format in which results will be returned.

          industry: Filters results by industry.

          limit_per_group: Limits the number of objects per group to the top items within the specified
              time range. When item count exceeds the limit, extra items appear grouped under
              an "other" category. Only supported on high-cardinality dimensions; otherwise
              the request is rejected. Minimum value is 2.

          location: Filters results by location. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude locations from results. For example, `-US,PT`
              excludes results from the US, but includes results from PT.

          name: Array of names used to label the series in the response.

          response_status: Filters results by HTTP response status code (e.g. 200, 403, 404). Only
              [IANA-registered codes](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
              are accepted.

          response_status_category: Filters results by HTTP response status code category.

          user_agent: Filters results by user agent.

          vertical: Filters results by vertical.

          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
        """
        return self._get(
            "/radar/ai/bots/timeseries",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "agg_interval": agg_interval,
                        "asn": asn,
                        "content_type": content_type,
                        "continent": continent,
                        "crawl_purpose": crawl_purpose,
                        "date_end": date_end,
                        "date_range": date_range,
                        "date_start": date_start,
                        "format": format,
                        "industry": industry,
                        "limit_per_group": limit_per_group,
                        "location": location,
                        "name": name,
                        "response_status": response_status,
                        "response_status_category": response_status_category,
                        "user_agent": user_agent,
                        "vertical": vertical,
                    },
                    bot_timeseries_params.BotTimeseriesParams,
                ),
                post_parser=ResultWrapper[BotTimeseriesResponse]._unwrapper,
            ),
            cast_to=cast(Type[BotTimeseriesResponse], ResultWrapper[BotTimeseriesResponse]),
        )

    def timeseries_groups(
        self,
        dimension: Literal[
            "USER_AGENT",
            "CRAWL_PURPOSE",
            "INDUSTRY",
            "VERTICAL",
            "CONTENT_TYPE",
            "RESPONSE_STATUS",
            "RESPONSE_STATUS_CATEGORY",
        ],
        *,
        agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit,
        asn: SequenceNotStr[str] | Omit = omit,
        content_type: List[
            Literal[
                "HTML",
                "IMAGES",
                "JSON",
                "JAVASCRIPT",
                "CSS",
                "PLAIN_TEXT",
                "FONTS",
                "XML",
                "YAML",
                "VIDEO",
                "AUDIO",
                "MARKDOWN",
                "DOCUMENTS",
                "BINARY",
                "SERIALIZATION",
                "OTHER",
            ]
        ]
        | Omit = omit,
        continent: SequenceNotStr[str] | Omit = omit,
        crawl_purpose: SequenceNotStr[str] | Omit = omit,
        date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        date_range: SequenceNotStr[str] | Omit = omit,
        date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        format: Literal["JSON", "CSV"] | Omit = omit,
        industry: SequenceNotStr[str] | Omit = omit,
        limit_per_group: int | Omit = omit,
        location: SequenceNotStr[str] | Omit = omit,
        name: SequenceNotStr[str] | Omit = omit,
        normalization: Literal["PERCENTAGE", "MIN0_MAX", "PERCENTAGE_CHANGE"] | Omit = omit,
        response_status: SequenceNotStr[str] | Omit = omit,
        response_status_category: List[
            Literal["INFORMATIONAL", "SUCCESS", "REDIRECTION", "CLIENT_ERROR", "SERVER_ERROR"]
        ]
        | Omit = omit,
        user_agent: SequenceNotStr[str] | Omit = omit,
        vertical: SequenceNotStr[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,
    ) -> BotTimeseriesGroupsResponse:
        """
        Retrieves the distribution of HTTP requests from AI bots, grouped by the
        specified dimension over time.

        Args:
          dimension: Specifies the attribute by which to group the results.

          agg_interval: Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals).
              Refer to
              [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/).
              When omitted, the interval is auto-selected from the requested date range; finer
              intervals are only available for shorter ranges. If the requested interval is
              too granular for the date range, the request is rejected.

          asn: Filters results by Autonomous System. Specify one or more Autonomous System
              Numbers (ASNs) as a comma-separated list. Prefix with `-` to exclude ASNs from
              results. For example, `-174, 3356` excludes results from AS174, but includes
              results from AS3356.

          content_type: Filters results by content type category. When set, results can only be further
              filtered by location, continent, or Autonomous System.

          continent: Filters results by continent. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude continents from results. For example, `-EU,NA`
              excludes results from EU, but includes results from NA.

          crawl_purpose: Filters results by bot crawl purpose.

          date_end: End of the date range (inclusive). Alternative to `dateRange`; provide together
              with `dateStart`. When requesting comparison series, every series must resolve
              to the same duration as the main series. Each `dateStart`/`dateEnd` is floored
              to the nearest 15 minutes before evaluation, so windows whose durations match
              only before alignment may be rejected.

          date_range: Filters results by relative date range ending at the current time, with each
              value producing a separate series. Use `<n>d` for days (up to `364d`) or `<n>w`
              for weeks (up to `52w`). Append `control` to request the equivalent previous
              period for comparison: the comparison window is shifted back by the current
              window's length rounded up to a whole number of weeks, so it keeps the same
              weekday alignment and does not overlap the current window (e.g. `7dcontrol`
              covers days -14 to -7, `10dcontrol` covers days -24 to -14). For example, pass
              `7d` and `7dcontrol` to compare this week with the previous week. All series
              must resolve to the same duration as the main series; relative ranges (including
              `control`) satisfy this automatically. Use this parameter or set specific start
              and end dates (`dateStart` and `dateEnd` parameters).

          date_start: Start of the date range. Alternative to `dateRange`; provide together with
              `dateEnd`. When requesting comparison series, every series must resolve to the
              same duration as the main series. Each `dateStart`/`dateEnd` is floored to the
              nearest 15 minutes before evaluation, so windows whose durations match only
              before alignment may be rejected.

          format: Format in which results will be returned.

          industry: Filters results by industry.

          limit_per_group: Limits the number of objects per group to the top items within the specified
              time range. When item count exceeds the limit, extra items appear grouped under
              an "other" category. Only supported on high-cardinality dimensions; otherwise
              the request is rejected. Minimum value is 2.

          location: Filters results by location. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude locations from results. For example, `-US,PT`
              excludes results from the US, but includes results from PT.

          name: Array of names used to label the series in the response.

          normalization: Normalization method applied to the results. Refer to
              [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/).
              `PERCENTAGE_CHANGE` requires exactly one comparison series (e.g. a `control`
              date range).

          response_status: Filters results by HTTP response status code (e.g. 200, 403, 404). Only
              [IANA-registered codes](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
              are accepted.

          response_status_category: Filters results by HTTP response status code category.

          user_agent: Filters results by user agent.

          vertical: Filters results by vertical.

          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 dimension:
            raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}")
        return self._get(
            path_template("/radar/ai/bots/timeseries_groups/{dimension}", dimension=dimension),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "agg_interval": agg_interval,
                        "asn": asn,
                        "content_type": content_type,
                        "continent": continent,
                        "crawl_purpose": crawl_purpose,
                        "date_end": date_end,
                        "date_range": date_range,
                        "date_start": date_start,
                        "format": format,
                        "industry": industry,
                        "limit_per_group": limit_per_group,
                        "location": location,
                        "name": name,
                        "normalization": normalization,
                        "response_status": response_status,
                        "response_status_category": response_status_category,
                        "user_agent": user_agent,
                        "vertical": vertical,
                    },
                    bot_timeseries_groups_params.BotTimeseriesGroupsParams,
                ),
                post_parser=ResultWrapper[BotTimeseriesGroupsResponse]._unwrapper,
            ),
            cast_to=cast(Type[BotTimeseriesGroupsResponse], ResultWrapper[BotTimeseriesGroupsResponse]),
        )


class AsyncBotsResource(AsyncAPIResource):
    @cached_property
    def summary(self) -> AsyncSummaryResource:
        return AsyncSummaryResource(self._client)

    @cached_property
    def with_raw_response(self) -> AsyncBotsResourceWithRawResponse:
        """
        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 AsyncBotsResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncBotsResourceWithStreamingResponse:
        """
        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 AsyncBotsResourceWithStreamingResponse(self)

    async def summary_v2(
        self,
        dimension: Literal[
            "USER_AGENT",
            "CRAWL_PURPOSE",
            "INDUSTRY",
            "VERTICAL",
            "CONTENT_TYPE",
            "RESPONSE_STATUS",
            "RESPONSE_STATUS_CATEGORY",
        ],
        *,
        asn: SequenceNotStr[str] | Omit = omit,
        content_type: List[
            Literal[
                "HTML",
                "IMAGES",
                "JSON",
                "JAVASCRIPT",
                "CSS",
                "PLAIN_TEXT",
                "FONTS",
                "XML",
                "YAML",
                "VIDEO",
                "AUDIO",
                "MARKDOWN",
                "DOCUMENTS",
                "BINARY",
                "SERIALIZATION",
                "OTHER",
            ]
        ]
        | Omit = omit,
        continent: SequenceNotStr[str] | Omit = omit,
        crawl_purpose: SequenceNotStr[str] | Omit = omit,
        date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        date_range: SequenceNotStr[str] | Omit = omit,
        date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        format: Literal["JSON", "CSV"] | Omit = omit,
        industry: SequenceNotStr[str] | Omit = omit,
        limit_per_group: int | Omit = omit,
        location: SequenceNotStr[str] | Omit = omit,
        name: SequenceNotStr[str] | Omit = omit,
        response_status: SequenceNotStr[str] | Omit = omit,
        response_status_category: List[
            Literal["INFORMATIONAL", "SUCCESS", "REDIRECTION", "CLIENT_ERROR", "SERVER_ERROR"]
        ]
        | Omit = omit,
        user_agent: SequenceNotStr[str] | Omit = omit,
        vertical: SequenceNotStr[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,
    ) -> BotSummaryV2Response:
        """
        Retrieves an aggregated summary of AI bots HTTP requests grouped by the
        specified dimension.

        Args:
          dimension: Specifies the attribute by which to group the results.

          asn: Filters results by Autonomous System. Specify one or more Autonomous System
              Numbers (ASNs) as a comma-separated list. Prefix with `-` to exclude ASNs from
              results. For example, `-174, 3356` excludes results from AS174, but includes
              results from AS3356.

          content_type: Filters results by content type category. When set, results can only be further
              filtered by location, continent, or Autonomous System.

          continent: Filters results by continent. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude continents from results. For example, `-EU,NA`
              excludes results from EU, but includes results from NA.

          crawl_purpose: Filters results by bot crawl purpose.

          date_end: End of the date range (inclusive). Alternative to `dateRange`; provide together
              with `dateStart`. When requesting comparison series, every series must resolve
              to the same duration as the main series. Each `dateStart`/`dateEnd` is floored
              to the nearest 15 minutes before evaluation, so windows whose durations match
              only before alignment may be rejected.

          date_range: Filters results by relative date range ending at the current time, with each
              value producing a separate series. Use `<n>d` for days (up to `364d`) or `<n>w`
              for weeks (up to `52w`). Append `control` to request the equivalent previous
              period for comparison: the comparison window is shifted back by the current
              window's length rounded up to a whole number of weeks, so it keeps the same
              weekday alignment and does not overlap the current window (e.g. `7dcontrol`
              covers days -14 to -7, `10dcontrol` covers days -24 to -14). For example, pass
              `7d` and `7dcontrol` to compare this week with the previous week. All series
              must resolve to the same duration as the main series; relative ranges (including
              `control`) satisfy this automatically. Use this parameter or set specific start
              and end dates (`dateStart` and `dateEnd` parameters).

          date_start: Start of the date range. Alternative to `dateRange`; provide together with
              `dateEnd`. When requesting comparison series, every series must resolve to the
              same duration as the main series. Each `dateStart`/`dateEnd` is floored to the
              nearest 15 minutes before evaluation, so windows whose durations match only
              before alignment may be rejected.

          format: Format in which results will be returned.

          industry: Filters results by industry.

          limit_per_group: Limits the number of objects per group to the top items within the specified
              time range. When item count exceeds the limit, extra items appear grouped under
              an "other" category. Only supported on high-cardinality dimensions; otherwise
              the request is rejected. Minimum value is 2.

          location: Filters results by location. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude locations from results. For example, `-US,PT`
              excludes results from the US, but includes results from PT.

          name: Array of names used to label the series in the response.

          response_status: Filters results by HTTP response status code (e.g. 200, 403, 404). Only
              [IANA-registered codes](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
              are accepted.

          response_status_category: Filters results by HTTP response status code category.

          user_agent: Filters results by user agent.

          vertical: Filters results by vertical.

          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 dimension:
            raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}")
        return await self._get(
            path_template("/radar/ai/bots/summary/{dimension}", dimension=dimension),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform(
                    {
                        "asn": asn,
                        "content_type": content_type,
                        "continent": continent,
                        "crawl_purpose": crawl_purpose,
                        "date_end": date_end,
                        "date_range": date_range,
                        "date_start": date_start,
                        "format": format,
                        "industry": industry,
                        "limit_per_group": limit_per_group,
                        "location": location,
                        "name": name,
                        "response_status": response_status,
                        "response_status_category": response_status_category,
                        "user_agent": user_agent,
                        "vertical": vertical,
                    },
                    bot_summary_v2_params.BotSummaryV2Params,
                ),
                post_parser=ResultWrapper[BotSummaryV2Response]._unwrapper,
            ),
            cast_to=cast(Type[BotSummaryV2Response], ResultWrapper[BotSummaryV2Response]),
        )

    async def timeseries(
        self,
        *,
        agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit,
        asn: SequenceNotStr[str] | Omit = omit,
        content_type: List[
            Literal[
                "HTML",
                "IMAGES",
                "JSON",
                "JAVASCRIPT",
                "CSS",
                "PLAIN_TEXT",
                "FONTS",
                "XML",
                "YAML",
                "VIDEO",
                "AUDIO",
                "MARKDOWN",
                "DOCUMENTS",
                "BINARY",
                "SERIALIZATION",
                "OTHER",
            ]
        ]
        | Omit = omit,
        continent: SequenceNotStr[str] | Omit = omit,
        crawl_purpose: SequenceNotStr[str] | Omit = omit,
        date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        date_range: SequenceNotStr[str] | Omit = omit,
        date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        format: Literal["JSON", "CSV"] | Omit = omit,
        industry: SequenceNotStr[str] | Omit = omit,
        limit_per_group: int | Omit = omit,
        location: SequenceNotStr[str] | Omit = omit,
        name: SequenceNotStr[str] | Omit = omit,
        response_status: SequenceNotStr[str] | Omit = omit,
        response_status_category: List[
            Literal["INFORMATIONAL", "SUCCESS", "REDIRECTION", "CLIENT_ERROR", "SERVER_ERROR"]
        ]
        | Omit = omit,
        user_agent: SequenceNotStr[str] | Omit = omit,
        vertical: SequenceNotStr[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,
    ) -> BotTimeseriesResponse:
        """
        Retrieves AI bots HTTP request volume over time.

        Args:
          agg_interval: Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals).
              Refer to
              [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/).
              When omitted, the interval is auto-selected from the requested date range; finer
              intervals are only available for shorter ranges. If the requested interval is
              too granular for the date range, the request is rejected.

          asn: Filters results by Autonomous System. Specify one or more Autonomous System
              Numbers (ASNs) as a comma-separated list. Prefix with `-` to exclude ASNs from
              results. For example, `-174, 3356` excludes results from AS174, but includes
              results from AS3356.

          content_type: Filters results by content type category. When set, results can only be further
              filtered by location, continent, or Autonomous System.

          continent: Filters results by continent. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude continents from results. For example, `-EU,NA`
              excludes results from EU, but includes results from NA.

          crawl_purpose: Filters results by bot crawl purpose.

          date_end: End of the date range (inclusive). Alternative to `dateRange`; provide together
              with `dateStart`. When requesting comparison series, every series must resolve
              to the same duration as the main series. Each `dateStart`/`dateEnd` is floored
              to the nearest 15 minutes before evaluation, so windows whose durations match
              only before alignment may be rejected.

          date_range: Filters results by relative date range ending at the current time, with each
              value producing a separate series. Use `<n>d` for days (up to `364d`) or `<n>w`
              for weeks (up to `52w`). Append `control` to request the equivalent previous
              period for comparison: the comparison window is shifted back by the current
              window's length rounded up to a whole number of weeks, so it keeps the same
              weekday alignment and does not overlap the current window (e.g. `7dcontrol`
              covers days -14 to -7, `10dcontrol` covers days -24 to -14). For example, pass
              `7d` and `7dcontrol` to compare this week with the previous week. All series
              must resolve to the same duration as the main series; relative ranges (including
              `control`) satisfy this automatically. Use this parameter or set specific start
              and end dates (`dateStart` and `dateEnd` parameters).

          date_start: Start of the date range. Alternative to `dateRange`; provide together with
              `dateEnd`. When requesting comparison series, every series must resolve to the
              same duration as the main series. Each `dateStart`/`dateEnd` is floored to the
              nearest 15 minutes before evaluation, so windows whose durations match only
              before alignment may be rejected.

          format: Format in which results will be returned.

          industry: Filters results by industry.

          limit_per_group: Limits the number of objects per group to the top items within the specified
              time range. When item count exceeds the limit, extra items appear grouped under
              an "other" category. Only supported on high-cardinality dimensions; otherwise
              the request is rejected. Minimum value is 2.

          location: Filters results by location. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude locations from results. For example, `-US,PT`
              excludes results from the US, but includes results from PT.

          name: Array of names used to label the series in the response.

          response_status: Filters results by HTTP response status code (e.g. 200, 403, 404). Only
              [IANA-registered codes](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
              are accepted.

          response_status_category: Filters results by HTTP response status code category.

          user_agent: Filters results by user agent.

          vertical: Filters results by vertical.

          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
        """
        return await self._get(
            "/radar/ai/bots/timeseries",
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform(
                    {
                        "agg_interval": agg_interval,
                        "asn": asn,
                        "content_type": content_type,
                        "continent": continent,
                        "crawl_purpose": crawl_purpose,
                        "date_end": date_end,
                        "date_range": date_range,
                        "date_start": date_start,
                        "format": format,
                        "industry": industry,
                        "limit_per_group": limit_per_group,
                        "location": location,
                        "name": name,
                        "response_status": response_status,
                        "response_status_category": response_status_category,
                        "user_agent": user_agent,
                        "vertical": vertical,
                    },
                    bot_timeseries_params.BotTimeseriesParams,
                ),
                post_parser=ResultWrapper[BotTimeseriesResponse]._unwrapper,
            ),
            cast_to=cast(Type[BotTimeseriesResponse], ResultWrapper[BotTimeseriesResponse]),
        )

    async def timeseries_groups(
        self,
        dimension: Literal[
            "USER_AGENT",
            "CRAWL_PURPOSE",
            "INDUSTRY",
            "VERTICAL",
            "CONTENT_TYPE",
            "RESPONSE_STATUS",
            "RESPONSE_STATUS_CATEGORY",
        ],
        *,
        agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit,
        asn: SequenceNotStr[str] | Omit = omit,
        content_type: List[
            Literal[
                "HTML",
                "IMAGES",
                "JSON",
                "JAVASCRIPT",
                "CSS",
                "PLAIN_TEXT",
                "FONTS",
                "XML",
                "YAML",
                "VIDEO",
                "AUDIO",
                "MARKDOWN",
                "DOCUMENTS",
                "BINARY",
                "SERIALIZATION",
                "OTHER",
            ]
        ]
        | Omit = omit,
        continent: SequenceNotStr[str] | Omit = omit,
        crawl_purpose: SequenceNotStr[str] | Omit = omit,
        date_end: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        date_range: SequenceNotStr[str] | Omit = omit,
        date_start: SequenceNotStr[Union[str, datetime]] | Omit = omit,
        format: Literal["JSON", "CSV"] | Omit = omit,
        industry: SequenceNotStr[str] | Omit = omit,
        limit_per_group: int | Omit = omit,
        location: SequenceNotStr[str] | Omit = omit,
        name: SequenceNotStr[str] | Omit = omit,
        normalization: Literal["PERCENTAGE", "MIN0_MAX", "PERCENTAGE_CHANGE"] | Omit = omit,
        response_status: SequenceNotStr[str] | Omit = omit,
        response_status_category: List[
            Literal["INFORMATIONAL", "SUCCESS", "REDIRECTION", "CLIENT_ERROR", "SERVER_ERROR"]
        ]
        | Omit = omit,
        user_agent: SequenceNotStr[str] | Omit = omit,
        vertical: SequenceNotStr[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,
    ) -> BotTimeseriesGroupsResponse:
        """
        Retrieves the distribution of HTTP requests from AI bots, grouped by the
        specified dimension over time.

        Args:
          dimension: Specifies the attribute by which to group the results.

          agg_interval: Aggregation interval of the results (e.g., in 15 minutes or 1 hour intervals).
              Refer to
              [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/).
              When omitted, the interval is auto-selected from the requested date range; finer
              intervals are only available for shorter ranges. If the requested interval is
              too granular for the date range, the request is rejected.

          asn: Filters results by Autonomous System. Specify one or more Autonomous System
              Numbers (ASNs) as a comma-separated list. Prefix with `-` to exclude ASNs from
              results. For example, `-174, 3356` excludes results from AS174, but includes
              results from AS3356.

          content_type: Filters results by content type category. When set, results can only be further
              filtered by location, continent, or Autonomous System.

          continent: Filters results by continent. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude continents from results. For example, `-EU,NA`
              excludes results from EU, but includes results from NA.

          crawl_purpose: Filters results by bot crawl purpose.

          date_end: End of the date range (inclusive). Alternative to `dateRange`; provide together
              with `dateStart`. When requesting comparison series, every series must resolve
              to the same duration as the main series. Each `dateStart`/`dateEnd` is floored
              to the nearest 15 minutes before evaluation, so windows whose durations match
              only before alignment may be rejected.

          date_range: Filters results by relative date range ending at the current time, with each
              value producing a separate series. Use `<n>d` for days (up to `364d`) or `<n>w`
              for weeks (up to `52w`). Append `control` to request the equivalent previous
              period for comparison: the comparison window is shifted back by the current
              window's length rounded up to a whole number of weeks, so it keeps the same
              weekday alignment and does not overlap the current window (e.g. `7dcontrol`
              covers days -14 to -7, `10dcontrol` covers days -24 to -14). For example, pass
              `7d` and `7dcontrol` to compare this week with the previous week. All series
              must resolve to the same duration as the main series; relative ranges (including
              `control`) satisfy this automatically. Use this parameter or set specific start
              and end dates (`dateStart` and `dateEnd` parameters).

          date_start: Start of the date range. Alternative to `dateRange`; provide together with
              `dateEnd`. When requesting comparison series, every series must resolve to the
              same duration as the main series. Each `dateStart`/`dateEnd` is floored to the
              nearest 15 minutes before evaluation, so windows whose durations match only
              before alignment may be rejected.

          format: Format in which results will be returned.

          industry: Filters results by industry.

          limit_per_group: Limits the number of objects per group to the top items within the specified
              time range. When item count exceeds the limit, extra items appear grouped under
              an "other" category. Only supported on high-cardinality dimensions; otherwise
              the request is rejected. Minimum value is 2.

          location: Filters results by location. Specify a comma-separated list of alpha-2 codes.
              Prefix with `-` to exclude locations from results. For example, `-US,PT`
              excludes results from the US, but includes results from PT.

          name: Array of names used to label the series in the response.

          normalization: Normalization method applied to the results. Refer to
              [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/).
              `PERCENTAGE_CHANGE` requires exactly one comparison series (e.g. a `control`
              date range).

          response_status: Filters results by HTTP response status code (e.g. 200, 403, 404). Only
              [IANA-registered codes](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
              are accepted.

          response_status_category: Filters results by HTTP response status code category.

          user_agent: Filters results by user agent.

          vertical: Filters results by vertical.

          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 dimension:
            raise ValueError(f"Expected a non-empty value for `dimension` but received {dimension!r}")
        return await self._get(
            path_template("/radar/ai/bots/timeseries_groups/{dimension}", dimension=dimension),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=await async_maybe_transform(
                    {
                        "agg_interval": agg_interval,
                        "asn": asn,
                        "content_type": content_type,
                        "continent": continent,
                        "crawl_purpose": crawl_purpose,
                        "date_end": date_end,
                        "date_range": date_range,
                        "date_start": date_start,
                        "format": format,
                        "industry": industry,
                        "limit_per_group": limit_per_group,
                        "location": location,
                        "name": name,
                        "normalization": normalization,
                        "response_status": response_status,
                        "response_status_category": response_status_category,
                        "user_agent": user_agent,
                        "vertical": vertical,
                    },
                    bot_timeseries_groups_params.BotTimeseriesGroupsParams,
                ),
                post_parser=ResultWrapper[BotTimeseriesGroupsResponse]._unwrapper,
            ),
            cast_to=cast(Type[BotTimeseriesGroupsResponse], ResultWrapper[BotTimeseriesGroupsResponse]),
        )


class BotsResourceWithRawResponse:
    def __init__(self, bots: BotsResource) -> None:
        self._bots = bots

        self.summary_v2 = to_raw_response_wrapper(
            bots.summary_v2,
        )
        self.timeseries = to_raw_response_wrapper(
            bots.timeseries,
        )
        self.timeseries_groups = to_raw_response_wrapper(
            bots.timeseries_groups,
        )

    @cached_property
    def summary(self) -> SummaryResourceWithRawResponse:
        return SummaryResourceWithRawResponse(self._bots.summary)


class AsyncBotsResourceWithRawResponse:
    def __init__(self, bots: AsyncBotsResource) -> None:
        self._bots = bots

        self.summary_v2 = async_to_raw_response_wrapper(
            bots.summary_v2,
        )
        self.timeseries = async_to_raw_response_wrapper(
            bots.timeseries,
        )
        self.timeseries_groups = async_to_raw_response_wrapper(
            bots.timeseries_groups,
        )

    @cached_property
    def summary(self) -> AsyncSummaryResourceWithRawResponse:
        return AsyncSummaryResourceWithRawResponse(self._bots.summary)


class BotsResourceWithStreamingResponse:
    def __init__(self, bots: BotsResource) -> None:
        self._bots = bots

        self.summary_v2 = to_streamed_response_wrapper(
            bots.summary_v2,
        )
        self.timeseries = to_streamed_response_wrapper(
            bots.timeseries,
        )
        self.timeseries_groups = to_streamed_response_wrapper(
            bots.timeseries_groups,
        )

    @cached_property
    def summary(self) -> SummaryResourceWithStreamingResponse:
        return SummaryResourceWithStreamingResponse(self._bots.summary)


class AsyncBotsResourceWithStreamingResponse:
    def __init__(self, bots: AsyncBotsResource) -> None:
        self._bots = bots

        self.summary_v2 = async_to_streamed_response_wrapper(
            bots.summary_v2,
        )
        self.timeseries = async_to_streamed_response_wrapper(
            bots.timeseries,
        )
        self.timeseries_groups = async_to_streamed_response_wrapper(
            bots.timeseries_groups,
        )

    @cached_property
    def summary(self) -> AsyncSummaryResourceWithStreamingResponse:
        return AsyncSummaryResourceWithStreamingResponse(self._bots.summary)
