cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/api-gateway/configurations.ts

178lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import * as Core from '../../core';
5
6export class Configurations extends APIResource {
7 /**
8 * Updates API Shield configuration settings for a zone. Can modify validation
9 * strictness, enforcement mode, and other global settings.
10 *
11 * @example
12 * ```ts
13 * const configuration =
14 * await client.apiGateway.configurations.update({
15 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
16 * auth_id_characteristics: [
17 * { name: 'authorization', type: 'header' },
18 * ],
19 * });
20 * ```
21 */
22 update(params: ConfigurationUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Configuration> {
23 const { zone_id, normalize, ...body } = params;
24 return (
25 this._client.put(`/zones/${zone_id}/api_gateway/configuration`, {
26 query: { normalize },
27 body,
28 ...options,
29 }) as Core.APIPromise<{ result: Configuration }>
30 )._thenUnwrap((obj) => obj.result);
31 }
32
33 /**
34 * Gets the current API Shield configuration settings for a zone, including
35 * validation behavior and enforcement mode.
36 *
37 * @example
38 * ```ts
39 * const configuration =
40 * await client.apiGateway.configurations.get({
41 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
42 * });
43 * ```
44 */
45 get(params: ConfigurationGetParams, options?: Core.RequestOptions): Core.APIPromise<Configuration> {
46 const { zone_id, ...query } = params;
47 return (
48 this._client.get(`/zones/${zone_id}/api_gateway/configuration`, {
49 query,
50 ...options,
51 }) as Core.APIPromise<{ result: Configuration }>
52 )._thenUnwrap((obj) => obj.result);
53 }
54}
55
56export interface Configuration {
57 auth_id_characteristics: Array<
58 Configuration.APIShieldAuthIDCharacteristic | Configuration.APIShieldAuthIDCharacteristicJWTClaim
59 >;
60}
61
62export namespace Configuration {
63 /**
64 * Auth ID Characteristic
65 */
66 export interface APIShieldAuthIDCharacteristic {
67 /**
68 * The name of the characteristic field, i.e., the header or cookie name.
69 */
70 name: string;
71
72 /**
73 * The type of characteristic.
74 */
75 type: 'header' | 'cookie';
76 }
77
78 /**
79 * Auth ID Characteristic extracted from JWT Token Claims
80 */
81 export interface APIShieldAuthIDCharacteristicJWTClaim {
82 /**
83 * Claim location expressed as `$(token_config_id):$(json_path)`, where
84 * `token_config_id` is the ID of the token configuration used in validating the
85 * JWT, and `json_path` is a RFC 9535 JSONPath
86 * (https://goessner.net/articles/JsonPath/,
87 * https://www.rfc-editor.org/rfc/rfc9535.html). The JSONPath expression may be in
88 * dot or bracket notation, may only specify literal keys or array indexes, and
89 * must return a singleton value, which will be interpreted as a string.
90 */
91 name: string;
92
93 /**
94 * The type of characteristic.
95 */
96 type: 'jwt';
97 }
98}
99
100export interface ConfigurationUpdateParams {
101 /**
102 * Path param: Identifier.
103 */
104 zone_id: string;
105
106 /**
107 * Body param
108 */
109 auth_id_characteristics: Array<
110 | ConfigurationUpdateParams.APIShieldAuthIDCharacteristic
111 | ConfigurationUpdateParams.APIShieldAuthIDCharacteristicJWTClaim
112 >;
113
114 /**
115 * Query param: Ensures that the configuration is written or retrieved in
116 * normalized fashion
117 */
118 normalize?: boolean;
119}
120
121export namespace ConfigurationUpdateParams {
122 /**
123 * Auth ID Characteristic
124 */
125 export interface APIShieldAuthIDCharacteristic {
126 /**
127 * The name of the characteristic field, i.e., the header or cookie name.
128 */
129 name: string;
130
131 /**
132 * The type of characteristic.
133 */
134 type: 'header' | 'cookie';
135 }
136
137 /**
138 * Auth ID Characteristic extracted from JWT Token Claims
139 */
140 export interface APIShieldAuthIDCharacteristicJWTClaim {
141 /**
142 * Claim location expressed as `$(token_config_id):$(json_path)`, where
143 * `token_config_id` is the ID of the token configuration used in validating the
144 * JWT, and `json_path` is a RFC 9535 JSONPath
145 * (https://goessner.net/articles/JsonPath/,
146 * https://www.rfc-editor.org/rfc/rfc9535.html). The JSONPath expression may be in
147 * dot or bracket notation, may only specify literal keys or array indexes, and
148 * must return a singleton value, which will be interpreted as a string.
149 */
150 name: string;
151
152 /**
153 * The type of characteristic.
154 */
155 type: 'jwt';
156 }
157}
158
159export interface ConfigurationGetParams {
160 /**
161 * Path param: Identifier.
162 */
163 zone_id: string;
164
165 /**
166 * Query param: Ensures that the configuration is written or retrieved in
167 * normalized fashion
168 */
169 normalize?: boolean;
170}
171
172export declare namespace Configurations {
173 export {
174 type Configuration as Configuration,
175 type ConfigurationUpdateParams as ConfigurationUpdateParams,
176 type ConfigurationGetParams as ConfigurationGetParams,
177 };
178}
179