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