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