22
33import { APIResource } from '../resource' ;
44import * as Core from '../core' ;
5+ import { V4PagePagination , type V4PagePaginationParams } from '../pagination' ;
56
67export class AbuseReports extends APIResource {
78 /**
@@ -20,13 +21,182 @@ export class AbuseReports extends APIResource {
2021 } ) as Core . APIPromise < { result : AbuseReportCreateResponse } >
2122 ) . _thenUnwrap ( ( obj ) => obj . result ) ;
2223 }
24+
25+ /**
26+ * List the abuse reports for a given account.
27+ */
28+ list (
29+ params : AbuseReportListParams ,
30+ options ?: Core . RequestOptions ,
31+ ) : Core . PagePromise < AbuseReportListResponsesV4PagePagination , AbuseReportListResponse > {
32+ const { account_id, ...query } = params ;
33+ return this . _client . getAPIList (
34+ `/accounts/${ account_id } /abuse-reports` ,
35+ AbuseReportListResponsesV4PagePagination ,
36+ { query, ...options } ,
37+ ) ;
38+ }
39+
40+ /**
41+ * Retrieve an abuse report.
42+ */
43+ get (
44+ reportParam : string ,
45+ params : AbuseReportGetParams ,
46+ options ?: Core . RequestOptions ,
47+ ) : Core . APIPromise < AbuseReportGetResponse > {
48+ const { account_id } = params ;
49+ return (
50+ this . _client . get ( `/accounts/${ account_id } /abuse-reports/${ reportParam } ` , options ) as Core . APIPromise < {
51+ result : AbuseReportGetResponse ;
52+ } >
53+ ) . _thenUnwrap ( ( obj ) => obj . result ) ;
54+ }
2355}
2456
57+ export class AbuseReportListResponsesV4PagePagination extends V4PagePagination < AbuseReportListResponse > { }
58+
2559/**
2660 * The result should be 'success' for successful response
2761 */
2862export type AbuseReportCreateResponse = string ;
2963
64+ export interface AbuseReportListResponse {
65+ reports : Array < AbuseReportListResponse . Report > ;
66+ }
67+
68+ export namespace AbuseReportListResponse {
69+ export interface Report {
70+ /**
71+ * Public facing ID of abuse report, aka abuse_rand.
72+ */
73+ id : string ;
74+
75+ /**
76+ * Creation date of report. Time in RFC 3339 format
77+ * (https://www.rfc-editor.org/rfc/rfc3339.html)
78+ */
79+ cdate : string ;
80+
81+ /**
82+ * Domain that relates to the report.
83+ */
84+ domain : string ;
85+
86+ /**
87+ * A summary of the mitigations related to this report.
88+ */
89+ mitigation_summary : Report . MitigationSummary ;
90+
91+ /**
92+ * An enum value that represents the status of an abuse record
93+ */
94+ status : 'accepted' | 'in_review' ;
95+
96+ /**
97+ * The abuse report type
98+ */
99+ type : 'PHISH' | 'GEN' | 'THREAT' | 'DMCA' | 'EMER' | 'TM' | 'REG_WHO' | 'NCSEI' | 'NETWORK' ;
100+ }
101+
102+ export namespace Report {
103+ /**
104+ * A summary of the mitigations related to this report.
105+ */
106+ export interface MitigationSummary {
107+ /**
108+ * How many of the reported URLs were confirmed as abusive.
109+ */
110+ accepted_url_count : number ;
111+
112+ /**
113+ * How many mitigations are active.
114+ */
115+ active_count : number ;
116+
117+ /**
118+ * Whether the report has been forwarded to an external hosting provider.
119+ */
120+ external_host_notified : boolean ;
121+
122+ /**
123+ * How many mitigations are under review.
124+ */
125+ in_review_count : number ;
126+
127+ /**
128+ * How many mitigations are pending their effective date.
129+ */
130+ pending_count : number ;
131+ }
132+ }
133+ }
134+
135+ export interface AbuseReportGetResponse {
136+ /**
137+ * Public facing ID of abuse report, aka abuse_rand.
138+ */
139+ id : string ;
140+
141+ /**
142+ * Creation date of report. Time in RFC 3339 format
143+ * (https://www.rfc-editor.org/rfc/rfc3339.html)
144+ */
145+ cdate : string ;
146+
147+ /**
148+ * Domain that relates to the report.
149+ */
150+ domain : string ;
151+
152+ /**
153+ * A summary of the mitigations related to this report.
154+ */
155+ mitigation_summary : AbuseReportGetResponse . MitigationSummary ;
156+
157+ /**
158+ * An enum value that represents the status of an abuse record
159+ */
160+ status : 'accepted' | 'in_review' ;
161+
162+ /**
163+ * The abuse report type
164+ */
165+ type : 'PHISH' | 'GEN' | 'THREAT' | 'DMCA' | 'EMER' | 'TM' | 'REG_WHO' | 'NCSEI' | 'NETWORK' ;
166+ }
167+
168+ export namespace AbuseReportGetResponse {
169+ /**
170+ * A summary of the mitigations related to this report.
171+ */
172+ export interface MitigationSummary {
173+ /**
174+ * How many of the reported URLs were confirmed as abusive.
175+ */
176+ accepted_url_count : number ;
177+
178+ /**
179+ * How many mitigations are active.
180+ */
181+ active_count : number ;
182+
183+ /**
184+ * Whether the report has been forwarded to an external hosting provider.
185+ */
186+ external_host_notified : boolean ;
187+
188+ /**
189+ * How many mitigations are under review.
190+ */
191+ in_review_count : number ;
192+
193+ /**
194+ * How many mitigations are pending their effective date.
195+ */
196+ pending_count : number ;
197+ }
198+ }
199+
30200export type AbuseReportCreateParams =
31201 | AbuseReportCreateParams . AbuseReportsDmcaReport
32202 | AbuseReportCreateParams . AbuseReportsTrademarkReport
@@ -881,9 +1051,66 @@ export declare namespace AbuseReportCreateParams {
8811051 }
8821052}
8831053
1054+ export interface AbuseReportListParams extends V4PagePaginationParams {
1055+ /**
1056+ * Path param: Cloudflare Account ID
1057+ */
1058+ account_id : string ;
1059+
1060+ /**
1061+ * Query param: Returns reports created after the specified date
1062+ */
1063+ created_after ?: string ;
1064+
1065+ /**
1066+ * Query param: Returns reports created before the specified date
1067+ */
1068+ created_before ?: string ;
1069+
1070+ /**
1071+ * Query param: Filter by domain name related to the abuse report
1072+ */
1073+ domain ?: string ;
1074+
1075+ /**
1076+ * Query param: Filter reports that have any mitigations in the given status.
1077+ */
1078+ mitigation_status ?: 'pending' | 'active' | 'in_review' | 'cancelled' | 'removed' ;
1079+
1080+ /**
1081+ * Query param: A property to sort by, followed by the order (id, cdate, domain,
1082+ * type, status)
1083+ */
1084+ sort ?: string ;
1085+
1086+ /**
1087+ * Query param: Filter by the status of the report.
1088+ */
1089+ status ?: 'accepted' | 'in_review' ;
1090+
1091+ /**
1092+ * Query param: Filter by the type of the report.
1093+ */
1094+ type ?: 'PHISH' | 'GEN' | 'THREAT' | 'DMCA' | 'EMER' | 'TM' | 'REG_WHO' | 'NCSEI' | 'NETWORK' ;
1095+ }
1096+
1097+ export interface AbuseReportGetParams {
1098+ /**
1099+ * Cloudflare Account ID
1100+ */
1101+ account_id : string ;
1102+ }
1103+
1104+ AbuseReports . AbuseReportListResponsesV4PagePagination = AbuseReportListResponsesV4PagePagination ;
1105+
8841106export declare namespace AbuseReports {
8851107 export {
8861108 type AbuseReportCreateResponse as AbuseReportCreateResponse ,
1109+ type AbuseReportListResponse as AbuseReportListResponse ,
1110+ type AbuseReportGetResponse as AbuseReportGetResponse ,
1111+ AbuseReportListResponsesV4PagePagination as AbuseReportListResponsesV4PagePagination ,
8871112 type AbuseReportCreateParams as AbuseReportCreateParams ,
1113+ type AbuseReportListParams as AbuseReportListParams ,
1114+ type AbuseReportGetParams as AbuseReportGetParams ,
8881115 } ;
8891116}
0 commit comments