cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/api-gateway/configurations.ts
160lines · 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 | import * as UserSchemasAPI from './user-schemas/user-schemas'; |
| 6 | |
| 7 | export class Configurations extends APIResource { |
| 8 | /** |
| 9 | * Set configuration properties |
| 10 | */ |
| 11 | update( |
| 12 | params: ConfigurationUpdateParams, |
| 13 | options?: Core.RequestOptions, |
| 14 | ): Core.APIPromise<ConfigurationUpdateResponse> { |
| 15 | const { zone_id, ...body } = params; |
| 16 | return this._client.put(`/zones/${zone_id}/api_gateway/configuration`, { body, ...options }); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Retrieve information about specific configuration properties |
| 21 | */ |
| 22 | get(params: ConfigurationGetParams, options?: Core.RequestOptions): Core.APIPromise<Configuration> { |
| 23 | const { zone_id, ...query } = params; |
| 24 | return ( |
| 25 | this._client.get(`/zones/${zone_id}/api_gateway/configuration`, { |
| 26 | query, |
| 27 | ...options, |
| 28 | }) as Core.APIPromise<{ result: Configuration }> |
| 29 | )._thenUnwrap((obj) => obj.result); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | export interface Configuration { |
| 34 | auth_id_characteristics: Array< |
| 35 | Configuration.APIShieldAuthIDCharacteristic | Configuration.APIShieldAuthIDCharacteristicJWTClaim |
| 36 | >; |
| 37 | } |
| 38 | |
| 39 | export namespace Configuration { |
| 40 | /** |
| 41 | * Auth ID Characteristic |
| 42 | */ |
| 43 | export interface APIShieldAuthIDCharacteristic { |
| 44 | /** |
| 45 | * The name of the characteristic field, i.e., the header or cookie name. |
| 46 | */ |
| 47 | name: string; |
| 48 | |
| 49 | /** |
| 50 | * The type of characteristic. |
| 51 | */ |
| 52 | type: 'header' | 'cookie'; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Auth ID Characteristic extracted from JWT Token Claims |
| 57 | */ |
| 58 | export interface APIShieldAuthIDCharacteristicJWTClaim { |
| 59 | /** |
| 60 | * Claim location expressed as `$(token_config_id):$(json_path)`, where |
| 61 | * `token_config_id` is the ID of the token configuration used in validating the |
| 62 | * JWT, and `json_path` is a RFC 9535 JSONPath |
| 63 | * (https://goessner.net/articles/JsonPath/, |
| 64 | * https://www.rfc-editor.org/rfc/rfc9535.html). The JSONPath expression may be in |
| 65 | * dot or bracket notation, may only specify literal keys or array indexes, and |
| 66 | * must return a singleton value, which will be interpreted as a string. |
| 67 | */ |
| 68 | name: string; |
| 69 | |
| 70 | /** |
| 71 | * The type of characteristic. |
| 72 | */ |
| 73 | type: 'jwt'; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | export interface ConfigurationUpdateResponse { |
| 78 | errors: UserSchemasAPI.Message; |
| 79 | |
| 80 | messages: UserSchemasAPI.Message; |
| 81 | |
| 82 | /** |
| 83 | * Whether the API call was successful |
| 84 | */ |
| 85 | success: true; |
| 86 | } |
| 87 | |
| 88 | export interface ConfigurationUpdateParams { |
| 89 | /** |
| 90 | * Path param: Identifier |
| 91 | */ |
| 92 | zone_id: string; |
| 93 | |
| 94 | /** |
| 95 | * Body param: |
| 96 | */ |
| 97 | auth_id_characteristics: Array< |
| 98 | | ConfigurationUpdateParams.APIShieldAuthIDCharacteristic |
| 99 | | ConfigurationUpdateParams.APIShieldAuthIDCharacteristicJWTClaim |
| 100 | >; |
| 101 | } |
| 102 | |
| 103 | export namespace ConfigurationUpdateParams { |
| 104 | /** |
| 105 | * Auth ID Characteristic |
| 106 | */ |
| 107 | export interface APIShieldAuthIDCharacteristic { |
| 108 | /** |
| 109 | * The name of the characteristic field, i.e., the header or cookie name. |
| 110 | */ |
| 111 | name: string; |
| 112 | |
| 113 | /** |
| 114 | * The type of characteristic. |
| 115 | */ |
| 116 | type: 'header' | 'cookie'; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Auth ID Characteristic extracted from JWT Token Claims |
| 121 | */ |
| 122 | export interface APIShieldAuthIDCharacteristicJWTClaim { |
| 123 | /** |
| 124 | * Claim location expressed as `$(token_config_id):$(json_path)`, where |
| 125 | * `token_config_id` is the ID of the token configuration used in validating the |
| 126 | * JWT, and `json_path` is a RFC 9535 JSONPath |
| 127 | * (https://goessner.net/articles/JsonPath/, |
| 128 | * https://www.rfc-editor.org/rfc/rfc9535.html). The JSONPath expression may be in |
| 129 | * dot or bracket notation, may only specify literal keys or array indexes, and |
| 130 | * must return a singleton value, which will be interpreted as a string. |
| 131 | */ |
| 132 | name: string; |
| 133 | |
| 134 | /** |
| 135 | * The type of characteristic. |
| 136 | */ |
| 137 | type: 'jwt'; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | export interface ConfigurationGetParams { |
| 142 | /** |
| 143 | * Path param: Identifier |
| 144 | */ |
| 145 | zone_id: string; |
| 146 | |
| 147 | /** |
| 148 | * Query param: Requests information about certain properties. |
| 149 | */ |
| 150 | properties?: Array<'auth_id_characteristics'>; |
| 151 | } |
| 152 | |
| 153 | export declare namespace Configurations { |
| 154 | export { |
| 155 | type Configuration as Configuration, |
| 156 | type ConfigurationUpdateResponse as ConfigurationUpdateResponse, |
| 157 | type ConfigurationUpdateParams as ConfigurationUpdateParams, |
| 158 | type ConfigurationGetParams as ConfigurationGetParams, |
| 159 | }; |
| 160 | } |
| 161 | |