From 28f7d845af9840b81f74cb8b228062eb436bc92d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 23:48:49 +0000 Subject: [PATCH] feat(threat_events): shuffle endpoints from POST => PATCH --- .stats.yml | 2 +- api.md | 184 ++++ .../resources/cloudforce_one/__init__.py | 14 + .../cloudforce_one/cloudforce_one.py | 32 + .../cloudforce_one/threat_events/__init__.py | 173 ++++ .../cloudforce_one/threat_events/attackers.py | 163 +++ .../threat_events/categories.py | 568 ++++++++++ .../cloudforce_one/threat_events/countries.py | 163 +++ .../cloudforce_one/threat_events/crons.py | 242 +++++ .../cloudforce_one/threat_events/datasets.py | 580 +++++++++++ .../threat_events/event_tags.py | 184 ++++ .../threat_events/indicator_types.py | 163 +++ .../cloudforce_one/threat_events/insights.py | 518 ++++++++++ .../cloudforce_one/threat_events/raw.py | 309 ++++++ .../cloudforce_one/threat_events/relate.py | 184 ++++ .../threat_events/target_industries.py | 163 +++ .../threat_events/threat_events.py | 976 ++++++++++++++++++ .../types/cloudforce_one/__init__.py | 8 + .../threat_event_bulk_create_params.py | 58 ++ .../threat_event_bulk_create_response.py | 69 ++ .../threat_event_create_params.py | 35 + .../threat_event_create_response.py | 69 ++ .../threat_event_delete_response.py | 10 + .../threat_event_edit_params.py | 36 + .../threat_event_edit_response.py | 65 ++ .../threat_event_get_response.py | 65 ++ .../cloudforce_one/threat_events/__init__.py | 32 + .../threat_events/attacker_list_response.py | 16 + .../threat_events/category_create_params.py | 23 + .../threat_events/category_create_response.py | 21 + .../threat_events/category_delete_response.py | 10 + .../threat_events/category_edit_params.py | 23 + .../threat_events/category_edit_response.py | 21 + .../threat_events/category_get_response.py | 21 + .../threat_events/category_list_response.py | 25 + .../threat_events/country_list_response.py | 23 + .../threat_events/cron_edit_response.py | 12 + .../threat_events/cron_list_response.py | 10 + .../threat_events/dataset_create_params.py | 23 + .../threat_events/dataset_create_response.py | 16 + .../threat_events/dataset_edit_params.py | 23 + .../threat_events/dataset_edit_response.py | 16 + .../threat_events/dataset_get_response.py | 16 + .../threat_events/dataset_list_response.py | 21 + .../threat_events/dataset_raw_response.py | 22 + .../event_tag_delete_response.py | 10 + .../indicator_type_list_response.py | 16 + .../threat_events/insight_creat_params.py | 14 + .../threat_events/insight_creat_response.py | 12 + .../threat_events/insight_delete_response.py | 10 + .../threat_events/insight_edit_params.py | 17 + .../threat_events/insight_edit_response.py | 12 + .../threat_events/insight_get_response.py | 12 + .../threat_events/raw_edit_params.py | 21 + .../threat_events/raw_edit_response.py | 12 + .../threat_events/raw_get_response.py | 22 + .../threat_events/relate_delete_response.py | 10 + .../target_industry_list_response.py | 16 + .../cloudforce_one/test_threat_events.py | 557 ++++++++++ .../cloudforce_one/threat_events/__init__.py | 1 + .../threat_events/test_attackers.py | 84 ++ .../threat_events/test_categories.py | 462 +++++++++ .../threat_events/test_countries.py | 84 ++ .../threat_events/test_crons.py | 146 +++ .../threat_events/test_datasets.py | 454 ++++++++ .../threat_events/test_event_tags.py | 106 ++ .../threat_events/test_indicator_types.py | 84 ++ .../threat_events/test_insights.py | 447 ++++++++ .../cloudforce_one/threat_events/test_raw.py | 258 +++++ .../threat_events/test_relate.py | 106 ++ .../threat_events/test_target_industries.py | 84 ++ 71 files changed, 8463 insertions(+), 1 deletion(-) create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/__init__.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/attackers.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/categories.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/countries.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/crons.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/datasets.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/insights.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/raw.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/relate.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py create mode 100644 src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_bulk_create_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_create_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_create_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_delete_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_edit_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_edit_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_event_get_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/attacker_list_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_create_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_delete_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_edit_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_get_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/category_list_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/country_list_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/cron_edit_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/cron_list_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_create_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_get_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_list_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/event_tag_delete_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/indicator_type_list_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/insight_creat_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/insight_creat_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/insight_delete_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/insight_edit_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/insight_edit_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/insight_get_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/raw_edit_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/raw_get_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/relate_delete_response.py create mode 100644 src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_response.py create mode 100644 tests/api_resources/cloudforce_one/test_threat_events.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/__init__.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_attackers.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_categories.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_countries.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_crons.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_datasets.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_event_tags.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_indicator_types.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_insights.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_raw.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_relate.py create mode 100644 tests/api_resources/cloudforce_one/threat_events/test_target_industries.py diff --git a/.stats.yml b/.stats.yml index 33541268ad2..68a5753ccbb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1576 +configured_endpoints: 1605 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0f0082a0942d9f9edb37ef99423f7cdf16d0bfeb57c6ee5728e830b2a9ebff87.yml diff --git a/api.md b/api.md index 5c637c1451b..f61824a6a6a 100644 --- a/api.md +++ b/api.md @@ -8490,6 +8490,190 @@ Methods: - client.cloudforce_one.requests.assets.delete(asset_identifer, \*, account_identifier, request_identifier) -> AssetDeleteResponse - client.cloudforce_one.requests.assets.get(asset_identifer, \*, account_identifier, request_identifier) -> SyncSinglePage[AssetGetResponse] +## ThreatEvents + +Types: + +```python +from cloudflare.types.cloudforce_one import ( + ThreatEventCreateResponse, + ThreatEventDeleteResponse, + ThreatEventBulkCreateResponse, + ThreatEventEditResponse, + ThreatEventGetResponse, +) +``` + +Methods: + +- client.cloudforce_one.threat_events.create(\*, account_id, \*\*params) -> ThreatEventCreateResponse +- client.cloudforce_one.threat_events.delete(event_id, \*, account_id) -> ThreatEventDeleteResponse +- client.cloudforce_one.threat_events.bulk_create(\*, account_id, \*\*params) -> ThreatEventBulkCreateResponse +- client.cloudforce_one.threat_events.edit(event_id, \*, account_id, \*\*params) -> ThreatEventEditResponse +- client.cloudforce_one.threat_events.get(event_id, \*, account_id) -> ThreatEventGetResponse + +### Attackers + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import AttackerListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.attackers.list(\*, account_id) -> AttackerListResponse + +### Categories + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import ( + CategoryCreateResponse, + CategoryListResponse, + CategoryDeleteResponse, + CategoryEditResponse, + CategoryGetResponse, +) +``` + +Methods: + +- client.cloudforce_one.threat_events.categories.create(\*, account_id, \*\*params) -> CategoryCreateResponse +- client.cloudforce_one.threat_events.categories.list(\*, account_id) -> CategoryListResponse +- client.cloudforce_one.threat_events.categories.delete(category_id, \*, account_id) -> CategoryDeleteResponse +- client.cloudforce_one.threat_events.categories.edit(category_id, \*, account_id, \*\*params) -> CategoryEditResponse +- client.cloudforce_one.threat_events.categories.get(category_id, \*, account_id) -> CategoryGetResponse + +### Countries + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import CountryListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.countries.list(\*, account_id) -> CountryListResponse + +### Crons + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import CronListResponse, CronEditResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.crons.list(\*, account_id) -> CronListResponse +- client.cloudforce_one.threat_events.crons.edit(\*, account_id) -> CronEditResponse + +### Datasets + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import ( + DatasetCreateResponse, + DatasetListResponse, + DatasetEditResponse, + DatasetGetResponse, + DatasetRawResponse, +) +``` + +Methods: + +- client.cloudforce_one.threat_events.datasets.create(\*, account_id, \*\*params) -> DatasetCreateResponse +- client.cloudforce_one.threat_events.datasets.list(\*, account_id) -> DatasetListResponse +- client.cloudforce_one.threat_events.datasets.edit(dataset_id, \*, account_id, \*\*params) -> DatasetEditResponse +- client.cloudforce_one.threat_events.datasets.get(dataset_id, \*, account_id) -> DatasetGetResponse +- client.cloudforce_one.threat_events.datasets.raw(event_id, \*, account_id, dataset_id) -> DatasetRawResponse + +### IndicatorTypes + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import IndicatorTypeListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.indicator_types.list(\*, account_id) -> IndicatorTypeListResponse + +### Raw + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import RawEditResponse, RawGetResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.raw.edit(raw_id, \*, account_id, event_id, \*\*params) -> RawEditResponse +- client.cloudforce_one.threat_events.raw.get(raw_id, \*, account_id, event_id) -> RawGetResponse + +### Relate + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import RelateDeleteResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.relate.delete(event_id, \*, account_id) -> RelateDeleteResponse + +### EventTags + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import EventTagDeleteResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.event_tags.delete(event_id, \*, account_id) -> EventTagDeleteResponse + +### TargetIndustries + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import TargetIndustryListResponse +``` + +Methods: + +- client.cloudforce_one.threat_events.target_industries.list(\*, account_id) -> TargetIndustryListResponse + +### Insights + +Types: + +```python +from cloudflare.types.cloudforce_one.threat_events import ( + InsightDeleteResponse, + InsightCreatResponse, + InsightEditResponse, + InsightGetResponse, +) +``` + +Methods: + +- client.cloudforce_one.threat_events.insights.delete(insight_id, \*, account_id, event_id) -> InsightDeleteResponse +- client.cloudforce_one.threat_events.insights.creat(event_id, \*, account_id, \*\*params) -> InsightCreatResponse +- client.cloudforce_one.threat_events.insights.edit(insight_id, \*, account_id, event_id, \*\*params) -> InsightEditResponse +- client.cloudforce_one.threat_events.insights.get(insight_id, \*, account_id, event_id) -> InsightGetResponse + # AIGateway Types: diff --git a/src/cloudflare/resources/cloudforce_one/__init__.py b/src/cloudflare/resources/cloudforce_one/__init__.py index ad85535e1d2..0a703327c39 100644 --- a/src/cloudflare/resources/cloudforce_one/__init__.py +++ b/src/cloudflare/resources/cloudforce_one/__init__.py @@ -16,6 +16,14 @@ RequestsResourceWithStreamingResponse, AsyncRequestsResourceWithStreamingResponse, ) +from .threat_events import ( + ThreatEventsResource, + AsyncThreatEventsResource, + ThreatEventsResourceWithRawResponse, + AsyncThreatEventsResourceWithRawResponse, + ThreatEventsResourceWithStreamingResponse, + AsyncThreatEventsResourceWithStreamingResponse, +) from .cloudforce_one import ( CloudforceOneResource, AsyncCloudforceOneResource, @@ -38,6 +46,12 @@ "AsyncRequestsResourceWithRawResponse", "RequestsResourceWithStreamingResponse", "AsyncRequestsResourceWithStreamingResponse", + "ThreatEventsResource", + "AsyncThreatEventsResource", + "ThreatEventsResourceWithRawResponse", + "AsyncThreatEventsResourceWithRawResponse", + "ThreatEventsResourceWithStreamingResponse", + "AsyncThreatEventsResourceWithStreamingResponse", "CloudforceOneResource", "AsyncCloudforceOneResource", "CloudforceOneResourceWithRawResponse", diff --git a/src/cloudflare/resources/cloudforce_one/cloudforce_one.py b/src/cloudflare/resources/cloudforce_one/cloudforce_one.py index fbc2bedc7c9..889e3108322 100644 --- a/src/cloudflare/resources/cloudforce_one/cloudforce_one.py +++ b/src/cloudflare/resources/cloudforce_one/cloudforce_one.py @@ -20,6 +20,14 @@ RequestsResourceWithStreamingResponse, AsyncRequestsResourceWithStreamingResponse, ) +from .threat_events.threat_events import ( + ThreatEventsResource, + AsyncThreatEventsResource, + ThreatEventsResourceWithRawResponse, + AsyncThreatEventsResourceWithRawResponse, + ThreatEventsResourceWithStreamingResponse, + AsyncThreatEventsResourceWithStreamingResponse, +) __all__ = ["CloudforceOneResource", "AsyncCloudforceOneResource"] @@ -33,6 +41,10 @@ def scans(self) -> ScansResource: def requests(self) -> RequestsResource: return RequestsResource(self._client) + @cached_property + def threat_events(self) -> ThreatEventsResource: + return ThreatEventsResource(self._client) + @cached_property def with_raw_response(self) -> CloudforceOneResourceWithRawResponse: """ @@ -62,6 +74,10 @@ def scans(self) -> AsyncScansResource: def requests(self) -> AsyncRequestsResource: return AsyncRequestsResource(self._client) + @cached_property + def threat_events(self) -> AsyncThreatEventsResource: + return AsyncThreatEventsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncCloudforceOneResourceWithRawResponse: """ @@ -94,6 +110,10 @@ def scans(self) -> ScansResourceWithRawResponse: def requests(self) -> RequestsResourceWithRawResponse: return RequestsResourceWithRawResponse(self._cloudforce_one.requests) + @cached_property + def threat_events(self) -> ThreatEventsResourceWithRawResponse: + return ThreatEventsResourceWithRawResponse(self._cloudforce_one.threat_events) + class AsyncCloudforceOneResourceWithRawResponse: def __init__(self, cloudforce_one: AsyncCloudforceOneResource) -> None: @@ -107,6 +127,10 @@ def scans(self) -> AsyncScansResourceWithRawResponse: def requests(self) -> AsyncRequestsResourceWithRawResponse: return AsyncRequestsResourceWithRawResponse(self._cloudforce_one.requests) + @cached_property + def threat_events(self) -> AsyncThreatEventsResourceWithRawResponse: + return AsyncThreatEventsResourceWithRawResponse(self._cloudforce_one.threat_events) + class CloudforceOneResourceWithStreamingResponse: def __init__(self, cloudforce_one: CloudforceOneResource) -> None: @@ -120,6 +144,10 @@ def scans(self) -> ScansResourceWithStreamingResponse: def requests(self) -> RequestsResourceWithStreamingResponse: return RequestsResourceWithStreamingResponse(self._cloudforce_one.requests) + @cached_property + def threat_events(self) -> ThreatEventsResourceWithStreamingResponse: + return ThreatEventsResourceWithStreamingResponse(self._cloudforce_one.threat_events) + class AsyncCloudforceOneResourceWithStreamingResponse: def __init__(self, cloudforce_one: AsyncCloudforceOneResource) -> None: @@ -132,3 +160,7 @@ def scans(self) -> AsyncScansResourceWithStreamingResponse: @cached_property def requests(self) -> AsyncRequestsResourceWithStreamingResponse: return AsyncRequestsResourceWithStreamingResponse(self._cloudforce_one.requests) + + @cached_property + def threat_events(self) -> AsyncThreatEventsResourceWithStreamingResponse: + return AsyncThreatEventsResourceWithStreamingResponse(self._cloudforce_one.threat_events) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/__init__.py b/src/cloudflare/resources/cloudforce_one/threat_events/__init__.py new file mode 100644 index 00000000000..c21e2b88f05 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/__init__.py @@ -0,0 +1,173 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .raw import ( + RawResource, + AsyncRawResource, + RawResourceWithRawResponse, + AsyncRawResourceWithRawResponse, + RawResourceWithStreamingResponse, + AsyncRawResourceWithStreamingResponse, +) +from .crons import ( + CronsResource, + AsyncCronsResource, + CronsResourceWithRawResponse, + AsyncCronsResourceWithRawResponse, + CronsResourceWithStreamingResponse, + AsyncCronsResourceWithStreamingResponse, +) +from .relate import ( + RelateResource, + AsyncRelateResource, + RelateResourceWithRawResponse, + AsyncRelateResourceWithRawResponse, + RelateResourceWithStreamingResponse, + AsyncRelateResourceWithStreamingResponse, +) +from .datasets import ( + DatasetsResource, + AsyncDatasetsResource, + DatasetsResourceWithRawResponse, + AsyncDatasetsResourceWithRawResponse, + DatasetsResourceWithStreamingResponse, + AsyncDatasetsResourceWithStreamingResponse, +) +from .insights import ( + InsightsResource, + AsyncInsightsResource, + InsightsResourceWithRawResponse, + AsyncInsightsResourceWithRawResponse, + InsightsResourceWithStreamingResponse, + AsyncInsightsResourceWithStreamingResponse, +) +from .attackers import ( + AttackersResource, + AsyncAttackersResource, + AttackersResourceWithRawResponse, + AsyncAttackersResourceWithRawResponse, + AttackersResourceWithStreamingResponse, + AsyncAttackersResourceWithStreamingResponse, +) +from .countries import ( + CountriesResource, + AsyncCountriesResource, + CountriesResourceWithRawResponse, + AsyncCountriesResourceWithRawResponse, + CountriesResourceWithStreamingResponse, + AsyncCountriesResourceWithStreamingResponse, +) +from .categories import ( + CategoriesResource, + AsyncCategoriesResource, + CategoriesResourceWithRawResponse, + AsyncCategoriesResourceWithRawResponse, + CategoriesResourceWithStreamingResponse, + AsyncCategoriesResourceWithStreamingResponse, +) +from .event_tags import ( + EventTagsResource, + AsyncEventTagsResource, + EventTagsResourceWithRawResponse, + AsyncEventTagsResourceWithRawResponse, + EventTagsResourceWithStreamingResponse, + AsyncEventTagsResourceWithStreamingResponse, +) +from .threat_events import ( + ThreatEventsResource, + AsyncThreatEventsResource, + ThreatEventsResourceWithRawResponse, + AsyncThreatEventsResourceWithRawResponse, + ThreatEventsResourceWithStreamingResponse, + AsyncThreatEventsResourceWithStreamingResponse, +) +from .indicator_types import ( + IndicatorTypesResource, + AsyncIndicatorTypesResource, + IndicatorTypesResourceWithRawResponse, + AsyncIndicatorTypesResourceWithRawResponse, + IndicatorTypesResourceWithStreamingResponse, + AsyncIndicatorTypesResourceWithStreamingResponse, +) +from .target_industries import ( + TargetIndustriesResource, + AsyncTargetIndustriesResource, + TargetIndustriesResourceWithRawResponse, + AsyncTargetIndustriesResourceWithRawResponse, + TargetIndustriesResourceWithStreamingResponse, + AsyncTargetIndustriesResourceWithStreamingResponse, +) + +__all__ = [ + "AttackersResource", + "AsyncAttackersResource", + "AttackersResourceWithRawResponse", + "AsyncAttackersResourceWithRawResponse", + "AttackersResourceWithStreamingResponse", + "AsyncAttackersResourceWithStreamingResponse", + "CategoriesResource", + "AsyncCategoriesResource", + "CategoriesResourceWithRawResponse", + "AsyncCategoriesResourceWithRawResponse", + "CategoriesResourceWithStreamingResponse", + "AsyncCategoriesResourceWithStreamingResponse", + "CountriesResource", + "AsyncCountriesResource", + "CountriesResourceWithRawResponse", + "AsyncCountriesResourceWithRawResponse", + "CountriesResourceWithStreamingResponse", + "AsyncCountriesResourceWithStreamingResponse", + "CronsResource", + "AsyncCronsResource", + "CronsResourceWithRawResponse", + "AsyncCronsResourceWithRawResponse", + "CronsResourceWithStreamingResponse", + "AsyncCronsResourceWithStreamingResponse", + "DatasetsResource", + "AsyncDatasetsResource", + "DatasetsResourceWithRawResponse", + "AsyncDatasetsResourceWithRawResponse", + "DatasetsResourceWithStreamingResponse", + "AsyncDatasetsResourceWithStreamingResponse", + "IndicatorTypesResource", + "AsyncIndicatorTypesResource", + "IndicatorTypesResourceWithRawResponse", + "AsyncIndicatorTypesResourceWithRawResponse", + "IndicatorTypesResourceWithStreamingResponse", + "AsyncIndicatorTypesResourceWithStreamingResponse", + "RawResource", + "AsyncRawResource", + "RawResourceWithRawResponse", + "AsyncRawResourceWithRawResponse", + "RawResourceWithStreamingResponse", + "AsyncRawResourceWithStreamingResponse", + "RelateResource", + "AsyncRelateResource", + "RelateResourceWithRawResponse", + "AsyncRelateResourceWithRawResponse", + "RelateResourceWithStreamingResponse", + "AsyncRelateResourceWithStreamingResponse", + "EventTagsResource", + "AsyncEventTagsResource", + "EventTagsResourceWithRawResponse", + "AsyncEventTagsResourceWithRawResponse", + "EventTagsResourceWithStreamingResponse", + "AsyncEventTagsResourceWithStreamingResponse", + "TargetIndustriesResource", + "AsyncTargetIndustriesResource", + "TargetIndustriesResourceWithRawResponse", + "AsyncTargetIndustriesResourceWithRawResponse", + "TargetIndustriesResourceWithStreamingResponse", + "AsyncTargetIndustriesResourceWithStreamingResponse", + "InsightsResource", + "AsyncInsightsResource", + "InsightsResourceWithRawResponse", + "AsyncInsightsResourceWithRawResponse", + "InsightsResourceWithStreamingResponse", + "AsyncInsightsResourceWithStreamingResponse", + "ThreatEventsResource", + "AsyncThreatEventsResource", + "ThreatEventsResourceWithRawResponse", + "AsyncThreatEventsResourceWithRawResponse", + "ThreatEventsResourceWithStreamingResponse", + "AsyncThreatEventsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py b/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py new file mode 100644 index 00000000000..da282f0e425 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/attackers.py @@ -0,0 +1,163 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events.attacker_list_response import AttackerListResponse + +__all__ = ["AttackersResource", "AsyncAttackersResource"] + + +class AttackersResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AttackersResourceWithRawResponse: + """ + 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 AttackersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AttackersResourceWithStreamingResponse: + """ + 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 AttackersResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: float, + # 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, + ) -> AttackerListResponse: + """ + Lists attackers + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/attackers", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AttackerListResponse, + ) + + +class AsyncAttackersResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAttackersResourceWithRawResponse: + """ + 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 AsyncAttackersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAttackersResourceWithStreamingResponse: + """ + 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 AsyncAttackersResourceWithStreamingResponse(self) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> AttackerListResponse: + """ + Lists attackers + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/attackers", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AttackerListResponse, + ) + + +class AttackersResourceWithRawResponse: + def __init__(self, attackers: AttackersResource) -> None: + self._attackers = attackers + + self.list = to_raw_response_wrapper( + attackers.list, + ) + + +class AsyncAttackersResourceWithRawResponse: + def __init__(self, attackers: AsyncAttackersResource) -> None: + self._attackers = attackers + + self.list = async_to_raw_response_wrapper( + attackers.list, + ) + + +class AttackersResourceWithStreamingResponse: + def __init__(self, attackers: AttackersResource) -> None: + self._attackers = attackers + + self.list = to_streamed_response_wrapper( + attackers.list, + ) + + +class AsyncAttackersResourceWithStreamingResponse: + def __init__(self, attackers: AsyncAttackersResource) -> None: + self._attackers = attackers + + self.list = async_to_streamed_response_wrapper( + attackers.list, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/categories.py b/src/cloudflare/resources/cloudforce_one/threat_events/categories.py new file mode 100644 index 00000000000..59e46feebb3 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/categories.py @@ -0,0 +1,568 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + 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 ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events import category_edit_params, category_create_params +from ....types.cloudforce_one.threat_events.category_get_response import CategoryGetResponse +from ....types.cloudforce_one.threat_events.category_edit_response import CategoryEditResponse +from ....types.cloudforce_one.threat_events.category_list_response import CategoryListResponse +from ....types.cloudforce_one.threat_events.category_create_response import CategoryCreateResponse +from ....types.cloudforce_one.threat_events.category_delete_response import CategoryDeleteResponse + +__all__ = ["CategoriesResource", "AsyncCategoriesResource"] + + +class CategoriesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CategoriesResourceWithRawResponse: + """ + 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 CategoriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CategoriesResourceWithStreamingResponse: + """ + 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 CategoriesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: float, + kill_chain: float, + name: str, + mitre_attack: List[str] | NotGiven = NOT_GIVEN, + shortname: str | NotGiven = NOT_GIVEN, + # 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, + ) -> CategoryCreateResponse: + """ + Creates a new category + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + f"/accounts/{account_id}/cloudforce-one/events/categories/create", + body=maybe_transform( + { + "kill_chain": kill_chain, + "name": name, + "mitre_attack": mitre_attack, + "shortname": shortname, + }, + category_create_params.CategoryCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryCreateResponse, + ) + + def list( + self, + *, + account_id: float, + # 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, + ) -> CategoryListResponse: + """ + Lists categories + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/categories", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryListResponse, + ) + + def delete( + self, + category_id: str, + *, + account_id: float, + # 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, + ) -> CategoryDeleteResponse: + """ + Deletes a category + + Args: + account_id: Account ID + + category_id: Category UUID + + 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 category_id: + raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") + return self._delete( + f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryDeleteResponse, + ) + + def edit( + self, + category_id: str, + *, + account_id: float, + kill_chain: float | NotGiven = NOT_GIVEN, + mitre_attack: List[str] | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + shortname: str | NotGiven = NOT_GIVEN, + # 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, + ) -> CategoryEditResponse: + """ + Updates a category + + Args: + account_id: Account ID + + category_id: Category UUID + + 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 category_id: + raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") + return self._patch( + f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + body=maybe_transform( + { + "kill_chain": kill_chain, + "mitre_attack": mitre_attack, + "name": name, + "shortname": shortname, + }, + category_edit_params.CategoryEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryEditResponse, + ) + + def get( + self, + category_id: str, + *, + account_id: float, + # 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, + ) -> CategoryGetResponse: + """ + Reads a category + + Args: + account_id: Account ID + + category_id: Category UUID + + 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 category_id: + raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryGetResponse, + ) + + +class AsyncCategoriesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCategoriesResourceWithRawResponse: + """ + 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 AsyncCategoriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCategoriesResourceWithStreamingResponse: + """ + 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 AsyncCategoriesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: float, + kill_chain: float, + name: str, + mitre_attack: List[str] | NotGiven = NOT_GIVEN, + shortname: str | NotGiven = NOT_GIVEN, + # 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, + ) -> CategoryCreateResponse: + """ + Creates a new category + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + f"/accounts/{account_id}/cloudforce-one/events/categories/create", + body=await async_maybe_transform( + { + "kill_chain": kill_chain, + "name": name, + "mitre_attack": mitre_attack, + "shortname": shortname, + }, + category_create_params.CategoryCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryCreateResponse, + ) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> CategoryListResponse: + """ + Lists categories + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/categories", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryListResponse, + ) + + async def delete( + self, + category_id: str, + *, + account_id: float, + # 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, + ) -> CategoryDeleteResponse: + """ + Deletes a category + + Args: + account_id: Account ID + + category_id: Category UUID + + 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 category_id: + raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") + return await self._delete( + f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryDeleteResponse, + ) + + async def edit( + self, + category_id: str, + *, + account_id: float, + kill_chain: float | NotGiven = NOT_GIVEN, + mitre_attack: List[str] | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + shortname: str | NotGiven = NOT_GIVEN, + # 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, + ) -> CategoryEditResponse: + """ + Updates a category + + Args: + account_id: Account ID + + category_id: Category UUID + + 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 category_id: + raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") + return await self._patch( + f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + body=await async_maybe_transform( + { + "kill_chain": kill_chain, + "mitre_attack": mitre_attack, + "name": name, + "shortname": shortname, + }, + category_edit_params.CategoryEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryEditResponse, + ) + + async def get( + self, + category_id: str, + *, + account_id: float, + # 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, + ) -> CategoryGetResponse: + """ + Reads a category + + Args: + account_id: Account ID + + category_id: Category UUID + + 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 category_id: + raise ValueError(f"Expected a non-empty value for `category_id` but received {category_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/categories/{category_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CategoryGetResponse, + ) + + +class CategoriesResourceWithRawResponse: + def __init__(self, categories: CategoriesResource) -> None: + self._categories = categories + + self.create = to_raw_response_wrapper( + categories.create, + ) + self.list = to_raw_response_wrapper( + categories.list, + ) + self.delete = to_raw_response_wrapper( + categories.delete, + ) + self.edit = to_raw_response_wrapper( + categories.edit, + ) + self.get = to_raw_response_wrapper( + categories.get, + ) + + +class AsyncCategoriesResourceWithRawResponse: + def __init__(self, categories: AsyncCategoriesResource) -> None: + self._categories = categories + + self.create = async_to_raw_response_wrapper( + categories.create, + ) + self.list = async_to_raw_response_wrapper( + categories.list, + ) + self.delete = async_to_raw_response_wrapper( + categories.delete, + ) + self.edit = async_to_raw_response_wrapper( + categories.edit, + ) + self.get = async_to_raw_response_wrapper( + categories.get, + ) + + +class CategoriesResourceWithStreamingResponse: + def __init__(self, categories: CategoriesResource) -> None: + self._categories = categories + + self.create = to_streamed_response_wrapper( + categories.create, + ) + self.list = to_streamed_response_wrapper( + categories.list, + ) + self.delete = to_streamed_response_wrapper( + categories.delete, + ) + self.edit = to_streamed_response_wrapper( + categories.edit, + ) + self.get = to_streamed_response_wrapper( + categories.get, + ) + + +class AsyncCategoriesResourceWithStreamingResponse: + def __init__(self, categories: AsyncCategoriesResource) -> None: + self._categories = categories + + self.create = async_to_streamed_response_wrapper( + categories.create, + ) + self.list = async_to_streamed_response_wrapper( + categories.list, + ) + self.delete = async_to_streamed_response_wrapper( + categories.delete, + ) + self.edit = async_to_streamed_response_wrapper( + categories.edit, + ) + self.get = async_to_streamed_response_wrapper( + categories.get, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/countries.py b/src/cloudflare/resources/cloudforce_one/threat_events/countries.py new file mode 100644 index 00000000000..fbca6174134 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/countries.py @@ -0,0 +1,163 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events.country_list_response import CountryListResponse + +__all__ = ["CountriesResource", "AsyncCountriesResource"] + + +class CountriesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CountriesResourceWithRawResponse: + """ + 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 CountriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CountriesResourceWithStreamingResponse: + """ + 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 CountriesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: float, + # 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, + ) -> CountryListResponse: + """ + Retrieves countries information for all countries + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/countries", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CountryListResponse, + ) + + +class AsyncCountriesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCountriesResourceWithRawResponse: + """ + 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 AsyncCountriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCountriesResourceWithStreamingResponse: + """ + 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 AsyncCountriesResourceWithStreamingResponse(self) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> CountryListResponse: + """ + Retrieves countries information for all countries + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/countries", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CountryListResponse, + ) + + +class CountriesResourceWithRawResponse: + def __init__(self, countries: CountriesResource) -> None: + self._countries = countries + + self.list = to_raw_response_wrapper( + countries.list, + ) + + +class AsyncCountriesResourceWithRawResponse: + def __init__(self, countries: AsyncCountriesResource) -> None: + self._countries = countries + + self.list = async_to_raw_response_wrapper( + countries.list, + ) + + +class CountriesResourceWithStreamingResponse: + def __init__(self, countries: CountriesResource) -> None: + self._countries = countries + + self.list = to_streamed_response_wrapper( + countries.list, + ) + + +class AsyncCountriesResourceWithStreamingResponse: + def __init__(self, countries: AsyncCountriesResource) -> None: + self._countries = countries + + self.list = async_to_streamed_response_wrapper( + countries.list, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/crons.py b/src/cloudflare/resources/cloudforce_one/threat_events/crons.py new file mode 100644 index 00000000000..dc1c25c03a1 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/crons.py @@ -0,0 +1,242 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events.cron_edit_response import CronEditResponse +from ....types.cloudforce_one.threat_events.cron_list_response import CronListResponse + +__all__ = ["CronsResource", "AsyncCronsResource"] + + +class CronsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CronsResourceWithRawResponse: + """ + 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 CronsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CronsResourceWithStreamingResponse: + """ + 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 CronsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: float, + # 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, + ) -> CronListResponse: + """ + Reads the last cron update time + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/cron", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CronListResponse, + ) + + def edit( + self, + *, + account_id: float, + # 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, + ) -> CronEditResponse: + """ + Reads the last cron update time + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._patch( + f"/accounts/{account_id}/cloudforce-one/events/cron", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CronEditResponse, + ) + + +class AsyncCronsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCronsResourceWithRawResponse: + """ + 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 AsyncCronsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCronsResourceWithStreamingResponse: + """ + 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 AsyncCronsResourceWithStreamingResponse(self) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> CronListResponse: + """ + Reads the last cron update time + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/cron", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CronListResponse, + ) + + async def edit( + self, + *, + account_id: float, + # 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, + ) -> CronEditResponse: + """ + Reads the last cron update time + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._patch( + f"/accounts/{account_id}/cloudforce-one/events/cron", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=CronEditResponse, + ) + + +class CronsResourceWithRawResponse: + def __init__(self, crons: CronsResource) -> None: + self._crons = crons + + self.list = to_raw_response_wrapper( + crons.list, + ) + self.edit = to_raw_response_wrapper( + crons.edit, + ) + + +class AsyncCronsResourceWithRawResponse: + def __init__(self, crons: AsyncCronsResource) -> None: + self._crons = crons + + self.list = async_to_raw_response_wrapper( + crons.list, + ) + self.edit = async_to_raw_response_wrapper( + crons.edit, + ) + + +class CronsResourceWithStreamingResponse: + def __init__(self, crons: CronsResource) -> None: + self._crons = crons + + self.list = to_streamed_response_wrapper( + crons.list, + ) + self.edit = to_streamed_response_wrapper( + crons.edit, + ) + + +class AsyncCronsResourceWithStreamingResponse: + def __init__(self, crons: AsyncCronsResource) -> None: + self._crons = crons + + self.list = async_to_streamed_response_wrapper( + crons.list, + ) + self.edit = async_to_streamed_response_wrapper( + crons.edit, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/datasets.py b/src/cloudflare/resources/cloudforce_one/threat_events/datasets.py new file mode 100644 index 00000000000..060a30e2816 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/datasets.py @@ -0,0 +1,580 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + 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 ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events import dataset_edit_params, dataset_create_params +from ....types.cloudforce_one.threat_events.dataset_get_response import DatasetGetResponse +from ....types.cloudforce_one.threat_events.dataset_raw_response import DatasetRawResponse +from ....types.cloudforce_one.threat_events.dataset_edit_response import DatasetEditResponse +from ....types.cloudforce_one.threat_events.dataset_list_response import DatasetListResponse +from ....types.cloudforce_one.threat_events.dataset_create_response import DatasetCreateResponse + +__all__ = ["DatasetsResource", "AsyncDatasetsResource"] + + +class DatasetsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DatasetsResourceWithRawResponse: + """ + 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 DatasetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse: + """ + 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 DatasetsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: float, + is_public: bool, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DatasetCreateResponse: + """ + Creates a dataset + + Args: + account_id: Account ID + + is_public: If true, then anyone can search the dataset. If false, then its limited to the + account. + + name: Used to describe the dataset within the account context + + 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._post( + f"/accounts/{account_id}/cloudforce-one/events/dataset/create", + body=maybe_transform( + { + "is_public": is_public, + "name": name, + }, + dataset_create_params.DatasetCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetCreateResponse, + ) + + def list( + self, + *, + account_id: float, + # 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, + ) -> DatasetListResponse: + """ + Lists all datasets in an account + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/dataset", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetListResponse, + ) + + def edit( + self, + dataset_id: str, + *, + account_id: float, + is_public: bool, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DatasetEditResponse: + """ + Updates an existing dataset + + Args: + account_id: Account ID + + dataset_id: Dataset ID + + is_public: If true, then anyone can search the dataset. If false, then its limited to the + account. + + name: Used to describe the dataset within the account context + + 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 dataset_id: + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + return self._patch( + f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + body=maybe_transform( + { + "is_public": is_public, + "name": name, + }, + dataset_edit_params.DatasetEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetEditResponse, + ) + + def get( + self, + dataset_id: str, + *, + account_id: float, + # 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, + ) -> DatasetGetResponse: + """ + Reads a dataset + + Args: + account_id: Account ID + + dataset_id: Dataset ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not dataset_id: + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetGetResponse, + ) + + def raw( + self, + event_id: str, + *, + account_id: float, + dataset_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DatasetRawResponse: + """ + Reads data for a raw event + + Args: + account_id: Account ID + + dataset_id: Dataset ID + + event_id: Event ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not dataset_id: + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + if not event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetRawResponse, + ) + + +class AsyncDatasetsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDatasetsResourceWithRawResponse: + """ + 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 AsyncDatasetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDatasetsResourceWithStreamingResponse: + """ + 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 AsyncDatasetsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: float, + is_public: bool, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DatasetCreateResponse: + """ + Creates a dataset + + Args: + account_id: Account ID + + is_public: If true, then anyone can search the dataset. If false, then its limited to the + account. + + name: Used to describe the dataset within the account context + + 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._post( + f"/accounts/{account_id}/cloudforce-one/events/dataset/create", + body=await async_maybe_transform( + { + "is_public": is_public, + "name": name, + }, + dataset_create_params.DatasetCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetCreateResponse, + ) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> DatasetListResponse: + """ + Lists all datasets in an account + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/dataset", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetListResponse, + ) + + async def edit( + self, + dataset_id: str, + *, + account_id: float, + is_public: bool, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DatasetEditResponse: + """ + Updates an existing dataset + + Args: + account_id: Account ID + + dataset_id: Dataset ID + + is_public: If true, then anyone can search the dataset. If false, then its limited to the + account. + + name: Used to describe the dataset within the account context + + 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 dataset_id: + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + return await self._patch( + f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + body=await async_maybe_transform( + { + "is_public": is_public, + "name": name, + }, + dataset_edit_params.DatasetEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetEditResponse, + ) + + async def get( + self, + dataset_id: str, + *, + account_id: float, + # 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, + ) -> DatasetGetResponse: + """ + Reads a dataset + + Args: + account_id: Account ID + + dataset_id: Dataset ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not dataset_id: + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetGetResponse, + ) + + async def raw( + self, + event_id: str, + *, + account_id: float, + dataset_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DatasetRawResponse: + """ + Reads data for a raw event + + Args: + account_id: Account ID + + dataset_id: Dataset ID + + event_id: Event ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not dataset_id: + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") + if not event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/raw/{dataset_id}/{event_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasetRawResponse, + ) + + +class DatasetsResourceWithRawResponse: + def __init__(self, datasets: DatasetsResource) -> None: + self._datasets = datasets + + self.create = to_raw_response_wrapper( + datasets.create, + ) + self.list = to_raw_response_wrapper( + datasets.list, + ) + self.edit = to_raw_response_wrapper( + datasets.edit, + ) + self.get = to_raw_response_wrapper( + datasets.get, + ) + self.raw = to_raw_response_wrapper( + datasets.raw, + ) + + +class AsyncDatasetsResourceWithRawResponse: + def __init__(self, datasets: AsyncDatasetsResource) -> None: + self._datasets = datasets + + self.create = async_to_raw_response_wrapper( + datasets.create, + ) + self.list = async_to_raw_response_wrapper( + datasets.list, + ) + self.edit = async_to_raw_response_wrapper( + datasets.edit, + ) + self.get = async_to_raw_response_wrapper( + datasets.get, + ) + self.raw = async_to_raw_response_wrapper( + datasets.raw, + ) + + +class DatasetsResourceWithStreamingResponse: + def __init__(self, datasets: DatasetsResource) -> None: + self._datasets = datasets + + self.create = to_streamed_response_wrapper( + datasets.create, + ) + self.list = to_streamed_response_wrapper( + datasets.list, + ) + self.edit = to_streamed_response_wrapper( + datasets.edit, + ) + self.get = to_streamed_response_wrapper( + datasets.get, + ) + self.raw = to_streamed_response_wrapper( + datasets.raw, + ) + + +class AsyncDatasetsResourceWithStreamingResponse: + def __init__(self, datasets: AsyncDatasetsResource) -> None: + self._datasets = datasets + + self.create = async_to_streamed_response_wrapper( + datasets.create, + ) + self.list = async_to_streamed_response_wrapper( + datasets.list, + ) + self.edit = async_to_streamed_response_wrapper( + datasets.edit, + ) + self.get = async_to_streamed_response_wrapper( + datasets.get, + ) + self.raw = async_to_streamed_response_wrapper( + datasets.raw, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py b/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py new file mode 100644 index 00000000000..8231dff29a2 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/event_tags.py @@ -0,0 +1,184 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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.cloudforce_one.threat_events.event_tag_delete_response import EventTagDeleteResponse + +__all__ = ["EventTagsResource", "AsyncEventTagsResource"] + + +class EventTagsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> EventTagsResourceWithRawResponse: + """ + 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 EventTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> EventTagsResourceWithStreamingResponse: + """ + 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 EventTagsResourceWithStreamingResponse(self) + + def delete( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> EventTagDeleteResponse: + """ + Removes a tag from an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._delete( + f"/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EventTagDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[EventTagDeleteResponse], ResultWrapper[EventTagDeleteResponse]), + ) + + +class AsyncEventTagsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncEventTagsResourceWithRawResponse: + """ + 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 AsyncEventTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncEventTagsResourceWithStreamingResponse: + """ + 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 AsyncEventTagsResourceWithStreamingResponse(self) + + async def delete( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> EventTagDeleteResponse: + """ + Removes a tag from an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._delete( + f"/accounts/{account_id}/cloudforce-one/events/event_tag/{event_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EventTagDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[EventTagDeleteResponse], ResultWrapper[EventTagDeleteResponse]), + ) + + +class EventTagsResourceWithRawResponse: + def __init__(self, event_tags: EventTagsResource) -> None: + self._event_tags = event_tags + + self.delete = to_raw_response_wrapper( + event_tags.delete, + ) + + +class AsyncEventTagsResourceWithRawResponse: + def __init__(self, event_tags: AsyncEventTagsResource) -> None: + self._event_tags = event_tags + + self.delete = async_to_raw_response_wrapper( + event_tags.delete, + ) + + +class EventTagsResourceWithStreamingResponse: + def __init__(self, event_tags: EventTagsResource) -> None: + self._event_tags = event_tags + + self.delete = to_streamed_response_wrapper( + event_tags.delete, + ) + + +class AsyncEventTagsResourceWithStreamingResponse: + def __init__(self, event_tags: AsyncEventTagsResource) -> None: + self._event_tags = event_tags + + self.delete = async_to_streamed_response_wrapper( + event_tags.delete, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py b/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py new file mode 100644 index 00000000000..a5682dd2cf9 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/indicator_types.py @@ -0,0 +1,163 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events.indicator_type_list_response import IndicatorTypeListResponse + +__all__ = ["IndicatorTypesResource", "AsyncIndicatorTypesResource"] + + +class IndicatorTypesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IndicatorTypesResourceWithRawResponse: + """ + 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 IndicatorTypesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IndicatorTypesResourceWithStreamingResponse: + """ + 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 IndicatorTypesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: float, + # 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, + ) -> IndicatorTypeListResponse: + """ + Lists all indicator types + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/indicatorTypes", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=IndicatorTypeListResponse, + ) + + +class AsyncIndicatorTypesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIndicatorTypesResourceWithRawResponse: + """ + 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 AsyncIndicatorTypesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIndicatorTypesResourceWithStreamingResponse: + """ + 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 AsyncIndicatorTypesResourceWithStreamingResponse(self) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> IndicatorTypeListResponse: + """ + Lists all indicator types + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/indicatorTypes", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=IndicatorTypeListResponse, + ) + + +class IndicatorTypesResourceWithRawResponse: + def __init__(self, indicator_types: IndicatorTypesResource) -> None: + self._indicator_types = indicator_types + + self.list = to_raw_response_wrapper( + indicator_types.list, + ) + + +class AsyncIndicatorTypesResourceWithRawResponse: + def __init__(self, indicator_types: AsyncIndicatorTypesResource) -> None: + self._indicator_types = indicator_types + + self.list = async_to_raw_response_wrapper( + indicator_types.list, + ) + + +class IndicatorTypesResourceWithStreamingResponse: + def __init__(self, indicator_types: IndicatorTypesResource) -> None: + self._indicator_types = indicator_types + + self.list = to_streamed_response_wrapper( + indicator_types.list, + ) + + +class AsyncIndicatorTypesResourceWithStreamingResponse: + def __init__(self, indicator_types: AsyncIndicatorTypesResource) -> None: + self._indicator_types = indicator_types + + self.list = async_to_streamed_response_wrapper( + indicator_types.list, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/insights.py b/src/cloudflare/resources/cloudforce_one/threat_events/insights.py new file mode 100644 index 00000000000..698b01e01fd --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/insights.py @@ -0,0 +1,518 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + 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.cloudforce_one.threat_events import insight_edit_params, insight_creat_params +from ....types.cloudforce_one.threat_events.insight_get_response import InsightGetResponse +from ....types.cloudforce_one.threat_events.insight_edit_response import InsightEditResponse +from ....types.cloudforce_one.threat_events.insight_creat_response import InsightCreatResponse +from ....types.cloudforce_one.threat_events.insight_delete_response import InsightDeleteResponse + +__all__ = ["InsightsResource", "AsyncInsightsResource"] + + +class InsightsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> InsightsResourceWithRawResponse: + """ + 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 InsightsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> InsightsResourceWithStreamingResponse: + """ + 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 InsightsResourceWithStreamingResponse(self) + + def delete( + self, + insight_id: str, + *, + account_id: float, + event_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightDeleteResponse: + """ + Deletes an event insight + + Args: + account_id: Account ID + + event_id: Event UUID + + insight_id: Insight UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not insight_id: + raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") + return self._delete( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/{insight_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[InsightDeleteResponse], ResultWrapper[InsightDeleteResponse]), + ) + + def creat( + self, + event_id: str, + *, + account_id: float, + content: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightCreatResponse: + """ + Adds an insight to an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._post( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/create", + body=maybe_transform({"content": content}, insight_creat_params.InsightCreatParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightCreatResponse]._unwrapper, + ), + cast_to=cast(Type[InsightCreatResponse], ResultWrapper[InsightCreatResponse]), + ) + + def edit( + self, + insight_id: str, + *, + account_id: float, + event_id: str, + content: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightEditResponse: + """ + Updates an event insight + + Args: + account_id: Account ID + + event_id: Event UUID + + insight_id: Insight UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not insight_id: + raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") + return self._patch( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/{insight_id}", + body=maybe_transform({"content": content}, insight_edit_params.InsightEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightEditResponse]._unwrapper, + ), + cast_to=cast(Type[InsightEditResponse], ResultWrapper[InsightEditResponse]), + ) + + def get( + self, + insight_id: str, + *, + account_id: float, + event_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightGetResponse: + """ + Reads an event insight + + Args: + account_id: Account ID + + event_id: Event UUID + + insight_id: Insight UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not insight_id: + raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/{insight_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightGetResponse]._unwrapper, + ), + cast_to=cast(Type[InsightGetResponse], ResultWrapper[InsightGetResponse]), + ) + + +class AsyncInsightsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncInsightsResourceWithRawResponse: + """ + 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 AsyncInsightsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncInsightsResourceWithStreamingResponse: + """ + 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 AsyncInsightsResourceWithStreamingResponse(self) + + async def delete( + self, + insight_id: str, + *, + account_id: float, + event_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightDeleteResponse: + """ + Deletes an event insight + + Args: + account_id: Account ID + + event_id: Event UUID + + insight_id: Insight UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not insight_id: + raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") + return await self._delete( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/{insight_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[InsightDeleteResponse], ResultWrapper[InsightDeleteResponse]), + ) + + async def creat( + self, + event_id: str, + *, + account_id: float, + content: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightCreatResponse: + """ + Adds an insight to an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._post( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/create", + body=await async_maybe_transform({"content": content}, insight_creat_params.InsightCreatParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightCreatResponse]._unwrapper, + ), + cast_to=cast(Type[InsightCreatResponse], ResultWrapper[InsightCreatResponse]), + ) + + async def edit( + self, + insight_id: str, + *, + account_id: float, + event_id: str, + content: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightEditResponse: + """ + Updates an event insight + + Args: + account_id: Account ID + + event_id: Event UUID + + insight_id: Insight UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not insight_id: + raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") + return await self._patch( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/{insight_id}", + body=await async_maybe_transform({"content": content}, insight_edit_params.InsightEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightEditResponse]._unwrapper, + ), + cast_to=cast(Type[InsightEditResponse], ResultWrapper[InsightEditResponse]), + ) + + async def get( + self, + insight_id: str, + *, + account_id: float, + event_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> InsightGetResponse: + """ + Reads an event insight + + Args: + account_id: Account ID + + event_id: Event UUID + + insight_id: Insight UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not insight_id: + raise ValueError(f"Expected a non-empty value for `insight_id` but received {insight_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/insight/{insight_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InsightGetResponse]._unwrapper, + ), + cast_to=cast(Type[InsightGetResponse], ResultWrapper[InsightGetResponse]), + ) + + +class InsightsResourceWithRawResponse: + def __init__(self, insights: InsightsResource) -> None: + self._insights = insights + + self.delete = to_raw_response_wrapper( + insights.delete, + ) + self.creat = to_raw_response_wrapper( + insights.creat, + ) + self.edit = to_raw_response_wrapper( + insights.edit, + ) + self.get = to_raw_response_wrapper( + insights.get, + ) + + +class AsyncInsightsResourceWithRawResponse: + def __init__(self, insights: AsyncInsightsResource) -> None: + self._insights = insights + + self.delete = async_to_raw_response_wrapper( + insights.delete, + ) + self.creat = async_to_raw_response_wrapper( + insights.creat, + ) + self.edit = async_to_raw_response_wrapper( + insights.edit, + ) + self.get = async_to_raw_response_wrapper( + insights.get, + ) + + +class InsightsResourceWithStreamingResponse: + def __init__(self, insights: InsightsResource) -> None: + self._insights = insights + + self.delete = to_streamed_response_wrapper( + insights.delete, + ) + self.creat = to_streamed_response_wrapper( + insights.creat, + ) + self.edit = to_streamed_response_wrapper( + insights.edit, + ) + self.get = to_streamed_response_wrapper( + insights.get, + ) + + +class AsyncInsightsResourceWithStreamingResponse: + def __init__(self, insights: AsyncInsightsResource) -> None: + self._insights = insights + + self.delete = async_to_streamed_response_wrapper( + insights.delete, + ) + self.creat = async_to_streamed_response_wrapper( + insights.creat, + ) + self.edit = async_to_streamed_response_wrapper( + insights.edit, + ) + self.get = async_to_streamed_response_wrapper( + insights.get, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/raw.py b/src/cloudflare/resources/cloudforce_one/threat_events/raw.py new file mode 100644 index 00000000000..74d2a12db10 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/raw.py @@ -0,0 +1,309 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + 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 ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events import raw_edit_params +from ....types.cloudforce_one.threat_events.raw_get_response import RawGetResponse +from ....types.cloudforce_one.threat_events.raw_edit_response import RawEditResponse + +__all__ = ["RawResource", "AsyncRawResource"] + + +class RawResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RawResourceWithRawResponse: + """ + 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 RawResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RawResourceWithStreamingResponse: + """ + 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 RawResourceWithStreamingResponse(self) + + def edit( + self, + raw_id: str, + *, + account_id: float, + event_id: str, + data: object | NotGiven = NOT_GIVEN, + source: str | NotGiven = NOT_GIVEN, + tlp: str | NotGiven = NOT_GIVEN, + # 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, + ) -> RawEditResponse: + """ + Updates a raw event + + Args: + account_id: Account ID + + event_id: Event UUID + + raw_id: Raw Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not raw_id: + raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") + return self._patch( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + body=maybe_transform( + { + "data": data, + "source": source, + "tlp": tlp, + }, + raw_edit_params.RawEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RawEditResponse, + ) + + def get( + self, + raw_id: str, + *, + account_id: float, + event_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RawGetResponse: + """ + Reads data for a raw event + + Args: + account_id: Account ID + + event_id: Event UUID + + raw_id: Raw Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not raw_id: + raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RawGetResponse, + ) + + +class AsyncRawResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRawResourceWithRawResponse: + """ + 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 AsyncRawResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRawResourceWithStreamingResponse: + """ + 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 AsyncRawResourceWithStreamingResponse(self) + + async def edit( + self, + raw_id: str, + *, + account_id: float, + event_id: str, + data: object | NotGiven = NOT_GIVEN, + source: str | NotGiven = NOT_GIVEN, + tlp: str | NotGiven = NOT_GIVEN, + # 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, + ) -> RawEditResponse: + """ + Updates a raw event + + Args: + account_id: Account ID + + event_id: Event UUID + + raw_id: Raw Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not raw_id: + raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") + return await self._patch( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + body=await async_maybe_transform( + { + "data": data, + "source": source, + "tlp": tlp, + }, + raw_edit_params.RawEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RawEditResponse, + ) + + async def get( + self, + raw_id: str, + *, + account_id: float, + event_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RawGetResponse: + """ + Reads data for a raw event + + Args: + account_id: Account ID + + event_id: Event UUID + + raw_id: Raw Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + if not raw_id: + raise ValueError(f"Expected a non-empty value for `raw_id` but received {raw_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}/raw/{raw_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RawGetResponse, + ) + + +class RawResourceWithRawResponse: + def __init__(self, raw: RawResource) -> None: + self._raw = raw + + self.edit = to_raw_response_wrapper( + raw.edit, + ) + self.get = to_raw_response_wrapper( + raw.get, + ) + + +class AsyncRawResourceWithRawResponse: + def __init__(self, raw: AsyncRawResource) -> None: + self._raw = raw + + self.edit = async_to_raw_response_wrapper( + raw.edit, + ) + self.get = async_to_raw_response_wrapper( + raw.get, + ) + + +class RawResourceWithStreamingResponse: + def __init__(self, raw: RawResource) -> None: + self._raw = raw + + self.edit = to_streamed_response_wrapper( + raw.edit, + ) + self.get = to_streamed_response_wrapper( + raw.get, + ) + + +class AsyncRawResourceWithStreamingResponse: + def __init__(self, raw: AsyncRawResource) -> None: + self._raw = raw + + self.edit = async_to_streamed_response_wrapper( + raw.edit, + ) + self.get = async_to_streamed_response_wrapper( + raw.get, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/relate.py b/src/cloudflare/resources/cloudforce_one/threat_events/relate.py new file mode 100644 index 00000000000..3e8644a7e39 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/relate.py @@ -0,0 +1,184 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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.cloudforce_one.threat_events.relate_delete_response import RelateDeleteResponse + +__all__ = ["RelateResource", "AsyncRelateResource"] + + +class RelateResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RelateResourceWithRawResponse: + """ + 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 RelateResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RelateResourceWithStreamingResponse: + """ + 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 RelateResourceWithStreamingResponse(self) + + def delete( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> RelateDeleteResponse: + """ + Removes an event reference + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._delete( + f"/accounts/{account_id}/cloudforce-one/events/relate/{event_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RelateDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[RelateDeleteResponse], ResultWrapper[RelateDeleteResponse]), + ) + + +class AsyncRelateResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRelateResourceWithRawResponse: + """ + 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 AsyncRelateResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRelateResourceWithStreamingResponse: + """ + 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 AsyncRelateResourceWithStreamingResponse(self) + + async def delete( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> RelateDeleteResponse: + """ + Removes an event reference + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._delete( + f"/accounts/{account_id}/cloudforce-one/events/relate/{event_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RelateDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[RelateDeleteResponse], ResultWrapper[RelateDeleteResponse]), + ) + + +class RelateResourceWithRawResponse: + def __init__(self, relate: RelateResource) -> None: + self._relate = relate + + self.delete = to_raw_response_wrapper( + relate.delete, + ) + + +class AsyncRelateResourceWithRawResponse: + def __init__(self, relate: AsyncRelateResource) -> None: + self._relate = relate + + self.delete = async_to_raw_response_wrapper( + relate.delete, + ) + + +class RelateResourceWithStreamingResponse: + def __init__(self, relate: RelateResource) -> None: + self._relate = relate + + self.delete = to_streamed_response_wrapper( + relate.delete, + ) + + +class AsyncRelateResourceWithStreamingResponse: + def __init__(self, relate: AsyncRelateResource) -> None: + self._relate = relate + + self.delete = async_to_streamed_response_wrapper( + relate.delete, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py b/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py new file mode 100644 index 00000000000..6c608ffd8d4 --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/target_industries.py @@ -0,0 +1,163 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.cloudforce_one.threat_events.target_industry_list_response import TargetIndustryListResponse + +__all__ = ["TargetIndustriesResource", "AsyncTargetIndustriesResource"] + + +class TargetIndustriesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TargetIndustriesResourceWithRawResponse: + """ + 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 TargetIndustriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TargetIndustriesResourceWithStreamingResponse: + """ + 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 TargetIndustriesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: float, + # 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, + ) -> TargetIndustryListResponse: + """ + Lists all target industries + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/targetIndustries", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetIndustryListResponse, + ) + + +class AsyncTargetIndustriesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTargetIndustriesResourceWithRawResponse: + """ + 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 AsyncTargetIndustriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTargetIndustriesResourceWithStreamingResponse: + """ + 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 AsyncTargetIndustriesResourceWithStreamingResponse(self) + + async def list( + self, + *, + account_id: float, + # 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, + ) -> TargetIndustryListResponse: + """ + Lists all target industries + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/targetIndustries", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetIndustryListResponse, + ) + + +class TargetIndustriesResourceWithRawResponse: + def __init__(self, target_industries: TargetIndustriesResource) -> None: + self._target_industries = target_industries + + self.list = to_raw_response_wrapper( + target_industries.list, + ) + + +class AsyncTargetIndustriesResourceWithRawResponse: + def __init__(self, target_industries: AsyncTargetIndustriesResource) -> None: + self._target_industries = target_industries + + self.list = async_to_raw_response_wrapper( + target_industries.list, + ) + + +class TargetIndustriesResourceWithStreamingResponse: + def __init__(self, target_industries: TargetIndustriesResource) -> None: + self._target_industries = target_industries + + self.list = to_streamed_response_wrapper( + target_industries.list, + ) + + +class AsyncTargetIndustriesResourceWithStreamingResponse: + def __init__(self, target_industries: AsyncTargetIndustriesResource) -> None: + self._target_industries = target_industries + + self.list = async_to_streamed_response_wrapper( + target_industries.list, + ) diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py b/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py new file mode 100644 index 00000000000..906ca57ef5c --- /dev/null +++ b/src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py @@ -0,0 +1,976 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Iterable +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from .raw import ( + RawResource, + AsyncRawResource, + RawResourceWithRawResponse, + AsyncRawResourceWithRawResponse, + RawResourceWithStreamingResponse, + AsyncRawResourceWithStreamingResponse, +) +from .crons import ( + CronsResource, + AsyncCronsResource, + CronsResourceWithRawResponse, + AsyncCronsResourceWithRawResponse, + CronsResourceWithStreamingResponse, + AsyncCronsResourceWithStreamingResponse, +) +from .relate import ( + RelateResource, + AsyncRelateResource, + RelateResourceWithRawResponse, + AsyncRelateResourceWithRawResponse, + RelateResourceWithStreamingResponse, + AsyncRelateResourceWithStreamingResponse, +) +from .datasets import ( + DatasetsResource, + AsyncDatasetsResource, + DatasetsResourceWithRawResponse, + AsyncDatasetsResourceWithRawResponse, + DatasetsResourceWithStreamingResponse, + AsyncDatasetsResourceWithStreamingResponse, +) +from .insights import ( + InsightsResource, + AsyncInsightsResource, + InsightsResourceWithRawResponse, + AsyncInsightsResourceWithRawResponse, + InsightsResourceWithStreamingResponse, + AsyncInsightsResourceWithStreamingResponse, +) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from .attackers import ( + AttackersResource, + AsyncAttackersResource, + AttackersResourceWithRawResponse, + AsyncAttackersResourceWithRawResponse, + AttackersResourceWithStreamingResponse, + AsyncAttackersResourceWithStreamingResponse, +) +from .countries import ( + CountriesResource, + AsyncCountriesResource, + CountriesResourceWithRawResponse, + AsyncCountriesResourceWithRawResponse, + CountriesResourceWithStreamingResponse, + AsyncCountriesResourceWithStreamingResponse, +) +from ...._compat import cached_property +from .categories import ( + CategoriesResource, + AsyncCategoriesResource, + CategoriesResourceWithRawResponse, + AsyncCategoriesResourceWithRawResponse, + CategoriesResourceWithStreamingResponse, + AsyncCategoriesResourceWithStreamingResponse, +) +from .event_tags import ( + EventTagsResource, + AsyncEventTagsResource, + EventTagsResourceWithRawResponse, + AsyncEventTagsResourceWithRawResponse, + EventTagsResourceWithStreamingResponse, + AsyncEventTagsResourceWithStreamingResponse, +) +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from .indicator_types import ( + IndicatorTypesResource, + AsyncIndicatorTypesResource, + IndicatorTypesResourceWithRawResponse, + AsyncIndicatorTypesResourceWithRawResponse, + IndicatorTypesResourceWithStreamingResponse, + AsyncIndicatorTypesResourceWithStreamingResponse, +) +from .target_industries import ( + TargetIndustriesResource, + AsyncTargetIndustriesResource, + TargetIndustriesResourceWithRawResponse, + AsyncTargetIndustriesResourceWithRawResponse, + TargetIndustriesResourceWithStreamingResponse, + AsyncTargetIndustriesResourceWithStreamingResponse, +) +from ....types.cloudforce_one import ( + threat_event_edit_params, + threat_event_create_params, + threat_event_bulk_create_params, +) +from ....types.cloudforce_one.threat_event_get_response import ThreatEventGetResponse +from ....types.cloudforce_one.threat_event_edit_response import ThreatEventEditResponse +from ....types.cloudforce_one.threat_event_create_response import ThreatEventCreateResponse +from ....types.cloudforce_one.threat_event_delete_response import ThreatEventDeleteResponse +from ....types.cloudforce_one.threat_event_bulk_create_response import ThreatEventBulkCreateResponse + +__all__ = ["ThreatEventsResource", "AsyncThreatEventsResource"] + + +class ThreatEventsResource(SyncAPIResource): + @cached_property + def attackers(self) -> AttackersResource: + return AttackersResource(self._client) + + @cached_property + def categories(self) -> CategoriesResource: + return CategoriesResource(self._client) + + @cached_property + def countries(self) -> CountriesResource: + return CountriesResource(self._client) + + @cached_property + def crons(self) -> CronsResource: + return CronsResource(self._client) + + @cached_property + def datasets(self) -> DatasetsResource: + return DatasetsResource(self._client) + + @cached_property + def indicator_types(self) -> IndicatorTypesResource: + return IndicatorTypesResource(self._client) + + @cached_property + def raw(self) -> RawResource: + return RawResource(self._client) + + @cached_property + def relate(self) -> RelateResource: + return RelateResource(self._client) + + @cached_property + def event_tags(self) -> EventTagsResource: + return EventTagsResource(self._client) + + @cached_property + def target_industries(self) -> TargetIndustriesResource: + return TargetIndustriesResource(self._client) + + @cached_property + def insights(self) -> InsightsResource: + return InsightsResource(self._client) + + @cached_property + def with_raw_response(self) -> ThreatEventsResourceWithRawResponse: + """ + 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 ThreatEventsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ThreatEventsResourceWithStreamingResponse: + """ + 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 ThreatEventsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: float, + dataset_id: List[str] | NotGiven = NOT_GIVEN, + order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + order_by: str | NotGiven = NOT_GIVEN, + page: float | NotGiven = NOT_GIVEN, + page_size: float | NotGiven = NOT_GIVEN, + search: Iterable[threat_event_create_params.Search] | NotGiven = NOT_GIVEN, + # 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, + ) -> ThreatEventCreateResponse: + """ + Filter and list events + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + f"/accounts/{account_id}/cloudforce-one/events", + body=maybe_transform( + { + "dataset_id": dataset_id, + "order": order, + "order_by": order_by, + "page": page, + "page_size": page_size, + "search": search, + }, + threat_event_create_params.ThreatEventCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventCreateResponse, + ) + + def delete( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> ThreatEventDeleteResponse: + """ + Deletes an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._delete( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventDeleteResponse, + ) + + def bulk_create( + self, + *, + account_id: float, + data: Iterable[threat_event_bulk_create_params.Data], + dataset_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ThreatEventBulkCreateResponse: + """ + Creates bulk events + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + f"/accounts/{account_id}/cloudforce-one/events/create/bulk", + body=maybe_transform( + { + "data": data, + "dataset_id": dataset_id, + }, + threat_event_bulk_create_params.ThreatEventBulkCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventBulkCreateResponse, + ) + + def edit( + self, + event_id: str, + *, + account_id: float, + attacker: str | NotGiven = NOT_GIVEN, + attacker_country: str | NotGiven = NOT_GIVEN, + category: str | NotGiven = NOT_GIVEN, + date: Union[str, datetime] | NotGiven = NOT_GIVEN, + event: str | NotGiven = NOT_GIVEN, + indicator: str | NotGiven = NOT_GIVEN, + indicator_type: str | NotGiven = NOT_GIVEN, + target_country: str | NotGiven = NOT_GIVEN, + target_industry: str | NotGiven = NOT_GIVEN, + tlp: str | NotGiven = NOT_GIVEN, + # 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, + ) -> ThreatEventEditResponse: + """ + Updates an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._patch( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + body=maybe_transform( + { + "attacker": attacker, + "attacker_country": attacker_country, + "category": category, + "date": date, + "event": event, + "indicator": indicator, + "indicator_type": indicator_type, + "target_country": target_country, + "target_industry": target_industry, + "tlp": tlp, + }, + threat_event_edit_params.ThreatEventEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventEditResponse, + ) + + def get( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> ThreatEventGetResponse: + """ + Reads an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return self._get( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventGetResponse, + ) + + +class AsyncThreatEventsResource(AsyncAPIResource): + @cached_property + def attackers(self) -> AsyncAttackersResource: + return AsyncAttackersResource(self._client) + + @cached_property + def categories(self) -> AsyncCategoriesResource: + return AsyncCategoriesResource(self._client) + + @cached_property + def countries(self) -> AsyncCountriesResource: + return AsyncCountriesResource(self._client) + + @cached_property + def crons(self) -> AsyncCronsResource: + return AsyncCronsResource(self._client) + + @cached_property + def datasets(self) -> AsyncDatasetsResource: + return AsyncDatasetsResource(self._client) + + @cached_property + def indicator_types(self) -> AsyncIndicatorTypesResource: + return AsyncIndicatorTypesResource(self._client) + + @cached_property + def raw(self) -> AsyncRawResource: + return AsyncRawResource(self._client) + + @cached_property + def relate(self) -> AsyncRelateResource: + return AsyncRelateResource(self._client) + + @cached_property + def event_tags(self) -> AsyncEventTagsResource: + return AsyncEventTagsResource(self._client) + + @cached_property + def target_industries(self) -> AsyncTargetIndustriesResource: + return AsyncTargetIndustriesResource(self._client) + + @cached_property + def insights(self) -> AsyncInsightsResource: + return AsyncInsightsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncThreatEventsResourceWithRawResponse: + """ + 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 AsyncThreatEventsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncThreatEventsResourceWithStreamingResponse: + """ + 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 AsyncThreatEventsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: float, + dataset_id: List[str] | NotGiven = NOT_GIVEN, + order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + order_by: str | NotGiven = NOT_GIVEN, + page: float | NotGiven = NOT_GIVEN, + page_size: float | NotGiven = NOT_GIVEN, + search: Iterable[threat_event_create_params.Search] | NotGiven = NOT_GIVEN, + # 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, + ) -> ThreatEventCreateResponse: + """ + Filter and list events + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + f"/accounts/{account_id}/cloudforce-one/events", + body=await async_maybe_transform( + { + "dataset_id": dataset_id, + "order": order, + "order_by": order_by, + "page": page, + "page_size": page_size, + "search": search, + }, + threat_event_create_params.ThreatEventCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventCreateResponse, + ) + + async def delete( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> ThreatEventDeleteResponse: + """ + Deletes an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._delete( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventDeleteResponse, + ) + + async def bulk_create( + self, + *, + account_id: float, + data: Iterable[threat_event_bulk_create_params.Data], + dataset_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ThreatEventBulkCreateResponse: + """ + Creates bulk events + + Args: + account_id: Account ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + f"/accounts/{account_id}/cloudforce-one/events/create/bulk", + body=await async_maybe_transform( + { + "data": data, + "dataset_id": dataset_id, + }, + threat_event_bulk_create_params.ThreatEventBulkCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventBulkCreateResponse, + ) + + async def edit( + self, + event_id: str, + *, + account_id: float, + attacker: str | NotGiven = NOT_GIVEN, + attacker_country: str | NotGiven = NOT_GIVEN, + category: str | NotGiven = NOT_GIVEN, + date: Union[str, datetime] | NotGiven = NOT_GIVEN, + event: str | NotGiven = NOT_GIVEN, + indicator: str | NotGiven = NOT_GIVEN, + indicator_type: str | NotGiven = NOT_GIVEN, + target_country: str | NotGiven = NOT_GIVEN, + target_industry: str | NotGiven = NOT_GIVEN, + tlp: str | NotGiven = NOT_GIVEN, + # 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, + ) -> ThreatEventEditResponse: + """ + Updates an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._patch( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + body=await async_maybe_transform( + { + "attacker": attacker, + "attacker_country": attacker_country, + "category": category, + "date": date, + "event": event, + "indicator": indicator, + "indicator_type": indicator_type, + "target_country": target_country, + "target_industry": target_industry, + "tlp": tlp, + }, + threat_event_edit_params.ThreatEventEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventEditResponse, + ) + + async def get( + self, + event_id: str, + *, + account_id: float, + # 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, + ) -> ThreatEventGetResponse: + """ + Reads an event + + Args: + account_id: Account ID + + event_id: Event UUID + + 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 event_id: + raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}") + return await self._get( + f"/accounts/{account_id}/cloudforce-one/events/{event_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ThreatEventGetResponse, + ) + + +class ThreatEventsResourceWithRawResponse: + def __init__(self, threat_events: ThreatEventsResource) -> None: + self._threat_events = threat_events + + self.create = to_raw_response_wrapper( + threat_events.create, + ) + self.delete = to_raw_response_wrapper( + threat_events.delete, + ) + self.bulk_create = to_raw_response_wrapper( + threat_events.bulk_create, + ) + self.edit = to_raw_response_wrapper( + threat_events.edit, + ) + self.get = to_raw_response_wrapper( + threat_events.get, + ) + + @cached_property + def attackers(self) -> AttackersResourceWithRawResponse: + return AttackersResourceWithRawResponse(self._threat_events.attackers) + + @cached_property + def categories(self) -> CategoriesResourceWithRawResponse: + return CategoriesResourceWithRawResponse(self._threat_events.categories) + + @cached_property + def countries(self) -> CountriesResourceWithRawResponse: + return CountriesResourceWithRawResponse(self._threat_events.countries) + + @cached_property + def crons(self) -> CronsResourceWithRawResponse: + return CronsResourceWithRawResponse(self._threat_events.crons) + + @cached_property + def datasets(self) -> DatasetsResourceWithRawResponse: + return DatasetsResourceWithRawResponse(self._threat_events.datasets) + + @cached_property + def indicator_types(self) -> IndicatorTypesResourceWithRawResponse: + return IndicatorTypesResourceWithRawResponse(self._threat_events.indicator_types) + + @cached_property + def raw(self) -> RawResourceWithRawResponse: + return RawResourceWithRawResponse(self._threat_events.raw) + + @cached_property + def relate(self) -> RelateResourceWithRawResponse: + return RelateResourceWithRawResponse(self._threat_events.relate) + + @cached_property + def event_tags(self) -> EventTagsResourceWithRawResponse: + return EventTagsResourceWithRawResponse(self._threat_events.event_tags) + + @cached_property + def target_industries(self) -> TargetIndustriesResourceWithRawResponse: + return TargetIndustriesResourceWithRawResponse(self._threat_events.target_industries) + + @cached_property + def insights(self) -> InsightsResourceWithRawResponse: + return InsightsResourceWithRawResponse(self._threat_events.insights) + + +class AsyncThreatEventsResourceWithRawResponse: + def __init__(self, threat_events: AsyncThreatEventsResource) -> None: + self._threat_events = threat_events + + self.create = async_to_raw_response_wrapper( + threat_events.create, + ) + self.delete = async_to_raw_response_wrapper( + threat_events.delete, + ) + self.bulk_create = async_to_raw_response_wrapper( + threat_events.bulk_create, + ) + self.edit = async_to_raw_response_wrapper( + threat_events.edit, + ) + self.get = async_to_raw_response_wrapper( + threat_events.get, + ) + + @cached_property + def attackers(self) -> AsyncAttackersResourceWithRawResponse: + return AsyncAttackersResourceWithRawResponse(self._threat_events.attackers) + + @cached_property + def categories(self) -> AsyncCategoriesResourceWithRawResponse: + return AsyncCategoriesResourceWithRawResponse(self._threat_events.categories) + + @cached_property + def countries(self) -> AsyncCountriesResourceWithRawResponse: + return AsyncCountriesResourceWithRawResponse(self._threat_events.countries) + + @cached_property + def crons(self) -> AsyncCronsResourceWithRawResponse: + return AsyncCronsResourceWithRawResponse(self._threat_events.crons) + + @cached_property + def datasets(self) -> AsyncDatasetsResourceWithRawResponse: + return AsyncDatasetsResourceWithRawResponse(self._threat_events.datasets) + + @cached_property + def indicator_types(self) -> AsyncIndicatorTypesResourceWithRawResponse: + return AsyncIndicatorTypesResourceWithRawResponse(self._threat_events.indicator_types) + + @cached_property + def raw(self) -> AsyncRawResourceWithRawResponse: + return AsyncRawResourceWithRawResponse(self._threat_events.raw) + + @cached_property + def relate(self) -> AsyncRelateResourceWithRawResponse: + return AsyncRelateResourceWithRawResponse(self._threat_events.relate) + + @cached_property + def event_tags(self) -> AsyncEventTagsResourceWithRawResponse: + return AsyncEventTagsResourceWithRawResponse(self._threat_events.event_tags) + + @cached_property + def target_industries(self) -> AsyncTargetIndustriesResourceWithRawResponse: + return AsyncTargetIndustriesResourceWithRawResponse(self._threat_events.target_industries) + + @cached_property + def insights(self) -> AsyncInsightsResourceWithRawResponse: + return AsyncInsightsResourceWithRawResponse(self._threat_events.insights) + + +class ThreatEventsResourceWithStreamingResponse: + def __init__(self, threat_events: ThreatEventsResource) -> None: + self._threat_events = threat_events + + self.create = to_streamed_response_wrapper( + threat_events.create, + ) + self.delete = to_streamed_response_wrapper( + threat_events.delete, + ) + self.bulk_create = to_streamed_response_wrapper( + threat_events.bulk_create, + ) + self.edit = to_streamed_response_wrapper( + threat_events.edit, + ) + self.get = to_streamed_response_wrapper( + threat_events.get, + ) + + @cached_property + def attackers(self) -> AttackersResourceWithStreamingResponse: + return AttackersResourceWithStreamingResponse(self._threat_events.attackers) + + @cached_property + def categories(self) -> CategoriesResourceWithStreamingResponse: + return CategoriesResourceWithStreamingResponse(self._threat_events.categories) + + @cached_property + def countries(self) -> CountriesResourceWithStreamingResponse: + return CountriesResourceWithStreamingResponse(self._threat_events.countries) + + @cached_property + def crons(self) -> CronsResourceWithStreamingResponse: + return CronsResourceWithStreamingResponse(self._threat_events.crons) + + @cached_property + def datasets(self) -> DatasetsResourceWithStreamingResponse: + return DatasetsResourceWithStreamingResponse(self._threat_events.datasets) + + @cached_property + def indicator_types(self) -> IndicatorTypesResourceWithStreamingResponse: + return IndicatorTypesResourceWithStreamingResponse(self._threat_events.indicator_types) + + @cached_property + def raw(self) -> RawResourceWithStreamingResponse: + return RawResourceWithStreamingResponse(self._threat_events.raw) + + @cached_property + def relate(self) -> RelateResourceWithStreamingResponse: + return RelateResourceWithStreamingResponse(self._threat_events.relate) + + @cached_property + def event_tags(self) -> EventTagsResourceWithStreamingResponse: + return EventTagsResourceWithStreamingResponse(self._threat_events.event_tags) + + @cached_property + def target_industries(self) -> TargetIndustriesResourceWithStreamingResponse: + return TargetIndustriesResourceWithStreamingResponse(self._threat_events.target_industries) + + @cached_property + def insights(self) -> InsightsResourceWithStreamingResponse: + return InsightsResourceWithStreamingResponse(self._threat_events.insights) + + +class AsyncThreatEventsResourceWithStreamingResponse: + def __init__(self, threat_events: AsyncThreatEventsResource) -> None: + self._threat_events = threat_events + + self.create = async_to_streamed_response_wrapper( + threat_events.create, + ) + self.delete = async_to_streamed_response_wrapper( + threat_events.delete, + ) + self.bulk_create = async_to_streamed_response_wrapper( + threat_events.bulk_create, + ) + self.edit = async_to_streamed_response_wrapper( + threat_events.edit, + ) + self.get = async_to_streamed_response_wrapper( + threat_events.get, + ) + + @cached_property + def attackers(self) -> AsyncAttackersResourceWithStreamingResponse: + return AsyncAttackersResourceWithStreamingResponse(self._threat_events.attackers) + + @cached_property + def categories(self) -> AsyncCategoriesResourceWithStreamingResponse: + return AsyncCategoriesResourceWithStreamingResponse(self._threat_events.categories) + + @cached_property + def countries(self) -> AsyncCountriesResourceWithStreamingResponse: + return AsyncCountriesResourceWithStreamingResponse(self._threat_events.countries) + + @cached_property + def crons(self) -> AsyncCronsResourceWithStreamingResponse: + return AsyncCronsResourceWithStreamingResponse(self._threat_events.crons) + + @cached_property + def datasets(self) -> AsyncDatasetsResourceWithStreamingResponse: + return AsyncDatasetsResourceWithStreamingResponse(self._threat_events.datasets) + + @cached_property + def indicator_types(self) -> AsyncIndicatorTypesResourceWithStreamingResponse: + return AsyncIndicatorTypesResourceWithStreamingResponse(self._threat_events.indicator_types) + + @cached_property + def raw(self) -> AsyncRawResourceWithStreamingResponse: + return AsyncRawResourceWithStreamingResponse(self._threat_events.raw) + + @cached_property + def relate(self) -> AsyncRelateResourceWithStreamingResponse: + return AsyncRelateResourceWithStreamingResponse(self._threat_events.relate) + + @cached_property + def event_tags(self) -> AsyncEventTagsResourceWithStreamingResponse: + return AsyncEventTagsResourceWithStreamingResponse(self._threat_events.event_tags) + + @cached_property + def target_industries(self) -> AsyncTargetIndustriesResourceWithStreamingResponse: + return AsyncTargetIndustriesResourceWithStreamingResponse(self._threat_events.target_industries) + + @cached_property + def insights(self) -> AsyncInsightsResourceWithStreamingResponse: + return AsyncInsightsResourceWithStreamingResponse(self._threat_events.insights) diff --git a/src/cloudflare/types/cloudforce_one/__init__.py b/src/cloudflare/types/cloudforce_one/__init__.py index 4b1e4f5c1e4..887aef00c12 100644 --- a/src/cloudflare/types/cloudforce_one/__init__.py +++ b/src/cloudflare/types/cloudforce_one/__init__.py @@ -12,3 +12,11 @@ from .request_update_params import RequestUpdateParams as RequestUpdateParams from .request_types_response import RequestTypesResponse as RequestTypesResponse from .request_delete_response import RequestDeleteResponse as RequestDeleteResponse +from .threat_event_edit_params import ThreatEventEditParams as ThreatEventEditParams +from .threat_event_get_response import ThreatEventGetResponse as ThreatEventGetResponse +from .threat_event_create_params import ThreatEventCreateParams as ThreatEventCreateParams +from .threat_event_edit_response import ThreatEventEditResponse as ThreatEventEditResponse +from .threat_event_create_response import ThreatEventCreateResponse as ThreatEventCreateResponse +from .threat_event_delete_response import ThreatEventDeleteResponse as ThreatEventDeleteResponse +from .threat_event_bulk_create_params import ThreatEventBulkCreateParams as ThreatEventBulkCreateParams +from .threat_event_bulk_create_response import ThreatEventBulkCreateResponse as ThreatEventBulkCreateResponse diff --git a/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py b/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py new file mode 100644 index 00000000000..21d1d123074 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py @@ -0,0 +1,58 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Iterable +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["ThreatEventBulkCreateParams", "Data", "DataRaw"] + + +class ThreatEventBulkCreateParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + data: Required[Iterable[Data]] + + dataset_id: Required[Annotated[str, PropertyInfo(alias="datasetId")]] + + +class DataRaw(TypedDict, total=False): + data: object + + source: str + + tlp: str + + +class Data(TypedDict, total=False): + attacker: Required[str] + + attacker_country: Required[Annotated[str, PropertyInfo(alias="attackerCountry")]] + + category: Required[str] + + date: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + + event: Required[str] + + indicator_type: Required[Annotated[str, PropertyInfo(alias="indicatorType")]] + + raw: Required[DataRaw] + + tlp: Required[str] + + account_id: Annotated[float, PropertyInfo(alias="accountId")] + + dataset_id: Annotated[str, PropertyInfo(alias="datasetId")] + + indicator: str + + tags: List[str] + + target_country: Annotated[str, PropertyInfo(alias="targetCountry")] + + target_industry: Annotated[str, PropertyInfo(alias="targetIndustry")] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_response.py b/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_response.py new file mode 100644 index 00000000000..7d9273c9f24 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_bulk_create_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import TypeAlias + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["ThreatEventBulkCreateResponse", "ThreatEventBulkCreateResponseItem"] + + +class ThreatEventBulkCreateResponseItem(BaseModel): + id: float + + account_id: float = FieldInfo(alias="accountId") + + attacker: str + + attacker_country: str = FieldInfo(alias="attackerCountry") + + category: str + + category_id: float = FieldInfo(alias="categoryId") + + date: str + + event: str + + indicator: str + + indicator_type: str = FieldInfo(alias="indicatorType") + + indicator_type_id: float = FieldInfo(alias="indicatorTypeId") + + kill_chain: float = FieldInfo(alias="killChain") + + mitre_attack: List[str] = FieldInfo(alias="mitreAttack") + + num_referenced: float = FieldInfo(alias="numReferenced") + + num_references: float = FieldInfo(alias="numReferences") + + raw_id: str = FieldInfo(alias="rawId") + + referenced: List[str] + + referenced_ids: List[float] = FieldInfo(alias="referencedIds") + + references: List[str] + + references_ids: List[float] = FieldInfo(alias="referencesIds") + + tags: List[str] + + target_country: str = FieldInfo(alias="targetCountry") + + target_industry: str = FieldInfo(alias="targetIndustry") + + tlp: str + + uuid: str + + insight: Optional[str] = None + + releasability_id: Optional[str] = FieldInfo(alias="releasabilityId", default=None) + + +ThreatEventBulkCreateResponse: TypeAlias = List[ThreatEventBulkCreateResponseItem] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_create_params.py b/src/cloudflare/types/cloudforce_one/threat_event_create_params.py new file mode 100644 index 00000000000..ddfc3372d9d --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_create_params.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["ThreatEventCreateParams", "Search"] + + +class ThreatEventCreateParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + dataset_id: Annotated[List[str], PropertyInfo(alias="datasetId")] + + order: Literal["asc", "desc"] + + order_by: Annotated[str, PropertyInfo(alias="orderBy")] + + page: float + + page_size: Annotated[float, PropertyInfo(alias="pageSize")] + + search: Iterable[Search] + + +class Search(TypedDict, total=False): + field: str + + op: str + + value: Union[str, float, List[Union[str, float]]] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_create_response.py b/src/cloudflare/types/cloudforce_one/threat_event_create_response.py new file mode 100644 index 00000000000..6dcd4f9e93d --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_create_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import TypeAlias + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["ThreatEventCreateResponse", "ThreatEventCreateResponseItem"] + + +class ThreatEventCreateResponseItem(BaseModel): + id: float + + account_id: float = FieldInfo(alias="accountId") + + attacker: str + + attacker_country: str = FieldInfo(alias="attackerCountry") + + category: str + + category_id: float = FieldInfo(alias="categoryId") + + date: str + + event: str + + indicator: str + + indicator_type: str = FieldInfo(alias="indicatorType") + + indicator_type_id: float = FieldInfo(alias="indicatorTypeId") + + kill_chain: float = FieldInfo(alias="killChain") + + mitre_attack: List[str] = FieldInfo(alias="mitreAttack") + + num_referenced: float = FieldInfo(alias="numReferenced") + + num_references: float = FieldInfo(alias="numReferences") + + raw_id: str = FieldInfo(alias="rawId") + + referenced: List[str] + + referenced_ids: List[float] = FieldInfo(alias="referencedIds") + + references: List[str] + + references_ids: List[float] = FieldInfo(alias="referencesIds") + + tags: List[str] + + target_country: str = FieldInfo(alias="targetCountry") + + target_industry: str = FieldInfo(alias="targetIndustry") + + tlp: str + + uuid: str + + insight: Optional[str] = None + + releasability_id: Optional[str] = FieldInfo(alias="releasabilityId", default=None) + + +ThreatEventCreateResponse: TypeAlias = List[ThreatEventCreateResponseItem] diff --git a/src/cloudflare/types/cloudforce_one/threat_event_delete_response.py b/src/cloudflare/types/cloudforce_one/threat_event_delete_response.py new file mode 100644 index 00000000000..3010d08341b --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_delete_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ..._models import BaseModel + +__all__ = ["ThreatEventDeleteResponse"] + + +class ThreatEventDeleteResponse(BaseModel): + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py new file mode 100644 index 00000000000..98c5573ba83 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_edit_params.py @@ -0,0 +1,36 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["ThreatEventEditParams"] + + +class ThreatEventEditParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + attacker: str + + attacker_country: Annotated[str, PropertyInfo(alias="attackerCountry")] + + category: str + + date: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + + event: str + + indicator: str + + indicator_type: Annotated[str, PropertyInfo(alias="indicatorType")] + + target_country: Annotated[str, PropertyInfo(alias="targetCountry")] + + target_industry: Annotated[str, PropertyInfo(alias="targetIndustry")] + + tlp: str diff --git a/src/cloudflare/types/cloudforce_one/threat_event_edit_response.py b/src/cloudflare/types/cloudforce_one/threat_event_edit_response.py new file mode 100644 index 00000000000..d231b5a963b --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_edit_response.py @@ -0,0 +1,65 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["ThreatEventEditResponse"] + + +class ThreatEventEditResponse(BaseModel): + id: float + + account_id: float = FieldInfo(alias="accountId") + + attacker: str + + attacker_country: str = FieldInfo(alias="attackerCountry") + + category: str + + category_id: float = FieldInfo(alias="categoryId") + + date: str + + event: str + + indicator: str + + indicator_type: str = FieldInfo(alias="indicatorType") + + indicator_type_id: float = FieldInfo(alias="indicatorTypeId") + + kill_chain: float = FieldInfo(alias="killChain") + + mitre_attack: List[str] = FieldInfo(alias="mitreAttack") + + num_referenced: float = FieldInfo(alias="numReferenced") + + num_references: float = FieldInfo(alias="numReferences") + + raw_id: str = FieldInfo(alias="rawId") + + referenced: List[str] + + referenced_ids: List[float] = FieldInfo(alias="referencedIds") + + references: List[str] + + references_ids: List[float] = FieldInfo(alias="referencesIds") + + tags: List[str] + + target_country: str = FieldInfo(alias="targetCountry") + + target_industry: str = FieldInfo(alias="targetIndustry") + + tlp: str + + uuid: str + + insight: Optional[str] = None + + releasability_id: Optional[str] = FieldInfo(alias="releasabilityId", default=None) diff --git a/src/cloudflare/types/cloudforce_one/threat_event_get_response.py b/src/cloudflare/types/cloudforce_one/threat_event_get_response.py new file mode 100644 index 00000000000..93a44b230ec --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_event_get_response.py @@ -0,0 +1,65 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["ThreatEventGetResponse"] + + +class ThreatEventGetResponse(BaseModel): + id: float + + account_id: float = FieldInfo(alias="accountId") + + attacker: str + + attacker_country: str = FieldInfo(alias="attackerCountry") + + category: str + + category_id: float = FieldInfo(alias="categoryId") + + date: str + + event: str + + indicator: str + + indicator_type: str = FieldInfo(alias="indicatorType") + + indicator_type_id: float = FieldInfo(alias="indicatorTypeId") + + kill_chain: float = FieldInfo(alias="killChain") + + mitre_attack: List[str] = FieldInfo(alias="mitreAttack") + + num_referenced: float = FieldInfo(alias="numReferenced") + + num_references: float = FieldInfo(alias="numReferences") + + raw_id: str = FieldInfo(alias="rawId") + + referenced: List[str] + + referenced_ids: List[float] = FieldInfo(alias="referencedIds") + + references: List[str] + + references_ids: List[float] = FieldInfo(alias="referencesIds") + + tags: List[str] + + target_country: str = FieldInfo(alias="targetCountry") + + target_industry: str = FieldInfo(alias="targetIndustry") + + tlp: str + + uuid: str + + insight: Optional[str] = None + + releasability_id: Optional[str] = FieldInfo(alias="releasabilityId", default=None) diff --git a/src/cloudflare/types/cloudforce_one/threat_events/__init__.py b/src/cloudflare/types/cloudforce_one/threat_events/__init__.py index f8ee8b14b1c..5a780ea7661 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/__init__.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/__init__.py @@ -1,3 +1,35 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .raw_edit_params import RawEditParams as RawEditParams +from .raw_get_response import RawGetResponse as RawGetResponse +from .raw_edit_response import RawEditResponse as RawEditResponse +from .cron_edit_response import CronEditResponse as CronEditResponse +from .cron_list_response import CronListResponse as CronListResponse +from .dataset_edit_params import DatasetEditParams as DatasetEditParams +from .insight_edit_params import InsightEditParams as InsightEditParams +from .category_edit_params import CategoryEditParams as CategoryEditParams +from .dataset_get_response import DatasetGetResponse as DatasetGetResponse +from .dataset_raw_response import DatasetRawResponse as DatasetRawResponse +from .insight_creat_params import InsightCreatParams as InsightCreatParams +from .insight_get_response import InsightGetResponse as InsightGetResponse +from .category_get_response import CategoryGetResponse as CategoryGetResponse +from .country_list_response import CountryListResponse as CountryListResponse +from .dataset_create_params import DatasetCreateParams as DatasetCreateParams +from .dataset_edit_response import DatasetEditResponse as DatasetEditResponse +from .dataset_list_response import DatasetListResponse as DatasetListResponse +from .insight_edit_response import InsightEditResponse as InsightEditResponse +from .attacker_list_response import AttackerListResponse as AttackerListResponse +from .category_create_params import CategoryCreateParams as CategoryCreateParams +from .category_edit_response import CategoryEditResponse as CategoryEditResponse +from .category_list_response import CategoryListResponse as CategoryListResponse +from .insight_creat_response import InsightCreatResponse as InsightCreatResponse +from .relate_delete_response import RelateDeleteResponse as RelateDeleteResponse +from .dataset_create_response import DatasetCreateResponse as DatasetCreateResponse +from .insight_delete_response import InsightDeleteResponse as InsightDeleteResponse +from .category_create_response import CategoryCreateResponse as CategoryCreateResponse +from .category_delete_response import CategoryDeleteResponse as CategoryDeleteResponse +from .event_tag_delete_response import EventTagDeleteResponse as EventTagDeleteResponse +from .indicator_type_list_response import IndicatorTypeListResponse as IndicatorTypeListResponse +from .target_industry_list_response import TargetIndustryListResponse as TargetIndustryListResponse diff --git a/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_response.py new file mode 100644 index 00000000000..9eb9b5b9010 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/attacker_list_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["AttackerListResponse", "Items"] + + +class Items(BaseModel): + type: str + + +class AttackerListResponse(BaseModel): + items: Items + + type: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py b/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py new file mode 100644 index 00000000000..577239c3b83 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_create_params.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["CategoryCreateParams"] + + +class CategoryCreateParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + kill_chain: Required[Annotated[float, PropertyInfo(alias="killChain")]] + + name: Required[str] + + mitre_attack: Annotated[List[str], PropertyInfo(alias="mitreAttack")] + + shortname: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_create_response.py b/src/cloudflare/types/cloudforce_one/threat_events/category_create_response.py new file mode 100644 index 00000000000..18aba95acd8 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_create_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["CategoryCreateResponse"] + + +class CategoryCreateResponse(BaseModel): + kill_chain: float = FieldInfo(alias="killChain") + + name: str + + uuid: str + + mitre_attack: Optional[List[str]] = FieldInfo(alias="mitreAttack", default=None) + + shortname: Optional[str] = None diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_delete_response.py b/src/cloudflare/types/cloudforce_one/threat_events/category_delete_response.py new file mode 100644 index 00000000000..f3d24b548a5 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_delete_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["CategoryDeleteResponse"] + + +class CategoryDeleteResponse(BaseModel): + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py new file mode 100644 index 00000000000..686f927ec44 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_edit_params.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["CategoryEditParams"] + + +class CategoryEditParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + kill_chain: Annotated[float, PropertyInfo(alias="killChain")] + + mitre_attack: Annotated[List[str], PropertyInfo(alias="mitreAttack")] + + name: str + + shortname: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_edit_response.py b/src/cloudflare/types/cloudforce_one/threat_events/category_edit_response.py new file mode 100644 index 00000000000..ca0a5b7dfcf --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_edit_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["CategoryEditResponse"] + + +class CategoryEditResponse(BaseModel): + kill_chain: float = FieldInfo(alias="killChain") + + name: str + + uuid: str + + mitre_attack: Optional[List[str]] = FieldInfo(alias="mitreAttack", default=None) + + shortname: Optional[str] = None diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_get_response.py b/src/cloudflare/types/cloudforce_one/threat_events/category_get_response.py new file mode 100644 index 00000000000..71b786056e0 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_get_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["CategoryGetResponse"] + + +class CategoryGetResponse(BaseModel): + kill_chain: float = FieldInfo(alias="killChain") + + name: str + + uuid: str + + mitre_attack: Optional[List[str]] = FieldInfo(alias="mitreAttack", default=None) + + shortname: Optional[str] = None diff --git a/src/cloudflare/types/cloudforce_one/threat_events/category_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/category_list_response.py new file mode 100644 index 00000000000..76c5ed72b90 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/category_list_response.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import TypeAlias + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["CategoryListResponse", "CategoryListResponseItem"] + + +class CategoryListResponseItem(BaseModel): + kill_chain: float = FieldInfo(alias="killChain") + + name: str + + uuid: str + + mitre_attack: Optional[List[str]] = FieldInfo(alias="mitreAttack", default=None) + + shortname: Optional[str] = None + + +CategoryListResponse: TypeAlias = List[CategoryListResponseItem] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/country_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/country_list_response.py new file mode 100644 index 00000000000..c6309e41696 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/country_list_response.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...._models import BaseModel + +__all__ = ["CountryListResponse", "CountryListResponseItem", "CountryListResponseItemResult"] + + +class CountryListResponseItemResult(BaseModel): + alpha3: str + + name: str + + +class CountryListResponseItem(BaseModel): + result: List[CountryListResponseItemResult] + + success: str + + +CountryListResponse: TypeAlias = List[CountryListResponseItem] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/cron_edit_response.py b/src/cloudflare/types/cloudforce_one/threat_events/cron_edit_response.py new file mode 100644 index 00000000000..677ab2424b6 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/cron_edit_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["CronEditResponse"] + + +class CronEditResponse(BaseModel): + id: float + + update: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/cron_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/cron_list_response.py new file mode 100644 index 00000000000..8c7a0302806 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/cron_list_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["CronListResponse"] + + +class CronListResponse(BaseModel): + update: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py new file mode 100644 index 00000000000..0b5104a53c1 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_params.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["DatasetCreateParams"] + + +class DatasetCreateParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + is_public: Required[Annotated[bool, PropertyInfo(alias="isPublic")]] + """If true, then anyone can search the dataset. + + If false, then its limited to the account. + """ + + name: Required[str] + """Used to describe the dataset within the account context""" diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_response.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_response.py new file mode 100644 index 00000000000..4a2fa081c0f --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_create_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DatasetCreateResponse"] + + +class DatasetCreateResponse(BaseModel): + is_public: bool = FieldInfo(alias="isPublic") + + name: str + + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py new file mode 100644 index 00000000000..180862d264c --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_params.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["DatasetEditParams"] + + +class DatasetEditParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + is_public: Required[Annotated[bool, PropertyInfo(alias="isPublic")]] + """If true, then anyone can search the dataset. + + If false, then its limited to the account. + """ + + name: Required[str] + """Used to describe the dataset within the account context""" diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_response.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_response.py new file mode 100644 index 00000000000..7eee64ce399 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_edit_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DatasetEditResponse"] + + +class DatasetEditResponse(BaseModel): + is_public: bool = FieldInfo(alias="isPublic") + + name: str + + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_get_response.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_get_response.py new file mode 100644 index 00000000000..20a2c3bdc14 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_get_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DatasetGetResponse"] + + +class DatasetGetResponse(BaseModel): + is_public: bool = FieldInfo(alias="isPublic") + + name: str + + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_list_response.py new file mode 100644 index 00000000000..810843f27ef --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_list_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DatasetListResponse", "DatasetListResponseItem"] + + +class DatasetListResponseItem(BaseModel): + is_public: bool = FieldInfo(alias="isPublic") + + name: str + + uuid: str + + +DatasetListResponse: TypeAlias = List[DatasetListResponseItem] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py new file mode 100644 index 00000000000..aacafd7a85b --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DatasetRawResponse"] + + +class DatasetRawResponse(BaseModel): + id: str + + account_id: float = FieldInfo(alias="accountId") + + created: str + + data: object + + source: str + + tlp: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/event_tag_delete_response.py b/src/cloudflare/types/cloudforce_one/threat_events/event_tag_delete_response.py new file mode 100644 index 00000000000..ec12210300b --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/event_tag_delete_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["EventTagDeleteResponse"] + + +class EventTagDeleteResponse(BaseModel): + success: bool diff --git a/src/cloudflare/types/cloudforce_one/threat_events/indicator_type_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/indicator_type_list_response.py new file mode 100644 index 00000000000..7c534ee36c3 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/indicator_type_list_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["IndicatorTypeListResponse", "Items"] + + +class Items(BaseModel): + type: str + + +class IndicatorTypeListResponse(BaseModel): + items: Items + + type: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/insight_creat_params.py b/src/cloudflare/types/cloudforce_one/threat_events/insight_creat_params.py new file mode 100644 index 00000000000..ca6cbf7dbbd --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/insight_creat_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["InsightCreatParams"] + + +class InsightCreatParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + content: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/insight_creat_response.py b/src/cloudflare/types/cloudforce_one/threat_events/insight_creat_response.py new file mode 100644 index 00000000000..d86488ce100 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/insight_creat_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["InsightCreatResponse"] + + +class InsightCreatResponse(BaseModel): + content: str + + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/insight_delete_response.py b/src/cloudflare/types/cloudforce_one/threat_events/insight_delete_response.py new file mode 100644 index 00000000000..b329d669d6f --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/insight_delete_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["InsightDeleteResponse"] + + +class InsightDeleteResponse(BaseModel): + success: bool diff --git a/src/cloudflare/types/cloudforce_one/threat_events/insight_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/insight_edit_params.py new file mode 100644 index 00000000000..e989059b907 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/insight_edit_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["InsightEditParams"] + + +class InsightEditParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + event_id: Required[str] + """Event UUID""" + + content: Required[str] diff --git a/src/cloudflare/types/cloudforce_one/threat_events/insight_edit_response.py b/src/cloudflare/types/cloudforce_one/threat_events/insight_edit_response.py new file mode 100644 index 00000000000..bd306cb70f0 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/insight_edit_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["InsightEditResponse"] + + +class InsightEditResponse(BaseModel): + content: str + + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/insight_get_response.py b/src/cloudflare/types/cloudforce_one/threat_events/insight_get_response.py new file mode 100644 index 00000000000..7c6d144402c --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/insight_get_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["InsightGetResponse"] + + +class InsightGetResponse(BaseModel): + content: str + + uuid: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py b/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py new file mode 100644 index 00000000000..0a64e350135 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RawEditParams"] + + +class RawEditParams(TypedDict, total=False): + account_id: Required[float] + """Account ID""" + + event_id: Required[str] + """Event UUID""" + + data: object + + source: str + + tlp: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_response.py b/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_response.py new file mode 100644 index 00000000000..19886a7392c --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/raw_edit_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["RawEditResponse"] + + +class RawEditResponse(BaseModel): + id: str + + data: object diff --git a/src/cloudflare/types/cloudforce_one/threat_events/raw_get_response.py b/src/cloudflare/types/cloudforce_one/threat_events/raw_get_response.py new file mode 100644 index 00000000000..9f984cec408 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/raw_get_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["RawGetResponse"] + + +class RawGetResponse(BaseModel): + id: str + + account_id: float = FieldInfo(alias="accountId") + + created: str + + data: object + + source: str + + tlp: str diff --git a/src/cloudflare/types/cloudforce_one/threat_events/relate_delete_response.py b/src/cloudflare/types/cloudforce_one/threat_events/relate_delete_response.py new file mode 100644 index 00000000000..5faa3e3df10 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/relate_delete_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["RelateDeleteResponse"] + + +class RelateDeleteResponse(BaseModel): + success: bool diff --git a/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_response.py b/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_response.py new file mode 100644 index 00000000000..c935d1a9610 --- /dev/null +++ b/src/cloudflare/types/cloudforce_one/threat_events/target_industry_list_response.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from ...._models import BaseModel + +__all__ = ["TargetIndustryListResponse", "Items"] + + +class Items(BaseModel): + type: str + + +class TargetIndustryListResponse(BaseModel): + items: Items + + type: str diff --git a/tests/api_resources/cloudforce_one/test_threat_events.py b/tests/api_resources/cloudforce_one/test_threat_events.py new file mode 100644 index 00000000000..cae5a6ba8de --- /dev/null +++ b/tests/api_resources/cloudforce_one/test_threat_events.py @@ -0,0 +1,557 @@ +# 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, + ThreatEventCreateResponse, + ThreatEventDeleteResponse, + ThreatEventBulkCreateResponse, +) + +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"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + threat_event = client.cloudforce_one.threat_events.create( + account_id=0, + ) + assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + threat_event = client.cloudforce_one.threat_events.create( + account_id=0, + dataset_id=["7632a037-fdef-4899-9b12-148470aae772"], + order="asc", + order_by="created", + page=1, + page_size=100, + search=[ + { + "field": "attackerCountry", + "op": "equals", + "value": "usa", + } + ], + ) + assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.with_raw_response.create( + account_id=0, + ) + + 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"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.with_streaming_response.create( + account_id=0, + ) 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 + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + threat_event = client.cloudforce_one.threat_events.delete( + event_id="event_id", + account_id=0, + ) + assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"]) + + @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=0, + ) + + 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"]) + + @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=0, + ) 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 + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + 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=0, + ) + + @parametrize + def test_method_bulk_create(self, client: Cloudflare) -> None: + threat_event = client.cloudforce_one.threat_events.bulk_create( + account_id=0, + data=[ + { + "attacker": "Flying Yeti", + "attacker_country": "CN", + "category": "Domain Resolution", + "date": parse_datetime("2022-04-01T00:00:00Z"), + "event": "An attacker registered the domain domain.com", + "indicator_type": "domain", + "raw": {}, + "tlp": "amber", + } + ], + dataset_id="durableObjectName", + ) + assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"]) + + @parametrize + def test_raw_response_bulk_create(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.with_raw_response.bulk_create( + account_id=0, + data=[ + { + "attacker": "Flying Yeti", + "attacker_country": "CN", + "category": "Domain Resolution", + "date": parse_datetime("2022-04-01T00:00:00Z"), + "event": "An attacker registered the domain domain.com", + "indicator_type": "domain", + "raw": {}, + "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"]) + + @parametrize + def test_streaming_response_bulk_create(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.with_streaming_response.bulk_create( + account_id=0, + data=[ + { + "attacker": "Flying Yeti", + "attacker_country": "CN", + "category": "Domain Resolution", + "date": parse_datetime("2022-04-01T00:00:00Z"), + "event": "An attacker registered the domain domain.com", + "indicator_type": "domain", + "raw": {}, + "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 + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + threat_event = client.cloudforce_one.threat_events.edit( + event_id="event_id", + account_id=0, + ) + assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"]) + + @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=0, + attacker="Flying Yeti", + attacker_country="CN", + category="Domain Resolution", + date=parse_datetime("2022-04-01T00:00:00Z"), + event="An attacker registered the domain domain.com", + indicator="domain2.com", + indicator_type="sha256", + target_country="US", + target_industry="Insurance", + tlp="amber", + ) + assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"]) + + @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=0, + ) + + 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"]) + + @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=0, + ) 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 + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + 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=0, + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + threat_event = client.cloudforce_one.threat_events.get( + event_id="event_id", + account_id=0, + ) + assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.with_raw_response.get( + event_id="event_id", + account_id=0, + ) + + 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"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.with_streaming_response.get( + event_id="event_id", + account_id=0, + ) 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 + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + 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=0, + ) + + +class TestAsyncThreatEvents: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + threat_event = await async_client.cloudforce_one.threat_events.create( + account_id=0, + ) + assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + threat_event = await async_client.cloudforce_one.threat_events.create( + account_id=0, + dataset_id=["7632a037-fdef-4899-9b12-148470aae772"], + order="asc", + order_by="created", + page=1, + page_size=100, + search=[ + { + "field": "attackerCountry", + "op": "equals", + "value": "usa", + } + ], + ) + assert_matches_type(ThreatEventCreateResponse, threat_event, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.with_raw_response.create( + account_id=0, + ) + + 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"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.with_streaming_response.create( + account_id=0, + ) 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 + + @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=0, + ) + assert_matches_type(ThreatEventDeleteResponse, threat_event, path=["response"]) + + @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=0, + ) + + 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"]) + + @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=0, + ) 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 + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + 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=0, + ) + + @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=0, + data=[ + { + "attacker": "Flying Yeti", + "attacker_country": "CN", + "category": "Domain Resolution", + "date": parse_datetime("2022-04-01T00:00:00Z"), + "event": "An attacker registered the domain domain.com", + "indicator_type": "domain", + "raw": {}, + "tlp": "amber", + } + ], + dataset_id="durableObjectName", + ) + assert_matches_type(ThreatEventBulkCreateResponse, threat_event, path=["response"]) + + @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=0, + data=[ + { + "attacker": "Flying Yeti", + "attacker_country": "CN", + "category": "Domain Resolution", + "date": parse_datetime("2022-04-01T00:00:00Z"), + "event": "An attacker registered the domain domain.com", + "indicator_type": "domain", + "raw": {}, + "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"]) + + @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=0, + data=[ + { + "attacker": "Flying Yeti", + "attacker_country": "CN", + "category": "Domain Resolution", + "date": parse_datetime("2022-04-01T00:00:00Z"), + "event": "An attacker registered the domain domain.com", + "indicator_type": "domain", + "raw": {}, + "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 + + @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=0, + ) + assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"]) + + @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=0, + attacker="Flying Yeti", + attacker_country="CN", + category="Domain Resolution", + date=parse_datetime("2022-04-01T00:00:00Z"), + event="An attacker registered the domain domain.com", + indicator="domain2.com", + indicator_type="sha256", + target_country="US", + target_industry="Insurance", + tlp="amber", + ) + assert_matches_type(ThreatEventEditResponse, threat_event, path=["response"]) + + @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=0, + ) + + 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"]) + + @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=0, + ) 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 + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + 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=0, + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + threat_event = await async_client.cloudforce_one.threat_events.get( + event_id="event_id", + account_id=0, + ) + assert_matches_type(ThreatEventGetResponse, threat_event, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.with_raw_response.get( + event_id="event_id", + account_id=0, + ) + + 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"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.with_streaming_response.get( + event_id="event_id", + account_id=0, + ) 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 + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + 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=0, + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/__init__.py b/tests/api_resources/cloudforce_one/threat_events/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/cloudforce_one/threat_events/test_attackers.py b/tests/api_resources/cloudforce_one/threat_events/test_attackers.py new file mode 100644 index 00000000000..464eadb0702 --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_attackers.py @@ -0,0 +1,84 @@ +# 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.types.cloudforce_one.threat_events import AttackerListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAttackers: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + attacker = client.cloudforce_one.threat_events.attackers.list( + account_id=0, + ) + assert_matches_type(AttackerListResponse, attacker, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.attackers.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + attacker = response.parse() + assert_matches_type(AttackerListResponse, attacker, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.attackers.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + attacker = response.parse() + assert_matches_type(AttackerListResponse, attacker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncAttackers: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + attacker = await async_client.cloudforce_one.threat_events.attackers.list( + account_id=0, + ) + assert_matches_type(AttackerListResponse, attacker, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.attackers.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + attacker = await response.parse() + assert_matches_type(AttackerListResponse, attacker, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.attackers.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + attacker = await response.parse() + assert_matches_type(AttackerListResponse, attacker, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/threat_events/test_categories.py b/tests/api_resources/cloudforce_one/threat_events/test_categories.py new file mode 100644 index 00000000000..20ded66d937 --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_categories.py @@ -0,0 +1,462 @@ +# 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.types.cloudforce_one.threat_events import ( + CategoryGetResponse, + CategoryEditResponse, + CategoryListResponse, + CategoryCreateResponse, + CategoryDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCategories: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.create( + account_id=0, + kill_chain=0, + name="name", + ) + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.create( + account_id=0, + kill_chain=0, + name="name", + mitre_attack=["T1234"], + shortname="shortname", + ) + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.categories.with_raw_response.create( + account_id=0, + kill_chain=0, + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = response.parse() + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.categories.with_streaming_response.create( + account_id=0, + kill_chain=0, + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = response.parse() + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.list( + account_id=0, + ) + assert_matches_type(CategoryListResponse, category, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.categories.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = response.parse() + assert_matches_type(CategoryListResponse, category, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.categories.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = response.parse() + assert_matches_type(CategoryListResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.delete( + category_id="category_id", + account_id=0, + ) + assert_matches_type(CategoryDeleteResponse, category, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.categories.with_raw_response.delete( + category_id="category_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = response.parse() + assert_matches_type(CategoryDeleteResponse, category, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.categories.with_streaming_response.delete( + category_id="category_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = response.parse() + assert_matches_type(CategoryDeleteResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `category_id` but received ''"): + client.cloudforce_one.threat_events.categories.with_raw_response.delete( + category_id="", + account_id=0, + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.edit( + category_id="category_id", + account_id=0, + ) + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.edit( + category_id="category_id", + account_id=0, + kill_chain=0, + mitre_attack=["T1234"], + name="name", + shortname="shortname", + ) + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.categories.with_raw_response.edit( + category_id="category_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = response.parse() + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.categories.with_streaming_response.edit( + category_id="category_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = response.parse() + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `category_id` but received ''"): + client.cloudforce_one.threat_events.categories.with_raw_response.edit( + category_id="", + account_id=0, + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + category = client.cloudforce_one.threat_events.categories.get( + category_id="category_id", + account_id=0, + ) + assert_matches_type(CategoryGetResponse, category, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.categories.with_raw_response.get( + category_id="category_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = response.parse() + assert_matches_type(CategoryGetResponse, category, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.categories.with_streaming_response.get( + category_id="category_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = response.parse() + assert_matches_type(CategoryGetResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `category_id` but received ''"): + client.cloudforce_one.threat_events.categories.with_raw_response.get( + category_id="", + account_id=0, + ) + + +class TestAsyncCategories: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.create( + account_id=0, + kill_chain=0, + name="name", + ) + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.create( + account_id=0, + kill_chain=0, + name="name", + mitre_attack=["T1234"], + shortname="shortname", + ) + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.categories.with_raw_response.create( + account_id=0, + kill_chain=0, + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = await response.parse() + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.categories.with_streaming_response.create( + account_id=0, + kill_chain=0, + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = await response.parse() + assert_matches_type(CategoryCreateResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.list( + account_id=0, + ) + assert_matches_type(CategoryListResponse, category, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.categories.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = await response.parse() + assert_matches_type(CategoryListResponse, category, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.categories.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = await response.parse() + assert_matches_type(CategoryListResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.delete( + category_id="category_id", + account_id=0, + ) + assert_matches_type(CategoryDeleteResponse, category, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.categories.with_raw_response.delete( + category_id="category_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = await response.parse() + assert_matches_type(CategoryDeleteResponse, category, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.categories.with_streaming_response.delete( + category_id="category_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = await response.parse() + assert_matches_type(CategoryDeleteResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `category_id` but received ''"): + await async_client.cloudforce_one.threat_events.categories.with_raw_response.delete( + category_id="", + account_id=0, + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.edit( + category_id="category_id", + account_id=0, + ) + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.edit( + category_id="category_id", + account_id=0, + kill_chain=0, + mitre_attack=["T1234"], + name="name", + shortname="shortname", + ) + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.categories.with_raw_response.edit( + category_id="category_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = await response.parse() + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.categories.with_streaming_response.edit( + category_id="category_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = await response.parse() + assert_matches_type(CategoryEditResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `category_id` but received ''"): + await async_client.cloudforce_one.threat_events.categories.with_raw_response.edit( + category_id="", + account_id=0, + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + category = await async_client.cloudforce_one.threat_events.categories.get( + category_id="category_id", + account_id=0, + ) + assert_matches_type(CategoryGetResponse, category, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.categories.with_raw_response.get( + category_id="category_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + category = await response.parse() + assert_matches_type(CategoryGetResponse, category, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.categories.with_streaming_response.get( + category_id="category_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + category = await response.parse() + assert_matches_type(CategoryGetResponse, category, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `category_id` but received ''"): + await async_client.cloudforce_one.threat_events.categories.with_raw_response.get( + category_id="", + account_id=0, + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/test_countries.py b/tests/api_resources/cloudforce_one/threat_events/test_countries.py new file mode 100644 index 00000000000..21666a6a9bc --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_countries.py @@ -0,0 +1,84 @@ +# 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.types.cloudforce_one.threat_events import CountryListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCountries: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + country = client.cloudforce_one.threat_events.countries.list( + account_id=0, + ) + assert_matches_type(CountryListResponse, country, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.countries.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + country = response.parse() + assert_matches_type(CountryListResponse, country, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.countries.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + country = response.parse() + assert_matches_type(CountryListResponse, country, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncCountries: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + country = await async_client.cloudforce_one.threat_events.countries.list( + account_id=0, + ) + assert_matches_type(CountryListResponse, country, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.countries.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + country = await response.parse() + assert_matches_type(CountryListResponse, country, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.countries.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + country = await response.parse() + assert_matches_type(CountryListResponse, country, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/threat_events/test_crons.py b/tests/api_resources/cloudforce_one/threat_events/test_crons.py new file mode 100644 index 00000000000..54137f33496 --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_crons.py @@ -0,0 +1,146 @@ +# 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.types.cloudforce_one.threat_events import CronEditResponse, CronListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCrons: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + cron = client.cloudforce_one.threat_events.crons.list( + account_id=0, + ) + assert_matches_type(CronListResponse, cron, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.crons.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cron = response.parse() + assert_matches_type(CronListResponse, cron, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.crons.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cron = response.parse() + assert_matches_type(CronListResponse, cron, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + cron = client.cloudforce_one.threat_events.crons.edit( + account_id=0, + ) + assert_matches_type(CronEditResponse, cron, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.crons.with_raw_response.edit( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cron = response.parse() + assert_matches_type(CronEditResponse, cron, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.crons.with_streaming_response.edit( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cron = response.parse() + assert_matches_type(CronEditResponse, cron, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncCrons: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + cron = await async_client.cloudforce_one.threat_events.crons.list( + account_id=0, + ) + assert_matches_type(CronListResponse, cron, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.crons.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cron = await response.parse() + assert_matches_type(CronListResponse, cron, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.crons.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cron = await response.parse() + assert_matches_type(CronListResponse, cron, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + cron = await async_client.cloudforce_one.threat_events.crons.edit( + account_id=0, + ) + assert_matches_type(CronEditResponse, cron, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.crons.with_raw_response.edit( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cron = await response.parse() + assert_matches_type(CronEditResponse, cron, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.crons.with_streaming_response.edit( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cron = await response.parse() + assert_matches_type(CronEditResponse, cron, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/threat_events/test_datasets.py b/tests/api_resources/cloudforce_one/threat_events/test_datasets.py new file mode 100644 index 00000000000..3766339f69e --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_datasets.py @@ -0,0 +1,454 @@ +# 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.types.cloudforce_one.threat_events import ( + DatasetGetResponse, + DatasetRawResponse, + DatasetEditResponse, + DatasetListResponse, + DatasetCreateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDatasets: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + dataset = client.cloudforce_one.threat_events.datasets.create( + account_id=0, + is_public=True, + name="x", + ) + assert_matches_type(DatasetCreateResponse, dataset, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.datasets.with_raw_response.create( + account_id=0, + is_public=True, + name="x", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = response.parse() + assert_matches_type(DatasetCreateResponse, dataset, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.datasets.with_streaming_response.create( + account_id=0, + is_public=True, + name="x", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = response.parse() + assert_matches_type(DatasetCreateResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + dataset = client.cloudforce_one.threat_events.datasets.list( + account_id=0, + ) + assert_matches_type(DatasetListResponse, dataset, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.datasets.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = response.parse() + assert_matches_type(DatasetListResponse, dataset, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.datasets.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = response.parse() + assert_matches_type(DatasetListResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + dataset = client.cloudforce_one.threat_events.datasets.edit( + dataset_id="dataset_id", + account_id=0, + is_public=True, + name="x", + ) + assert_matches_type(DatasetEditResponse, dataset, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.datasets.with_raw_response.edit( + dataset_id="dataset_id", + account_id=0, + is_public=True, + name="x", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = response.parse() + assert_matches_type(DatasetEditResponse, dataset, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.datasets.with_streaming_response.edit( + dataset_id="dataset_id", + account_id=0, + is_public=True, + name="x", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = response.parse() + assert_matches_type(DatasetEditResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): + client.cloudforce_one.threat_events.datasets.with_raw_response.edit( + dataset_id="", + account_id=0, + is_public=True, + name="x", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + dataset = client.cloudforce_one.threat_events.datasets.get( + dataset_id="dataset_id", + account_id=0, + ) + assert_matches_type(DatasetGetResponse, dataset, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.datasets.with_raw_response.get( + dataset_id="dataset_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = response.parse() + assert_matches_type(DatasetGetResponse, dataset, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.datasets.with_streaming_response.get( + dataset_id="dataset_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = response.parse() + assert_matches_type(DatasetGetResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): + client.cloudforce_one.threat_events.datasets.with_raw_response.get( + dataset_id="", + account_id=0, + ) + + @parametrize + def test_method_raw(self, client: Cloudflare) -> None: + dataset = client.cloudforce_one.threat_events.datasets.raw( + event_id="event_id", + account_id=0, + dataset_id="dataset_id", + ) + assert_matches_type(DatasetRawResponse, dataset, path=["response"]) + + @parametrize + def test_raw_response_raw(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.datasets.with_raw_response.raw( + event_id="event_id", + account_id=0, + dataset_id="dataset_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = response.parse() + assert_matches_type(DatasetRawResponse, dataset, path=["response"]) + + @parametrize + def test_streaming_response_raw(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.datasets.with_streaming_response.raw( + event_id="event_id", + account_id=0, + dataset_id="dataset_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = response.parse() + assert_matches_type(DatasetRawResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_raw(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): + client.cloudforce_one.threat_events.datasets.with_raw_response.raw( + event_id="event_id", + account_id=0, + dataset_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.datasets.with_raw_response.raw( + event_id="", + account_id=0, + dataset_id="dataset_id", + ) + + +class TestAsyncDatasets: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + dataset = await async_client.cloudforce_one.threat_events.datasets.create( + account_id=0, + is_public=True, + name="x", + ) + assert_matches_type(DatasetCreateResponse, dataset, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.datasets.with_raw_response.create( + account_id=0, + is_public=True, + name="x", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = await response.parse() + assert_matches_type(DatasetCreateResponse, dataset, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.datasets.with_streaming_response.create( + account_id=0, + is_public=True, + name="x", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = await response.parse() + assert_matches_type(DatasetCreateResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + dataset = await async_client.cloudforce_one.threat_events.datasets.list( + account_id=0, + ) + assert_matches_type(DatasetListResponse, dataset, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.datasets.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = await response.parse() + assert_matches_type(DatasetListResponse, dataset, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.datasets.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = await response.parse() + assert_matches_type(DatasetListResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + dataset = await async_client.cloudforce_one.threat_events.datasets.edit( + dataset_id="dataset_id", + account_id=0, + is_public=True, + name="x", + ) + assert_matches_type(DatasetEditResponse, dataset, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.datasets.with_raw_response.edit( + dataset_id="dataset_id", + account_id=0, + is_public=True, + name="x", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = await response.parse() + assert_matches_type(DatasetEditResponse, dataset, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.datasets.with_streaming_response.edit( + dataset_id="dataset_id", + account_id=0, + is_public=True, + name="x", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = await response.parse() + assert_matches_type(DatasetEditResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): + await async_client.cloudforce_one.threat_events.datasets.with_raw_response.edit( + dataset_id="", + account_id=0, + is_public=True, + name="x", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + dataset = await async_client.cloudforce_one.threat_events.datasets.get( + dataset_id="dataset_id", + account_id=0, + ) + assert_matches_type(DatasetGetResponse, dataset, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.datasets.with_raw_response.get( + dataset_id="dataset_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = await response.parse() + assert_matches_type(DatasetGetResponse, dataset, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.datasets.with_streaming_response.get( + dataset_id="dataset_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = await response.parse() + assert_matches_type(DatasetGetResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): + await async_client.cloudforce_one.threat_events.datasets.with_raw_response.get( + dataset_id="", + account_id=0, + ) + + @parametrize + async def test_method_raw(self, async_client: AsyncCloudflare) -> None: + dataset = await async_client.cloudforce_one.threat_events.datasets.raw( + event_id="event_id", + account_id=0, + dataset_id="dataset_id", + ) + assert_matches_type(DatasetRawResponse, dataset, path=["response"]) + + @parametrize + async def test_raw_response_raw(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.datasets.with_raw_response.raw( + event_id="event_id", + account_id=0, + dataset_id="dataset_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataset = await response.parse() + assert_matches_type(DatasetRawResponse, dataset, path=["response"]) + + @parametrize + async def test_streaming_response_raw(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.datasets.with_streaming_response.raw( + event_id="event_id", + account_id=0, + dataset_id="dataset_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataset = await response.parse() + assert_matches_type(DatasetRawResponse, dataset, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_raw(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): + await async_client.cloudforce_one.threat_events.datasets.with_raw_response.raw( + event_id="event_id", + account_id=0, + dataset_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.datasets.with_raw_response.raw( + event_id="", + account_id=0, + dataset_id="dataset_id", + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/test_event_tags.py b/tests/api_resources/cloudforce_one/threat_events/test_event_tags.py new file mode 100644 index 00000000000..14e7e83d279 --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_event_tags.py @@ -0,0 +1,106 @@ +# 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.types.cloudforce_one.threat_events import EventTagDeleteResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestEventTags: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + event_tag = client.cloudforce_one.threat_events.event_tags.delete( + event_id="event_id", + account_id=0, + ) + assert_matches_type(EventTagDeleteResponse, event_tag, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.event_tags.with_raw_response.delete( + event_id="event_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + event_tag = response.parse() + assert_matches_type(EventTagDeleteResponse, event_tag, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.event_tags.with_streaming_response.delete( + event_id="event_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + event_tag = response.parse() + assert_matches_type(EventTagDeleteResponse, event_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.event_tags.with_raw_response.delete( + event_id="", + account_id=0, + ) + + +class TestAsyncEventTags: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + event_tag = await async_client.cloudforce_one.threat_events.event_tags.delete( + event_id="event_id", + account_id=0, + ) + assert_matches_type(EventTagDeleteResponse, event_tag, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.event_tags.with_raw_response.delete( + event_id="event_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + event_tag = await response.parse() + assert_matches_type(EventTagDeleteResponse, event_tag, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.event_tags.with_streaming_response.delete( + event_id="event_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + event_tag = await response.parse() + assert_matches_type(EventTagDeleteResponse, event_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.event_tags.with_raw_response.delete( + event_id="", + account_id=0, + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/test_indicator_types.py b/tests/api_resources/cloudforce_one/threat_events/test_indicator_types.py new file mode 100644 index 00000000000..44bf37ccffa --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_indicator_types.py @@ -0,0 +1,84 @@ +# 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.types.cloudforce_one.threat_events import IndicatorTypeListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIndicatorTypes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + indicator_type = client.cloudforce_one.threat_events.indicator_types.list( + account_id=0, + ) + assert_matches_type(IndicatorTypeListResponse, indicator_type, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.indicator_types.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + indicator_type = response.parse() + assert_matches_type(IndicatorTypeListResponse, indicator_type, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.indicator_types.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + indicator_type = response.parse() + assert_matches_type(IndicatorTypeListResponse, indicator_type, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncIndicatorTypes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + indicator_type = await async_client.cloudforce_one.threat_events.indicator_types.list( + account_id=0, + ) + assert_matches_type(IndicatorTypeListResponse, indicator_type, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.indicator_types.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + indicator_type = await response.parse() + assert_matches_type(IndicatorTypeListResponse, indicator_type, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.indicator_types.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + indicator_type = await response.parse() + assert_matches_type(IndicatorTypeListResponse, indicator_type, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/threat_events/test_insights.py b/tests/api_resources/cloudforce_one/threat_events/test_insights.py new file mode 100644 index 00000000000..06da194e146 --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_insights.py @@ -0,0 +1,447 @@ +# 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.types.cloudforce_one.threat_events import ( + InsightGetResponse, + InsightEditResponse, + InsightCreatResponse, + InsightDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestInsights: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + insight = client.cloudforce_one.threat_events.insights.delete( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(InsightDeleteResponse, insight, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.insights.with_raw_response.delete( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = response.parse() + assert_matches_type(InsightDeleteResponse, insight, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.insights.with_streaming_response.delete( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = response.parse() + assert_matches_type(InsightDeleteResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.delete( + insight_id="insight_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `insight_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.delete( + insight_id="", + account_id=0, + event_id="event_id", + ) + + @parametrize + def test_method_creat(self, client: Cloudflare) -> None: + insight = client.cloudforce_one.threat_events.insights.creat( + event_id="event_id", + account_id=0, + content="Here is some additional context _in markdown_", + ) + assert_matches_type(InsightCreatResponse, insight, path=["response"]) + + @parametrize + def test_raw_response_creat(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.insights.with_raw_response.creat( + event_id="event_id", + account_id=0, + content="Here is some additional context _in markdown_", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = response.parse() + assert_matches_type(InsightCreatResponse, insight, path=["response"]) + + @parametrize + def test_streaming_response_creat(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.insights.with_streaming_response.creat( + event_id="event_id", + account_id=0, + content="Here is some additional context _in markdown_", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = response.parse() + assert_matches_type(InsightCreatResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_creat(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.creat( + event_id="", + account_id=0, + content="Here is some additional context _in markdown_", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + insight = client.cloudforce_one.threat_events.insights.edit( + insight_id="insight_id", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) + assert_matches_type(InsightEditResponse, insight, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.insights.with_raw_response.edit( + insight_id="insight_id", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = response.parse() + assert_matches_type(InsightEditResponse, insight, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.insights.with_streaming_response.edit( + insight_id="insight_id", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = response.parse() + assert_matches_type(InsightEditResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.edit( + insight_id="insight_id", + account_id=0, + event_id="", + content="Updated: Here is some additional context _in markdown_", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `insight_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.edit( + insight_id="", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + insight = client.cloudforce_one.threat_events.insights.get( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(InsightGetResponse, insight, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.insights.with_raw_response.get( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = response.parse() + assert_matches_type(InsightGetResponse, insight, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.insights.with_streaming_response.get( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = response.parse() + assert_matches_type(InsightGetResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.get( + insight_id="insight_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `insight_id` but received ''"): + client.cloudforce_one.threat_events.insights.with_raw_response.get( + insight_id="", + account_id=0, + event_id="event_id", + ) + + +class TestAsyncInsights: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.cloudforce_one.threat_events.insights.delete( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(InsightDeleteResponse, insight, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.insights.with_raw_response.delete( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = await response.parse() + assert_matches_type(InsightDeleteResponse, insight, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.insights.with_streaming_response.delete( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = await response.parse() + assert_matches_type(InsightDeleteResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.delete( + insight_id="insight_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `insight_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.delete( + insight_id="", + account_id=0, + event_id="event_id", + ) + + @parametrize + async def test_method_creat(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.cloudforce_one.threat_events.insights.creat( + event_id="event_id", + account_id=0, + content="Here is some additional context _in markdown_", + ) + assert_matches_type(InsightCreatResponse, insight, path=["response"]) + + @parametrize + async def test_raw_response_creat(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.insights.with_raw_response.creat( + event_id="event_id", + account_id=0, + content="Here is some additional context _in markdown_", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = await response.parse() + assert_matches_type(InsightCreatResponse, insight, path=["response"]) + + @parametrize + async def test_streaming_response_creat(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.insights.with_streaming_response.creat( + event_id="event_id", + account_id=0, + content="Here is some additional context _in markdown_", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = await response.parse() + assert_matches_type(InsightCreatResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_creat(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.creat( + event_id="", + account_id=0, + content="Here is some additional context _in markdown_", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.cloudforce_one.threat_events.insights.edit( + insight_id="insight_id", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) + assert_matches_type(InsightEditResponse, insight, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.insights.with_raw_response.edit( + insight_id="insight_id", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = await response.parse() + assert_matches_type(InsightEditResponse, insight, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.insights.with_streaming_response.edit( + insight_id="insight_id", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = await response.parse() + assert_matches_type(InsightEditResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.edit( + insight_id="insight_id", + account_id=0, + event_id="", + content="Updated: Here is some additional context _in markdown_", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `insight_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.edit( + insight_id="", + account_id=0, + event_id="event_id", + content="Updated: Here is some additional context _in markdown_", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + insight = await async_client.cloudforce_one.threat_events.insights.get( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(InsightGetResponse, insight, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.insights.with_raw_response.get( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + insight = await response.parse() + assert_matches_type(InsightGetResponse, insight, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.insights.with_streaming_response.get( + insight_id="insight_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + insight = await response.parse() + assert_matches_type(InsightGetResponse, insight, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.get( + insight_id="insight_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `insight_id` but received ''"): + await async_client.cloudforce_one.threat_events.insights.with_raw_response.get( + insight_id="", + account_id=0, + event_id="event_id", + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/test_raw.py b/tests/api_resources/cloudforce_one/threat_events/test_raw.py new file mode 100644 index 00000000000..25220fb9f2a --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_raw.py @@ -0,0 +1,258 @@ +# 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.types.cloudforce_one.threat_events import RawGetResponse, RawEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRaw: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + raw = client.cloudforce_one.threat_events.raw.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(RawEditResponse, raw, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + raw = client.cloudforce_one.threat_events.raw.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + data={}, + source="example.com", + tlp="amber", + ) + assert_matches_type(RawEditResponse, raw, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.raw.with_raw_response.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + raw = response.parse() + assert_matches_type(RawEditResponse, raw, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.raw.with_streaming_response.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + raw = response.parse() + assert_matches_type(RawEditResponse, raw, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.raw.with_raw_response.edit( + raw_id="raw_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `raw_id` but received ''"): + client.cloudforce_one.threat_events.raw.with_raw_response.edit( + raw_id="", + account_id=0, + event_id="event_id", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + raw = client.cloudforce_one.threat_events.raw.get( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(RawGetResponse, raw, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.raw.with_raw_response.get( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + raw = response.parse() + assert_matches_type(RawGetResponse, raw, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.raw.with_streaming_response.get( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + raw = response.parse() + assert_matches_type(RawGetResponse, raw, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.raw.with_raw_response.get( + raw_id="raw_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `raw_id` but received ''"): + client.cloudforce_one.threat_events.raw.with_raw_response.get( + raw_id="", + account_id=0, + event_id="event_id", + ) + + +class TestAsyncRaw: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + raw = await async_client.cloudforce_one.threat_events.raw.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(RawEditResponse, raw, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + raw = await async_client.cloudforce_one.threat_events.raw.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + data={}, + source="example.com", + tlp="amber", + ) + assert_matches_type(RawEditResponse, raw, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.raw.with_raw_response.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + raw = await response.parse() + assert_matches_type(RawEditResponse, raw, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.raw.with_streaming_response.edit( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + raw = await response.parse() + assert_matches_type(RawEditResponse, raw, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.raw.with_raw_response.edit( + raw_id="raw_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `raw_id` but received ''"): + await async_client.cloudforce_one.threat_events.raw.with_raw_response.edit( + raw_id="", + account_id=0, + event_id="event_id", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + raw = await async_client.cloudforce_one.threat_events.raw.get( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + assert_matches_type(RawGetResponse, raw, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.raw.with_raw_response.get( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + raw = await response.parse() + assert_matches_type(RawGetResponse, raw, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.raw.with_streaming_response.get( + raw_id="raw_id", + account_id=0, + event_id="event_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + raw = await response.parse() + assert_matches_type(RawGetResponse, raw, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.raw.with_raw_response.get( + raw_id="raw_id", + account_id=0, + event_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `raw_id` but received ''"): + await async_client.cloudforce_one.threat_events.raw.with_raw_response.get( + raw_id="", + account_id=0, + event_id="event_id", + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/test_relate.py b/tests/api_resources/cloudforce_one/threat_events/test_relate.py new file mode 100644 index 00000000000..844c43856bb --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_relate.py @@ -0,0 +1,106 @@ +# 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.types.cloudforce_one.threat_events import RelateDeleteResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRelate: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + relate = client.cloudforce_one.threat_events.relate.delete( + event_id="event_id", + account_id=0, + ) + assert_matches_type(RelateDeleteResponse, relate, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.relate.with_raw_response.delete( + event_id="event_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + relate = response.parse() + assert_matches_type(RelateDeleteResponse, relate, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.relate.with_streaming_response.delete( + event_id="event_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + relate = response.parse() + assert_matches_type(RelateDeleteResponse, relate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + client.cloudforce_one.threat_events.relate.with_raw_response.delete( + event_id="", + account_id=0, + ) + + +class TestAsyncRelate: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + relate = await async_client.cloudforce_one.threat_events.relate.delete( + event_id="event_id", + account_id=0, + ) + assert_matches_type(RelateDeleteResponse, relate, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.relate.with_raw_response.delete( + event_id="event_id", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + relate = await response.parse() + assert_matches_type(RelateDeleteResponse, relate, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.relate.with_streaming_response.delete( + event_id="event_id", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + relate = await response.parse() + assert_matches_type(RelateDeleteResponse, relate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): + await async_client.cloudforce_one.threat_events.relate.with_raw_response.delete( + event_id="", + account_id=0, + ) diff --git a/tests/api_resources/cloudforce_one/threat_events/test_target_industries.py b/tests/api_resources/cloudforce_one/threat_events/test_target_industries.py new file mode 100644 index 00000000000..15ddbafb2e1 --- /dev/null +++ b/tests/api_resources/cloudforce_one/threat_events/test_target_industries.py @@ -0,0 +1,84 @@ +# 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.types.cloudforce_one.threat_events import TargetIndustryListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTargetIndustries: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + target_industry = client.cloudforce_one.threat_events.target_industries.list( + account_id=0, + ) + assert_matches_type(TargetIndustryListResponse, target_industry, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.cloudforce_one.threat_events.target_industries.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + target_industry = response.parse() + assert_matches_type(TargetIndustryListResponse, target_industry, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.cloudforce_one.threat_events.target_industries.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + target_industry = response.parse() + assert_matches_type(TargetIndustryListResponse, target_industry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncTargetIndustries: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + target_industry = await async_client.cloudforce_one.threat_events.target_industries.list( + account_id=0, + ) + assert_matches_type(TargetIndustryListResponse, target_industry, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cloudforce_one.threat_events.target_industries.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + target_industry = await response.parse() + assert_matches_type(TargetIndustryListResponse, target_industry, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.cloudforce_one.threat_events.target_industries.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + target_industry = await response.parse() + assert_matches_type(TargetIndustryListResponse, target_industry, path=["response"]) + + assert cast(Any, response.is_closed) is True