Skip to content

Commit 4beeff9

Browse files
feat(threat_events): add list support
1 parent c579468 commit 4beeff9

File tree

7 files changed

+348
-2
lines changed

7 files changed

+348
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1712
1+
configured_endpoints: 1713
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-40991506ce58ce957e8a66e67a3ea0ce30eb6a573c30addc2a60a80ea6b378b8.yml
33
openapi_spec_hash: 49aee83e2c8c51d02a2bf4c62d70b3c0
4-
config_hash: 92bfde5d1009bebb90da71119327e5bf
4+
config_hash: 747eb99c1820d67851071225b0065a26

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8876,6 +8876,7 @@ Types:
88768876
```python
88778877
from cloudflare.types.cloudforce_one import (
88788878
ThreatEventCreateResponse,
8879+
ThreatEventListResponse,
88798880
ThreatEventDeleteResponse,
88808881
ThreatEventBulkCreateResponse,
88818882
ThreatEventEditResponse,
@@ -8886,6 +8887,7 @@ from cloudflare.types.cloudforce_one import (
88868887
Methods:
88878888

88888889
- <code title="post /accounts/{account_id}/cloudforce-one/events/create">client.cloudforce_one.threat_events.<a href="./src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py">create</a>(\*, path_account_id, \*\*<a href="src/cloudflare/types/cloudforce_one/threat_event_create_params.py">params</a>) -> <a href="./src/cloudflare/types/cloudforce_one/threat_event_create_response.py">ThreatEventCreateResponse</a></code>
8890+
- <code title="get /accounts/{account_id}/cloudforce-one/events">client.cloudforce_one.threat_events.<a href="./src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/cloudforce_one/threat_event_list_params.py">params</a>) -> <a href="./src/cloudflare/types/cloudforce_one/threat_event_list_response.py">ThreatEventListResponse</a></code>
88898891
- <code title="delete /accounts/{account_id}/cloudforce-one/events/{event_id}">client.cloudforce_one.threat_events.<a href="./src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py">delete</a>(event_id, \*, account_id) -> <a href="./src/cloudflare/types/cloudforce_one/threat_event_delete_response.py">ThreatEventDeleteResponse</a></code>
88908892
- <code title="post /accounts/{account_id}/cloudforce-one/events/create/bulk">client.cloudforce_one.threat_events.<a href="./src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py">bulk_create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/cloudforce_one/threat_event_bulk_create_params.py">params</a>) -> <a href="./src/cloudflare/types/cloudforce_one/threat_event_bulk_create_response.py">ThreatEventBulkCreateResponse</a></code>
88918893
- <code title="patch /accounts/{account_id}/cloudforce-one/events/{event_id}">client.cloudforce_one.threat_events.<a href="./src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py">edit</a>(event_id, \*, account_id, \*\*<a href="src/cloudflare/types/cloudforce_one/threat_event_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/cloudforce_one/threat_event_edit_response.py">ThreatEventEditResponse</a></code>

src/cloudflare/resources/cloudforce_one/threat_events/threat_events.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from typing import List, Union, Iterable
66
from datetime import datetime
7+
from typing_extensions import Literal
78

89
import httpx
910

@@ -116,11 +117,13 @@
116117
)
117118
from ....types.cloudforce_one import (
118119
threat_event_edit_params,
120+
threat_event_list_params,
119121
threat_event_create_params,
120122
threat_event_bulk_create_params,
121123
)
122124
from ....types.cloudforce_one.threat_event_get_response import ThreatEventGetResponse
123125
from ....types.cloudforce_one.threat_event_edit_response import ThreatEventEditResponse
126+
from ....types.cloudforce_one.threat_event_list_response import ThreatEventListResponse
124127
from ....types.cloudforce_one.threat_event_create_response import ThreatEventCreateResponse
125128
from ....types.cloudforce_one.threat_event_delete_response import ThreatEventDeleteResponse
126129
from ....types.cloudforce_one.threat_event_bulk_create_response import ThreatEventBulkCreateResponse
@@ -265,6 +268,63 @@ def create(
265268
cast_to=ThreatEventCreateResponse,
266269
)
267270

271+
def list(
272+
self,
273+
*,
274+
account_id: float,
275+
dataset_id: List[str] | NotGiven = NOT_GIVEN,
276+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
277+
order_by: str | NotGiven = NOT_GIVEN,
278+
page: float | NotGiven = NOT_GIVEN,
279+
page_size: float | NotGiven = NOT_GIVEN,
280+
search: Iterable[threat_event_list_params.Search] | NotGiven = NOT_GIVEN,
281+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
282+
# The extra values given here take precedence over values defined on the client or passed to this method.
283+
extra_headers: Headers | None = None,
284+
extra_query: Query | None = None,
285+
extra_body: Body | None = None,
286+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
287+
) -> ThreatEventListResponse:
288+
"""The `datasetId` parameter must be defined.
289+
290+
Must provide query parameters. To
291+
list existing datasets (and their IDs), use the
292+
[`List Datasets`](https://developers.cloudflare.com/api/resources/cloudforce_one/subresources/threat_events/subresources/datasets/methods/list/)
293+
endpoint.
294+
295+
Args:
296+
account_id: Account ID
297+
298+
extra_headers: Send extra headers
299+
300+
extra_query: Add additional query parameters to the request
301+
302+
extra_body: Add additional JSON properties to the request
303+
304+
timeout: Override the client-level default timeout for this request, in seconds
305+
"""
306+
return self._get(
307+
f"/accounts/{account_id}/cloudforce-one/events",
308+
options=make_request_options(
309+
extra_headers=extra_headers,
310+
extra_query=extra_query,
311+
extra_body=extra_body,
312+
timeout=timeout,
313+
query=maybe_transform(
314+
{
315+
"dataset_id": dataset_id,
316+
"order": order,
317+
"order_by": order_by,
318+
"page": page,
319+
"page_size": page_size,
320+
"search": search,
321+
},
322+
threat_event_list_params.ThreatEventListParams,
323+
),
324+
),
325+
cast_to=ThreatEventListResponse,
326+
)
327+
268328
def delete(
269329
self,
270330
event_id: str,
@@ -592,6 +652,63 @@ async def create(
592652
cast_to=ThreatEventCreateResponse,
593653
)
594654

655+
async def list(
656+
self,
657+
*,
658+
account_id: float,
659+
dataset_id: List[str] | NotGiven = NOT_GIVEN,
660+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
661+
order_by: str | NotGiven = NOT_GIVEN,
662+
page: float | NotGiven = NOT_GIVEN,
663+
page_size: float | NotGiven = NOT_GIVEN,
664+
search: Iterable[threat_event_list_params.Search] | NotGiven = NOT_GIVEN,
665+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
666+
# The extra values given here take precedence over values defined on the client or passed to this method.
667+
extra_headers: Headers | None = None,
668+
extra_query: Query | None = None,
669+
extra_body: Body | None = None,
670+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
671+
) -> ThreatEventListResponse:
672+
"""The `datasetId` parameter must be defined.
673+
674+
Must provide query parameters. To
675+
list existing datasets (and their IDs), use the
676+
[`List Datasets`](https://developers.cloudflare.com/api/resources/cloudforce_one/subresources/threat_events/subresources/datasets/methods/list/)
677+
endpoint.
678+
679+
Args:
680+
account_id: Account ID
681+
682+
extra_headers: Send extra headers
683+
684+
extra_query: Add additional query parameters to the request
685+
686+
extra_body: Add additional JSON properties to the request
687+
688+
timeout: Override the client-level default timeout for this request, in seconds
689+
"""
690+
return await self._get(
691+
f"/accounts/{account_id}/cloudforce-one/events",
692+
options=make_request_options(
693+
extra_headers=extra_headers,
694+
extra_query=extra_query,
695+
extra_body=extra_body,
696+
timeout=timeout,
697+
query=await async_maybe_transform(
698+
{
699+
"dataset_id": dataset_id,
700+
"order": order,
701+
"order_by": order_by,
702+
"page": page,
703+
"page_size": page_size,
704+
"search": search,
705+
},
706+
threat_event_list_params.ThreatEventListParams,
707+
),
708+
),
709+
cast_to=ThreatEventListResponse,
710+
)
711+
595712
async def delete(
596713
self,
597714
event_id: str,
@@ -789,6 +906,9 @@ def __init__(self, threat_events: ThreatEventsResource) -> None:
789906
self.create = to_raw_response_wrapper(
790907
threat_events.create,
791908
)
909+
self.list = to_raw_response_wrapper(
910+
threat_events.list,
911+
)
792912
self.delete = to_raw_response_wrapper(
793913
threat_events.delete,
794914
)
@@ -858,6 +978,9 @@ def __init__(self, threat_events: AsyncThreatEventsResource) -> None:
858978
self.create = async_to_raw_response_wrapper(
859979
threat_events.create,
860980
)
981+
self.list = async_to_raw_response_wrapper(
982+
threat_events.list,
983+
)
861984
self.delete = async_to_raw_response_wrapper(
862985
threat_events.delete,
863986
)
@@ -927,6 +1050,9 @@ def __init__(self, threat_events: ThreatEventsResource) -> None:
9271050
self.create = to_streamed_response_wrapper(
9281051
threat_events.create,
9291052
)
1053+
self.list = to_streamed_response_wrapper(
1054+
threat_events.list,
1055+
)
9301056
self.delete = to_streamed_response_wrapper(
9311057
threat_events.delete,
9321058
)
@@ -996,6 +1122,9 @@ def __init__(self, threat_events: AsyncThreatEventsResource) -> None:
9961122
self.create = async_to_streamed_response_wrapper(
9971123
threat_events.create,
9981124
)
1125+
self.list = async_to_streamed_response_wrapper(
1126+
threat_events.list,
1127+
)
9991128
self.delete = async_to_streamed_response_wrapper(
10001129
threat_events.delete,
10011130
)

src/cloudflare/types/cloudforce_one/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
from .request_types_response import RequestTypesResponse as RequestTypesResponse
1414
from .request_delete_response import RequestDeleteResponse as RequestDeleteResponse
1515
from .threat_event_edit_params import ThreatEventEditParams as ThreatEventEditParams
16+
from .threat_event_list_params import ThreatEventListParams as ThreatEventListParams
1617
from .threat_event_get_response import ThreatEventGetResponse as ThreatEventGetResponse
1718
from .threat_event_create_params import ThreatEventCreateParams as ThreatEventCreateParams
1819
from .threat_event_edit_response import ThreatEventEditResponse as ThreatEventEditResponse
20+
from .threat_event_list_response import ThreatEventListResponse as ThreatEventListResponse
1921
from .threat_event_create_response import ThreatEventCreateResponse as ThreatEventCreateResponse
2022
from .threat_event_delete_response import ThreatEventDeleteResponse as ThreatEventDeleteResponse
2123
from .threat_event_bulk_create_params import ThreatEventBulkCreateParams as ThreatEventBulkCreateParams
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import List, Union, Iterable
6+
from typing_extensions import Literal, Required, Annotated, TypedDict
7+
8+
from ..._utils import PropertyInfo
9+
10+
__all__ = ["ThreatEventListParams", "Search"]
11+
12+
13+
class ThreatEventListParams(TypedDict, total=False):
14+
account_id: Required[float]
15+
"""Account ID"""
16+
17+
dataset_id: Annotated[List[str], PropertyInfo(alias="datasetId")]
18+
19+
order: Literal["asc", "desc"]
20+
21+
order_by: Annotated[str, PropertyInfo(alias="orderBy")]
22+
23+
page: float
24+
25+
page_size: Annotated[float, PropertyInfo(alias="pageSize")]
26+
27+
search: Iterable[Search]
28+
29+
30+
class Search(TypedDict, total=False):
31+
field: str
32+
33+
op: Literal["equals", "not", "gt", "gte", "lt", "lte", "like", "contains", "startsWith", "endsWith", "in", "find"]
34+
35+
value: Union[str, float, List[Union[str, float]]]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from typing_extensions import TypeAlias
5+
6+
from pydantic import Field as FieldInfo
7+
8+
from ..._models import BaseModel
9+
10+
__all__ = ["ThreatEventListResponse", "ThreatEventListResponseItem"]
11+
12+
13+
class ThreatEventListResponseItem(BaseModel):
14+
id: float
15+
16+
account_id: float = FieldInfo(alias="accountId")
17+
18+
attacker: str
19+
20+
attacker_country: str = FieldInfo(alias="attackerCountry")
21+
22+
category: str
23+
24+
category_id: float = FieldInfo(alias="categoryId")
25+
26+
date: str
27+
28+
event: str
29+
30+
indicator: str
31+
32+
indicator_type: str = FieldInfo(alias="indicatorType")
33+
34+
indicator_type_id: float = FieldInfo(alias="indicatorTypeId")
35+
36+
kill_chain: float = FieldInfo(alias="killChain")
37+
38+
mitre_attack: List[str] = FieldInfo(alias="mitreAttack")
39+
40+
num_referenced: float = FieldInfo(alias="numReferenced")
41+
42+
num_references: float = FieldInfo(alias="numReferences")
43+
44+
raw_id: str = FieldInfo(alias="rawId")
45+
46+
referenced: List[str]
47+
48+
referenced_ids: List[float] = FieldInfo(alias="referencedIds")
49+
50+
references: List[str]
51+
52+
references_ids: List[float] = FieldInfo(alias="referencesIds")
53+
54+
tags: List[str]
55+
56+
target_country: str = FieldInfo(alias="targetCountry")
57+
58+
target_industry: str = FieldInfo(alias="targetIndustry")
59+
60+
tlp: str
61+
62+
uuid: str
63+
64+
insight: Optional[str] = None
65+
66+
releasability_id: Optional[str] = FieldInfo(alias="releasabilityId", default=None)
67+
68+
69+
ThreatEventListResponse: TypeAlias = List[ThreatEventListResponseItem]

0 commit comments

Comments
 (0)