cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v7

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/ai-security/custom-topics.ts

148lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../core/resource';
4import { APIPromise } from '../../core/api-promise';
5import { RequestOptions } from '../../internal/request-options';
6import { path } from '../../internal/utils/path';
7
8export class BaseCustomTopics extends APIResource {
9 static override readonly _key: readonly ['aiSecurity', 'customTopics'] = Object.freeze([
10 'aiSecurity',
11 'customTopics',
12 ] as const);
13
14 /**
15 * Set the AI Security for Apps custom topic categories for a zone.
16 *
17 * A maximum of 20 custom topics can be configured per zone. Each topic label must
18 * be 2–20 characters using only lowercase letters (a–z), digits (0–9), and
19 * hyphens. Each topic description must be 2–50 printable ASCII characters.
20 *
21 * Changes can take up to a minute to propagate to the zone.
22 *
23 * @example
24 * ```ts
25 * const customTopic =
26 * await client.aiSecurity.customTopics.update({
27 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
28 * });
29 * ```
30 */
31 update(params: CustomTopicUpdateParams, options?: RequestOptions): APIPromise<CustomTopicUpdateResponse> {
32 const { zone_id, ...body } = params;
33 return (
34 this._client.put(path`/zones/${zone_id}/ai-security/custom-topics`, {
35 body,
36 ...options,
37 }) as APIPromise<{ result: CustomTopicUpdateResponse }>
38 )._thenUnwrap((obj) => obj.result);
39 }
40
41 /**
42 * Get the AI Security for Apps custom topic categories for a zone.
43 *
44 * @example
45 * ```ts
46 * const customTopic =
47 * await client.aiSecurity.customTopics.get({
48 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
49 * });
50 * ```
51 */
52 get(params: CustomTopicGetParams, options?: RequestOptions): APIPromise<CustomTopicGetResponse> {
53 const { zone_id } = params;
54 return (
55 this._client.get(path`/zones/${zone_id}/ai-security/custom-topics`, options) as APIPromise<{
56 result: CustomTopicGetResponse;
57 }>
58 )._thenUnwrap((obj) => obj.result);
59 }
60}
61export class CustomTopics extends BaseCustomTopics {}
62
63export interface CustomTopicUpdateResponse {
64 /**
65 * Custom topic categories for AI Security for Apps content detection.
66 */
67 topics?: Array<CustomTopicUpdateResponse.Topic>;
68}
69
70export namespace CustomTopicUpdateResponse {
71 export interface Topic {
72 /**
73 * Unique label identifier. Must contain only lowercase letters (a–z), digits
74 * (0–9), and hyphens.
75 */
76 label: string;
77
78 /**
79 * Description of the topic category. Must contain only printable ASCII characters.
80 */
81 topic: string;
82 }
83}
84
85export interface CustomTopicGetResponse {
86 /**
87 * Custom topic categories for AI Security for Apps content detection.
88 */
89 topics?: Array<CustomTopicGetResponse.Topic>;
90}
91
92export namespace CustomTopicGetResponse {
93 export interface Topic {
94 /**
95 * Unique label identifier. Must contain only lowercase letters (a–z), digits
96 * (0–9), and hyphens.
97 */
98 label: string;
99
100 /**
101 * Description of the topic category. Must contain only printable ASCII characters.
102 */
103 topic: string;
104 }
105}
106
107export interface CustomTopicUpdateParams {
108 /**
109 * Path param: Defines the zone.
110 */
111 zone_id: string;
112
113 /**
114 * Body param: Custom topic categories for AI Security for Apps content detection.
115 */
116 topics?: Array<CustomTopicUpdateParams.Topic>;
117}
118
119export namespace CustomTopicUpdateParams {
120 export interface Topic {
121 /**
122 * Unique label identifier. Must contain only lowercase letters (a–z), digits
123 * (0–9), and hyphens.
124 */
125 label: string;
126
127 /**
128 * Description of the topic category. Must contain only printable ASCII characters.
129 */
130 topic: string;
131 }
132}
133
134export interface CustomTopicGetParams {
135 /**
136 * Defines the zone.
137 */
138 zone_id: string;
139}
140
141export declare namespace CustomTopics {
142 export {
143 type CustomTopicUpdateResponse as CustomTopicUpdateResponse,
144 type CustomTopicGetResponse as CustomTopicGetResponse,
145 type CustomTopicUpdateParams as CustomTopicUpdateParams,
146 type CustomTopicGetParams as CustomTopicGetParams,
147 };
148}
149