Skip to content

Commit b0fc29f

Browse files
feat: feat(abuse_reports): Expose new abuse report endpoints. GET and LIST.
* feat(abuse_reports): Expose new abuse report endpoints. GET and LIST. * feat(abuse_reports): Expose new abuse report endpoints
1 parent 7199aa3 commit b0fc29f

8 files changed

Lines changed: 629 additions & 7 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1887
1+
configured_endpoints: 1889
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fe5f9f74ec7fae587b81aa6c4405a2129bbe6c146d36a6a8eee6cbc184dceb01.yml
33
openapi_spec_hash: ad2c2470332035b5d92e2a94faefe5a6
4-
config_hash: 47bfb436213622df92afdda8ce4f077f
4+
config_hash: f02bc3ad56bdede6c515f996ca86012c

api.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10035,12 +10035,18 @@ Methods:
1003510035
Types:
1003610036

1003710037
```python
10038-
from cloudflare.types.abuse_reports import AbuseReportCreateResponse
10038+
from cloudflare.types.abuse_reports import (
10039+
AbuseReportCreateResponse,
10040+
AbuseReportListResponse,
10041+
AbuseReportGetResponse,
10042+
)
1003910043
```
1004010044

1004110045
Methods:
1004210046

1004310047
- <code title="post /accounts/{account_id}/abuse-reports/{report_param}">client.abuse_reports.<a href="./src/cloudflare/resources/abuse_reports.py">create</a>(report_param, \*, account_id, \*\*<a href="src/cloudflare/types/abuse_reports/abuse_report_create_params.py">params</a>) -> <a href="./src/cloudflare/types/abuse_reports/abuse_report_create_response.py">str</a></code>
10048+
- <code title="get /accounts/{account_id}/abuse-reports">client.abuse_reports.<a href="./src/cloudflare/resources/abuse_reports.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/abuse_reports/abuse_report_list_params.py">params</a>) -> <a href="./src/cloudflare/types/abuse_reports/abuse_report_list_response.py">SyncV4PagePagination[Optional[AbuseReportListResponse]]</a></code>
10049+
- <code title="get /accounts/{account_id}/abuse-reports/{report_param}">client.abuse_reports.<a href="./src/cloudflare/resources/abuse_reports.py">get</a>(report_param, \*, account_id) -> <a href="./src/cloudflare/types/abuse_reports/abuse_report_get_response.py">AbuseReportGetResponse</a></code>
1004410050

1004510051
# AI
1004610052

src/cloudflare/resources/abuse_reports.py

Lines changed: 266 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Type, cast
5+
from typing import Type, Optional, cast
66
from typing_extensions import Literal, overload
77

88
import httpx
@@ -18,8 +18,11 @@
1818
async_to_streamed_response_wrapper,
1919
)
2020
from .._wrappers import ResultWrapper
21-
from .._base_client import make_request_options
22-
from ..types.abuse_reports import abuse_report_create_params
21+
from ..pagination import SyncV4PagePagination, AsyncV4PagePagination
22+
from .._base_client import AsyncPaginator, make_request_options
23+
from ..types.abuse_reports import abuse_report_list_params, abuse_report_create_params
24+
from ..types.abuse_reports.abuse_report_get_response import AbuseReportGetResponse
25+
from ..types.abuse_reports.abuse_report_list_response import AbuseReportListResponse
2326
from ..types.abuse_reports.abuse_report_create_response import AbuseReportCreateResponse
2427

2528
__all__ = ["AbuseReportsResource", "AsyncAbuseReportsResource"]
@@ -928,6 +931,124 @@ def create(
928931
cast_to=cast(Type[str], ResultWrapper[str]),
929932
)
930933

934+
def list(
935+
self,
936+
*,
937+
account_id: str,
938+
created_after: str | Omit = omit,
939+
created_before: str | Omit = omit,
940+
domain: str | Omit = omit,
941+
mitigation_status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit,
942+
page: int | Omit = omit,
943+
per_page: int | Omit = omit,
944+
sort: str | Omit = omit,
945+
status: Literal["accepted", "in_review"] | Omit = omit,
946+
type: Literal["PHISH", "GEN", "THREAT", "DMCA", "EMER", "TM", "REG_WHO", "NCSEI", "NETWORK"] | Omit = omit,
947+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
948+
# The extra values given here take precedence over values defined on the client or passed to this method.
949+
extra_headers: Headers | None = None,
950+
extra_query: Query | None = None,
951+
extra_body: Body | None = None,
952+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
953+
) -> SyncV4PagePagination[Optional[AbuseReportListResponse]]:
954+
"""
955+
List the abuse reports for a given account.
956+
957+
Args:
958+
created_after: Returns reports created after the specified date
959+
960+
created_before: Returns reports created before the specified date
961+
962+
domain: Filter by domain name related to the abuse report
963+
964+
mitigation_status: Filter reports that have any mitigations in the given status.
965+
966+
page: Where in pagination to start listing abuse reports
967+
968+
per_page: How many abuse reports per page to list
969+
970+
sort: A property to sort by, followed by the order (id, cdate, domain, type, status)
971+
972+
status: Filter by the status of the report.
973+
974+
type: Filter by the type of the report.
975+
976+
extra_headers: Send extra headers
977+
978+
extra_query: Add additional query parameters to the request
979+
980+
extra_body: Add additional JSON properties to the request
981+
982+
timeout: Override the client-level default timeout for this request, in seconds
983+
"""
984+
if not account_id:
985+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
986+
return self._get_api_list(
987+
f"/accounts/{account_id}/abuse-reports",
988+
page=SyncV4PagePagination[Optional[AbuseReportListResponse]],
989+
options=make_request_options(
990+
extra_headers=extra_headers,
991+
extra_query=extra_query,
992+
extra_body=extra_body,
993+
timeout=timeout,
994+
query=maybe_transform(
995+
{
996+
"created_after": created_after,
997+
"created_before": created_before,
998+
"domain": domain,
999+
"mitigation_status": mitigation_status,
1000+
"page": page,
1001+
"per_page": per_page,
1002+
"sort": sort,
1003+
"status": status,
1004+
"type": type,
1005+
},
1006+
abuse_report_list_params.AbuseReportListParams,
1007+
),
1008+
),
1009+
model=AbuseReportListResponse,
1010+
)
1011+
1012+
def get(
1013+
self,
1014+
report_param: str,
1015+
*,
1016+
account_id: str,
1017+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1018+
# The extra values given here take precedence over values defined on the client or passed to this method.
1019+
extra_headers: Headers | None = None,
1020+
extra_query: Query | None = None,
1021+
extra_body: Body | None = None,
1022+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1023+
) -> AbuseReportGetResponse:
1024+
"""
1025+
Retrieve an abuse report.
1026+
1027+
Args:
1028+
extra_headers: Send extra headers
1029+
1030+
extra_query: Add additional query parameters to the request
1031+
1032+
extra_body: Add additional JSON properties to the request
1033+
1034+
timeout: Override the client-level default timeout for this request, in seconds
1035+
"""
1036+
if not account_id:
1037+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
1038+
if not report_param:
1039+
raise ValueError(f"Expected a non-empty value for `report_param` but received {report_param!r}")
1040+
return self._get(
1041+
f"/accounts/{account_id}/abuse-reports/{report_param}",
1042+
options=make_request_options(
1043+
extra_headers=extra_headers,
1044+
extra_query=extra_query,
1045+
extra_body=extra_body,
1046+
timeout=timeout,
1047+
post_parser=ResultWrapper[AbuseReportGetResponse]._unwrapper,
1048+
),
1049+
cast_to=cast(Type[AbuseReportGetResponse], ResultWrapper[AbuseReportGetResponse]),
1050+
)
1051+
9311052

9321053
class AsyncAbuseReportsResource(AsyncAPIResource):
9331054
@cached_property
@@ -1832,6 +1953,124 @@ async def create(
18321953
cast_to=cast(Type[str], ResultWrapper[str]),
18331954
)
18341955

1956+
def list(
1957+
self,
1958+
*,
1959+
account_id: str,
1960+
created_after: str | Omit = omit,
1961+
created_before: str | Omit = omit,
1962+
domain: str | Omit = omit,
1963+
mitigation_status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit,
1964+
page: int | Omit = omit,
1965+
per_page: int | Omit = omit,
1966+
sort: str | Omit = omit,
1967+
status: Literal["accepted", "in_review"] | Omit = omit,
1968+
type: Literal["PHISH", "GEN", "THREAT", "DMCA", "EMER", "TM", "REG_WHO", "NCSEI", "NETWORK"] | Omit = omit,
1969+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1970+
# The extra values given here take precedence over values defined on the client or passed to this method.
1971+
extra_headers: Headers | None = None,
1972+
extra_query: Query | None = None,
1973+
extra_body: Body | None = None,
1974+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1975+
) -> AsyncPaginator[Optional[AbuseReportListResponse], AsyncV4PagePagination[Optional[AbuseReportListResponse]]]:
1976+
"""
1977+
List the abuse reports for a given account.
1978+
1979+
Args:
1980+
created_after: Returns reports created after the specified date
1981+
1982+
created_before: Returns reports created before the specified date
1983+
1984+
domain: Filter by domain name related to the abuse report
1985+
1986+
mitigation_status: Filter reports that have any mitigations in the given status.
1987+
1988+
page: Where in pagination to start listing abuse reports
1989+
1990+
per_page: How many abuse reports per page to list
1991+
1992+
sort: A property to sort by, followed by the order (id, cdate, domain, type, status)
1993+
1994+
status: Filter by the status of the report.
1995+
1996+
type: Filter by the type of the report.
1997+
1998+
extra_headers: Send extra headers
1999+
2000+
extra_query: Add additional query parameters to the request
2001+
2002+
extra_body: Add additional JSON properties to the request
2003+
2004+
timeout: Override the client-level default timeout for this request, in seconds
2005+
"""
2006+
if not account_id:
2007+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
2008+
return self._get_api_list(
2009+
f"/accounts/{account_id}/abuse-reports",
2010+
page=AsyncV4PagePagination[Optional[AbuseReportListResponse]],
2011+
options=make_request_options(
2012+
extra_headers=extra_headers,
2013+
extra_query=extra_query,
2014+
extra_body=extra_body,
2015+
timeout=timeout,
2016+
query=maybe_transform(
2017+
{
2018+
"created_after": created_after,
2019+
"created_before": created_before,
2020+
"domain": domain,
2021+
"mitigation_status": mitigation_status,
2022+
"page": page,
2023+
"per_page": per_page,
2024+
"sort": sort,
2025+
"status": status,
2026+
"type": type,
2027+
},
2028+
abuse_report_list_params.AbuseReportListParams,
2029+
),
2030+
),
2031+
model=AbuseReportListResponse,
2032+
)
2033+
2034+
async def get(
2035+
self,
2036+
report_param: str,
2037+
*,
2038+
account_id: str,
2039+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2040+
# The extra values given here take precedence over values defined on the client or passed to this method.
2041+
extra_headers: Headers | None = None,
2042+
extra_query: Query | None = None,
2043+
extra_body: Body | None = None,
2044+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
2045+
) -> AbuseReportGetResponse:
2046+
"""
2047+
Retrieve an abuse report.
2048+
2049+
Args:
2050+
extra_headers: Send extra headers
2051+
2052+
extra_query: Add additional query parameters to the request
2053+
2054+
extra_body: Add additional JSON properties to the request
2055+
2056+
timeout: Override the client-level default timeout for this request, in seconds
2057+
"""
2058+
if not account_id:
2059+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
2060+
if not report_param:
2061+
raise ValueError(f"Expected a non-empty value for `report_param` but received {report_param!r}")
2062+
return await self._get(
2063+
f"/accounts/{account_id}/abuse-reports/{report_param}",
2064+
options=make_request_options(
2065+
extra_headers=extra_headers,
2066+
extra_query=extra_query,
2067+
extra_body=extra_body,
2068+
timeout=timeout,
2069+
post_parser=ResultWrapper[AbuseReportGetResponse]._unwrapper,
2070+
),
2071+
cast_to=cast(Type[AbuseReportGetResponse], ResultWrapper[AbuseReportGetResponse]),
2072+
)
2073+
18352074

18362075
class AbuseReportsResourceWithRawResponse:
18372076
def __init__(self, abuse_reports: AbuseReportsResource) -> None:
@@ -1840,6 +2079,12 @@ def __init__(self, abuse_reports: AbuseReportsResource) -> None:
18402079
self.create = to_raw_response_wrapper(
18412080
abuse_reports.create,
18422081
)
2082+
self.list = to_raw_response_wrapper(
2083+
abuse_reports.list,
2084+
)
2085+
self.get = to_raw_response_wrapper(
2086+
abuse_reports.get,
2087+
)
18432088

18442089

18452090
class AsyncAbuseReportsResourceWithRawResponse:
@@ -1849,6 +2094,12 @@ def __init__(self, abuse_reports: AsyncAbuseReportsResource) -> None:
18492094
self.create = async_to_raw_response_wrapper(
18502095
abuse_reports.create,
18512096
)
2097+
self.list = async_to_raw_response_wrapper(
2098+
abuse_reports.list,
2099+
)
2100+
self.get = async_to_raw_response_wrapper(
2101+
abuse_reports.get,
2102+
)
18522103

18532104

18542105
class AbuseReportsResourceWithStreamingResponse:
@@ -1858,6 +2109,12 @@ def __init__(self, abuse_reports: AbuseReportsResource) -> None:
18582109
self.create = to_streamed_response_wrapper(
18592110
abuse_reports.create,
18602111
)
2112+
self.list = to_streamed_response_wrapper(
2113+
abuse_reports.list,
2114+
)
2115+
self.get = to_streamed_response_wrapper(
2116+
abuse_reports.get,
2117+
)
18612118

18622119

18632120
class AsyncAbuseReportsResourceWithStreamingResponse:
@@ -1867,3 +2124,9 @@ def __init__(self, abuse_reports: AsyncAbuseReportsResource) -> None:
18672124
self.create = async_to_streamed_response_wrapper(
18682125
abuse_reports.create,
18692126
)
2127+
self.list = async_to_streamed_response_wrapper(
2128+
abuse_reports.list,
2129+
)
2130+
self.get = async_to_streamed_response_wrapper(
2131+
abuse_reports.get,
2132+
)

src/cloudflare/types/abuse_reports/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
from __future__ import annotations
44

5+
from .abuse_report_list_params import AbuseReportListParams as AbuseReportListParams
6+
from .abuse_report_get_response import AbuseReportGetResponse as AbuseReportGetResponse
57
from .abuse_report_create_params import AbuseReportCreateParams as AbuseReportCreateParams
8+
from .abuse_report_list_response import AbuseReportListResponse as AbuseReportListResponse
69
from .abuse_report_create_response import AbuseReportCreateResponse as AbuseReportCreateResponse

0 commit comments

Comments
 (0)