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/ai-security.ts

122lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../core/resource';
4import * as CustomTopicsAPI from './custom-topics';
5import {
6 BaseCustomTopics,
7 CustomTopicGetParams,
8 CustomTopicGetResponse,
9 CustomTopicUpdateParams,
10 CustomTopicUpdateResponse,
11 CustomTopics,
12} from './custom-topics';
13import { APIPromise } from '../../core/api-promise';
14import { RequestOptions } from '../../internal/request-options';
15import { path } from '../../internal/utils/path';
16
17export class BaseAISecurity extends APIResource {
18 static override readonly _key: readonly ['aiSecurity'] = Object.freeze(['aiSecurity'] as const);
19
20 /**
21 * Enable or disable AI Security for Apps for a zone.
22 *
23 * Changes can take up to a minute to propagate to the zone.
24 *
25 * @example
26 * ```ts
27 * const aiSecurity = await client.aiSecurity.update({
28 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
29 * });
30 * ```
31 */
32 update(params: AISecurityUpdateParams, options?: RequestOptions): APIPromise<AISecurityUpdateResponse> {
33 const { zone_id, ...body } = params;
34 return (
35 this._client.put(path`/zones/${zone_id}/ai-security/settings`, { body, ...options }) as APIPromise<{
36 result: AISecurityUpdateResponse;
37 }>
38 )._thenUnwrap((obj) => obj.result);
39 }
40
41 /**
42 * Get whether AI Security for Apps is enabled or disabled for a zone.
43 *
44 * @example
45 * ```ts
46 * const aiSecurity = await client.aiSecurity.get({
47 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
48 * });
49 * ```
50 */
51 get(params: AISecurityGetParams, options?: RequestOptions): APIPromise<AISecurityGetResponse> {
52 const { zone_id } = params;
53 return (
54 this._client.get(path`/zones/${zone_id}/ai-security/settings`, options) as APIPromise<{
55 result: AISecurityGetResponse;
56 }>
57 )._thenUnwrap((obj) => obj.result);
58 }
59}
60export class AISecurity extends BaseAISecurity {
61 customTopics: CustomTopicsAPI.CustomTopics = new CustomTopicsAPI.CustomTopics(this._client);
62}
63
64/**
65 * AI Security for Apps enablement status for a zone.
66 */
67export interface AISecurityUpdateResponse {
68 /**
69 * Whether AI Security for Apps is enabled on the zone.
70 */
71 enabled?: boolean;
72}
73
74/**
75 * AI Security for Apps enablement status for a zone.
76 */
77export interface AISecurityGetResponse {
78 /**
79 * Whether AI Security for Apps is enabled on the zone.
80 */
81 enabled?: boolean;
82}
83
84export interface AISecurityUpdateParams {
85 /**
86 * Path param: Defines the zone.
87 */
88 zone_id: string;
89
90 /**
91 * Body param: Whether AI Security for Apps is enabled on the zone.
92 */
93 enabled?: boolean;
94}
95
96export interface AISecurityGetParams {
97 /**
98 * Defines the zone.
99 */
100 zone_id: string;
101}
102
103AISecurity.CustomTopics = CustomTopics;
104AISecurity.BaseCustomTopics = BaseCustomTopics;
105
106export declare namespace AISecurity {
107 export {
108 type AISecurityUpdateResponse as AISecurityUpdateResponse,
109 type AISecurityGetResponse as AISecurityGetResponse,
110 type AISecurityUpdateParams as AISecurityUpdateParams,
111 type AISecurityGetParams as AISecurityGetParams,
112 };
113
114 export {
115 CustomTopics as CustomTopics,
116 BaseCustomTopics as BaseCustomTopics,
117 type CustomTopicUpdateResponse as CustomTopicUpdateResponse,
118 type CustomTopicGetResponse as CustomTopicGetResponse,
119 type CustomTopicUpdateParams as CustomTopicUpdateParams,
120 type CustomTopicGetParams as CustomTopicGetParams,
121 };
122}
123