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