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

from __future__ import annotations

import os
from typing import Any, cast

import pytest

from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare._utils import parse_datetime
from cloudflare.types.cloudforce_one import (
    ThreatEventGetResponse,
    ThreatEventEditResponse,
    ThreatEventListResponse,
    ThreatEventCreateResponse,
    ThreatEventDeleteResponse,
    ThreatEventBulkCreateResponse,
)

# pyright: reportDeprecated=false

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")


class TestThreatEvents:
    parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_create(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={"data": {"foo": "bar"}},
            tlp="amber",
        )
        assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_create_with_all_params(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={
                "data": {"foo": "bar"},
                "source": "example.com",
                "tlp": "amber",
            },
            tlp="amber",
            body_account_id=123456,
            attacker="Flying Yeti",
            attacker_country="CN",
            dataset_id="durableObjectName",
            indicator="domain.com",
            indicators=[
                {
                    "indicator_type": "domain",
                    "value": "malicious.com",
                }
            ],
            indicator_type="domain",
            insight="This domain was likely registered for phishing purposes",
            tags=["malware"],
            target_country="US",
            target_industry="Agriculture",
        )
        assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_raw_response_create(self, client: Cloudflare) -> None:
        response = client.cloudforce_one.threat_events.with_raw_response.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={"data": {"foo": "bar"}},
            tlp="amber",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = response.parse()
        assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_streaming_response_create(self, client: Cloudflare) -> None:
        with client.cloudforce_one.threat_events.with_streaming_response.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={"data": {"foo": "bar"}},
            tlp="amber",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = response.parse()
            assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_path_params_create(self, client: Cloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_account_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.create(
                path_account_id="",
                category="Domain Resolution",
                date=parse_datetime("2022-04-01T00:00:00Z"),
                event="An attacker registered the domain domain.com",
                raw={"data": {"foo": "bar"}},
                tlp="amber",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_list(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.list(
            account_id="account_id",
        )
        assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_list_with_all_params(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.list(
            account_id="account_id",
            cursor="eyJ2ZXJzaW9uIjoxLCJwb3NpdGlvbiI6eyJkYXRlIjoiMjAyNC0wMS0xMlQxMDowMDowMFoiLCJ1dWlkIjoiYWJjMTIzIn19",
            dataset_id=["string"],
            force_refresh=True,
            format="json",
            order="asc",
            order_by="orderBy",
            page=0,
            page_size=0,
            search=[
                {
                    "field": "attackerCountry",
                    "op": "equals",
                    "value": "usa",
                }
            ],
        )
        assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_raw_response_list(self, client: Cloudflare) -> None:
        response = client.cloudforce_one.threat_events.with_raw_response.list(
            account_id="account_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = response.parse()
        assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_streaming_response_list(self, client: Cloudflare) -> None:
        with client.cloudforce_one.threat_events.with_streaming_response.list(
            account_id="account_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = response.parse()
            assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_path_params_list(self, client: Cloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.list(
                account_id="",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_delete(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.delete(
            event_id="event_id",
            account_id="account_id",
        )
        assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_raw_response_delete(self, client: Cloudflare) -> None:
        response = client.cloudforce_one.threat_events.with_raw_response.delete(
            event_id="event_id",
            account_id="account_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = response.parse()
        assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_streaming_response_delete(self, client: Cloudflare) -> None:
        with client.cloudforce_one.threat_events.with_streaming_response.delete(
            event_id="event_id",
            account_id="account_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = response.parse()
            assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_path_params_delete(self, client: Cloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.delete(
                event_id="event_id",
                account_id="",
            )

        with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.delete(
                event_id="",
                account_id="account_id",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_bulk_create(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {"data": {"foo": "bar"}},
                    "tlp": "amber",
                }
            ],
            dataset_id="durableObjectName",
        )
        assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_bulk_create_with_all_params(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {
                        "data": {"foo": "bar"},
                        "source": "example.com",
                        "tlp": "amber",
                    },
                    "tlp": "amber",
                    "account_id": 123456,
                    "attacker": "Flying Yeti",
                    "attacker_country": "CN",
                    "dataset_id": "durableObjectName",
                    "indicator": "domain.com",
                    "indicators": [
                        {
                            "indicator_type": "domain",
                            "value": "malicious.com",
                        }
                    ],
                    "indicator_type": "domain",
                    "insight": "This domain was likely registered for phishing purposes",
                    "tags": ["malware"],
                    "target_country": "US",
                    "target_industry": "Agriculture",
                }
            ],
            dataset_id="durableObjectName",
            include_created_events=True,
        )
        assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_raw_response_bulk_create(self, client: Cloudflare) -> None:
        response = client.cloudforce_one.threat_events.with_raw_response.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {"data": {"foo": "bar"}},
                    "tlp": "amber",
                }
            ],
            dataset_id="durableObjectName",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = response.parse()
        assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_streaming_response_bulk_create(self, client: Cloudflare) -> None:
        with client.cloudforce_one.threat_events.with_streaming_response.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {"data": {"foo": "bar"}},
                    "tlp": "amber",
                }
            ],
            dataset_id="durableObjectName",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = response.parse()
            assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_path_params_bulk_create(self, client: Cloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.bulk_create(
                account_id="",
                data=[
                    {
                        "category": "Domain Resolution",
                        "date": parse_datetime("2022-04-01T00:00:00Z"),
                        "event": "An attacker registered the domain domain.com",
                        "raw": {"data": {"foo": "bar"}},
                        "tlp": "amber",
                    }
                ],
                dataset_id="durableObjectName",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_edit(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.edit(
            event_id="event_id",
            account_id="account_id",
        )
        assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
        threat_event = client.cloudforce_one.threat_events.edit(
            event_id="event_id",
            account_id="account_id",
            attacker="Flying Yeti",
            attacker_country="CN",
            category="Domain Resolution",
            created_at=parse_datetime("2025-12-19T00:00:00Z"),
            dataset_id="9b769969-a211-466c-8ac3-cb91266a066a",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            indicator="domain2.com",
            indicator_type="domain",
            insight="new insight",
            raw={
                "data": {"foo": "bar"},
                "source": "example.com",
                "tlp": "amber",
            },
            target_country="US",
            target_industry="Insurance",
            tlp="amber",
        )
        assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_raw_response_edit(self, client: Cloudflare) -> None:
        response = client.cloudforce_one.threat_events.with_raw_response.edit(
            event_id="event_id",
            account_id="account_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = response.parse()
        assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_streaming_response_edit(self, client: Cloudflare) -> None:
        with client.cloudforce_one.threat_events.with_streaming_response.edit(
            event_id="event_id",
            account_id="account_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = response.parse()
            assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_path_params_edit(self, client: Cloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.edit(
                event_id="event_id",
                account_id="",
            )

        with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"):
            client.cloudforce_one.threat_events.with_raw_response.edit(
                event_id="",
                account_id="account_id",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_method_get(self, client: Cloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            threat_event = client.cloudforce_one.threat_events.get(
                event_id="event_id",
                account_id="account_id",
            )

        assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_raw_response_get(self, client: Cloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            response = client.cloudforce_one.threat_events.with_raw_response.get(
                event_id="event_id",
                account_id="account_id",
            )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = response.parse()
        assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_streaming_response_get(self, client: Cloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            with client.cloudforce_one.threat_events.with_streaming_response.get(
                event_id="event_id",
                account_id="account_id",
            ) as response:
                assert not response.is_closed
                assert response.http_request.headers.get("X-Stainless-Lang") == "python"

                threat_event = response.parse()
                assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    def test_path_params_get(self, client: Cloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
                client.cloudforce_one.threat_events.with_raw_response.get(
                    event_id="event_id",
                    account_id="",
                )

            with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"):
                client.cloudforce_one.threat_events.with_raw_response.get(
                    event_id="",
                    account_id="account_id",
                )


class TestAsyncThreatEvents:
    parametrize = pytest.mark.parametrize(
        "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
    )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_create(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={"data": {"foo": "bar"}},
            tlp="amber",
        )
        assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={
                "data": {"foo": "bar"},
                "source": "example.com",
                "tlp": "amber",
            },
            tlp="amber",
            body_account_id=123456,
            attacker="Flying Yeti",
            attacker_country="CN",
            dataset_id="durableObjectName",
            indicator="domain.com",
            indicators=[
                {
                    "indicator_type": "domain",
                    "value": "malicious.com",
                }
            ],
            indicator_type="domain",
            insight="This domain was likely registered for phishing purposes",
            tags=["malware"],
            target_country="US",
            target_industry="Agriculture",
        )
        assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
        response = await async_client.cloudforce_one.threat_events.with_raw_response.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={"data": {"foo": "bar"}},
            tlp="amber",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = await response.parse()
        assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
        async with async_client.cloudforce_one.threat_events.with_streaming_response.create(
            path_account_id="account_id",
            category="Domain Resolution",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            raw={"data": {"foo": "bar"}},
            tlp="amber",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = await response.parse()
            assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_account_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.create(
                path_account_id="",
                category="Domain Resolution",
                date=parse_datetime("2022-04-01T00:00:00Z"),
                event="An attacker registered the domain domain.com",
                raw={"data": {"foo": "bar"}},
                tlp="amber",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_list(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.list(
            account_id="account_id",
        )
        assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.list(
            account_id="account_id",
            cursor="eyJ2ZXJzaW9uIjoxLCJwb3NpdGlvbiI6eyJkYXRlIjoiMjAyNC0wMS0xMlQxMDowMDowMFoiLCJ1dWlkIjoiYWJjMTIzIn19",
            dataset_id=["string"],
            force_refresh=True,
            format="json",
            order="asc",
            order_by="orderBy",
            page=0,
            page_size=0,
            search=[
                {
                    "field": "attackerCountry",
                    "op": "equals",
                    "value": "usa",
                }
            ],
        )
        assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
        response = await async_client.cloudforce_one.threat_events.with_raw_response.list(
            account_id="account_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = await response.parse()
        assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
        async with async_client.cloudforce_one.threat_events.with_streaming_response.list(
            account_id="account_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = await response.parse()
            assert_matches_type(ThreatEventListResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.list(
                account_id="",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.delete(
            event_id="event_id",
            account_id="account_id",
        )
        assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
        response = await async_client.cloudforce_one.threat_events.with_raw_response.delete(
            event_id="event_id",
            account_id="account_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = await response.parse()
        assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
        async with async_client.cloudforce_one.threat_events.with_streaming_response.delete(
            event_id="event_id",
            account_id="account_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = await response.parse()
            assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.delete(
                event_id="event_id",
                account_id="",
            )

        with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.delete(
                event_id="",
                account_id="account_id",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_bulk_create(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {"data": {"foo": "bar"}},
                    "tlp": "amber",
                }
            ],
            dataset_id="durableObjectName",
        )
        assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_bulk_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {
                        "data": {"foo": "bar"},
                        "source": "example.com",
                        "tlp": "amber",
                    },
                    "tlp": "amber",
                    "account_id": 123456,
                    "attacker": "Flying Yeti",
                    "attacker_country": "CN",
                    "dataset_id": "durableObjectName",
                    "indicator": "domain.com",
                    "indicators": [
                        {
                            "indicator_type": "domain",
                            "value": "malicious.com",
                        }
                    ],
                    "indicator_type": "domain",
                    "insight": "This domain was likely registered for phishing purposes",
                    "tags": ["malware"],
                    "target_country": "US",
                    "target_industry": "Agriculture",
                }
            ],
            dataset_id="durableObjectName",
            include_created_events=True,
        )
        assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_raw_response_bulk_create(self, async_client: AsyncCloudflare) -> None:
        response = await async_client.cloudforce_one.threat_events.with_raw_response.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {"data": {"foo": "bar"}},
                    "tlp": "amber",
                }
            ],
            dataset_id="durableObjectName",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = await response.parse()
        assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_streaming_response_bulk_create(self, async_client: AsyncCloudflare) -> None:
        async with async_client.cloudforce_one.threat_events.with_streaming_response.bulk_create(
            account_id="account_id",
            data=[
                {
                    "category": "Domain Resolution",
                    "date": parse_datetime("2022-04-01T00:00:00Z"),
                    "event": "An attacker registered the domain domain.com",
                    "raw": {"data": {"foo": "bar"}},
                    "tlp": "amber",
                }
            ],
            dataset_id="durableObjectName",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = await response.parse()
            assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_path_params_bulk_create(self, async_client: AsyncCloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.bulk_create(
                account_id="",
                data=[
                    {
                        "category": "Domain Resolution",
                        "date": parse_datetime("2022-04-01T00:00:00Z"),
                        "event": "An attacker registered the domain domain.com",
                        "raw": {"data": {"foo": "bar"}},
                        "tlp": "amber",
                    }
                ],
                dataset_id="durableObjectName",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.edit(
            event_id="event_id",
            account_id="account_id",
        )
        assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None:
        threat_event = await async_client.cloudforce_one.threat_events.edit(
            event_id="event_id",
            account_id="account_id",
            attacker="Flying Yeti",
            attacker_country="CN",
            category="Domain Resolution",
            created_at=parse_datetime("2025-12-19T00:00:00Z"),
            dataset_id="9b769969-a211-466c-8ac3-cb91266a066a",
            date=parse_datetime("2022-04-01T00:00:00Z"),
            event="An attacker registered the domain domain.com",
            indicator="domain2.com",
            indicator_type="domain",
            insight="new insight",
            raw={
                "data": {"foo": "bar"},
                "source": "example.com",
                "tlp": "amber",
            },
            target_country="US",
            target_industry="Insurance",
            tlp="amber",
        )
        assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
        response = await async_client.cloudforce_one.threat_events.with_raw_response.edit(
            event_id="event_id",
            account_id="account_id",
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = await response.parse()
        assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
        async with async_client.cloudforce_one.threat_events.with_streaming_response.edit(
            event_id="event_id",
            account_id="account_id",
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            threat_event = await response.parse()
            assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
        with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.edit(
                event_id="event_id",
                account_id="",
            )

        with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"):
            await async_client.cloudforce_one.threat_events.with_raw_response.edit(
                event_id="",
                account_id="account_id",
            )

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_method_get(self, async_client: AsyncCloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            threat_event = await async_client.cloudforce_one.threat_events.get(
                event_id="event_id",
                account_id="account_id",
            )

        assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            response = await async_client.cloudforce_one.threat_events.with_raw_response.get(
                event_id="event_id",
                account_id="account_id",
            )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        threat_event = await response.parse()
        assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"])

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            async with async_client.cloudforce_one.threat_events.with_streaming_response.get(
                event_id="event_id",
                account_id="account_id",
            ) as response:
                assert not response.is_closed
                assert response.http_request.headers.get("X-Stainless-Lang") == "python"

                threat_event = await response.parse()
                assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"])

        assert cast(Any, response.is_closed) is True

    @pytest.mark.skip(reason="TODO: HTTP 401 from prism")
    @parametrize
    async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
        with pytest.warns(DeprecationWarning):
            with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
                await async_client.cloudforce_one.threat_events.with_raw_response.get(
                    event_id="event_id",
                    account_id="",
                )

            with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"):
                await async_client.cloudforce_one.threat_events.with_raw_response.get(
                    event_id="",
                    account_id="account_id",
                )
