|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import * as Core from 'cloudflare/core'; |
| 4 | +import { APIResource } from 'cloudflare/resource'; |
| 5 | +import { isRequestOptions } from 'cloudflare/core'; |
| 6 | +import * as GatewaysAPI from 'cloudflare/resources/workers/ai/gateways/gateways'; |
| 7 | +import * as LogsAPI from 'cloudflare/resources/workers/ai/gateways/logs'; |
| 8 | +import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; |
| 9 | + |
| 10 | +export class Gateways extends APIResource { |
| 11 | + logs: LogsAPI.Logs = new LogsAPI.Logs(this._client); |
| 12 | + |
| 13 | + /** |
| 14 | + * Create a new Gateway |
| 15 | + */ |
| 16 | + create( |
| 17 | + accountTag: string, |
| 18 | + body: GatewayCreateParams, |
| 19 | + options?: Core.RequestOptions, |
| 20 | + ): Core.APIPromise<GatewayCreateResponse> { |
| 21 | + return ( |
| 22 | + this._client.post(`/accounts/${accountTag}/ai-gateway/gateways`, { |
| 23 | + body, |
| 24 | + ...options, |
| 25 | + }) as Core.APIPromise<{ result: GatewayCreateResponse }> |
| 26 | + )._thenUnwrap((obj) => obj.result); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Update a Gateway |
| 31 | + */ |
| 32 | + update( |
| 33 | + accountTag: string, |
| 34 | + id: string, |
| 35 | + body: GatewayUpdateParams, |
| 36 | + options?: Core.RequestOptions, |
| 37 | + ): Core.APIPromise<GatewayUpdateResponse> { |
| 38 | + return ( |
| 39 | + this._client.put(`/accounts/${accountTag}/ai-gateway/gateways/${id}`, { |
| 40 | + body, |
| 41 | + ...options, |
| 42 | + }) as Core.APIPromise<{ result: GatewayUpdateResponse }> |
| 43 | + )._thenUnwrap((obj) => obj.result); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * List Gateway's |
| 48 | + */ |
| 49 | + list( |
| 50 | + accountTag: string, |
| 51 | + query?: GatewayListParams, |
| 52 | + options?: Core.RequestOptions, |
| 53 | + ): Core.PagePromise<GatewayListResponsesV4PagePaginationArray, GatewayListResponse>; |
| 54 | + list( |
| 55 | + accountTag: string, |
| 56 | + options?: Core.RequestOptions, |
| 57 | + ): Core.PagePromise<GatewayListResponsesV4PagePaginationArray, GatewayListResponse>; |
| 58 | + list( |
| 59 | + accountTag: string, |
| 60 | + query: GatewayListParams | Core.RequestOptions = {}, |
| 61 | + options?: Core.RequestOptions, |
| 62 | + ): Core.PagePromise<GatewayListResponsesV4PagePaginationArray, GatewayListResponse> { |
| 63 | + if (isRequestOptions(query)) { |
| 64 | + return this.list(accountTag, {}, query); |
| 65 | + } |
| 66 | + return this._client.getAPIList( |
| 67 | + `/accounts/${accountTag}/ai-gateway/gateways`, |
| 68 | + GatewayListResponsesV4PagePaginationArray, |
| 69 | + { query, ...options }, |
| 70 | + ); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Delete a Gateway |
| 75 | + */ |
| 76 | + delete( |
| 77 | + accountTag: string, |
| 78 | + id: string, |
| 79 | + options?: Core.RequestOptions, |
| 80 | + ): Core.APIPromise<GatewayDeleteResponse> { |
| 81 | + return ( |
| 82 | + this._client.delete(`/accounts/${accountTag}/ai-gateway/gateways/${id}`, options) as Core.APIPromise<{ |
| 83 | + result: GatewayDeleteResponse; |
| 84 | + }> |
| 85 | + )._thenUnwrap((obj) => obj.result); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Fetch a Gateway |
| 90 | + */ |
| 91 | + get(accountTag: string, id: string, options?: Core.RequestOptions): Core.APIPromise<GatewayGetResponse> { |
| 92 | + return ( |
| 93 | + this._client.get(`/accounts/${accountTag}/ai-gateway/gateways/${id}`, options) as Core.APIPromise<{ |
| 94 | + result: GatewayGetResponse; |
| 95 | + }> |
| 96 | + )._thenUnwrap((obj) => obj.result); |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +export class GatewayListResponsesV4PagePaginationArray extends V4PagePaginationArray<GatewayListResponse> {} |
| 101 | + |
| 102 | +export interface GatewayCreateResponse { |
| 103 | + task: GatewayCreateResponse.Task; |
| 104 | +} |
| 105 | + |
| 106 | +export namespace GatewayCreateResponse { |
| 107 | + export interface Task { |
| 108 | + id: string; |
| 109 | + |
| 110 | + cache_invalidate_on_update: boolean; |
| 111 | + |
| 112 | + cache_ttl: number; |
| 113 | + |
| 114 | + collect_logs: boolean; |
| 115 | + |
| 116 | + created_at: string; |
| 117 | + |
| 118 | + modified_at: string; |
| 119 | + |
| 120 | + name: string; |
| 121 | + |
| 122 | + slug: string; |
| 123 | + |
| 124 | + rate_limiting_interval?: number; |
| 125 | + |
| 126 | + rate_limiting_limit?: number; |
| 127 | + |
| 128 | + rate_limiting_technique?: string; |
| 129 | + } |
| 130 | +} |
| 131 | + |
| 132 | +export interface GatewayUpdateResponse { |
| 133 | + id: string; |
| 134 | + |
| 135 | + cache_invalidate_on_update: boolean; |
| 136 | + |
| 137 | + cache_ttl: number; |
| 138 | + |
| 139 | + collect_logs: boolean; |
| 140 | + |
| 141 | + created_at: string; |
| 142 | + |
| 143 | + modified_at: string; |
| 144 | + |
| 145 | + name: string; |
| 146 | + |
| 147 | + slug: string; |
| 148 | + |
| 149 | + rate_limiting_interval?: number; |
| 150 | + |
| 151 | + rate_limiting_limit?: number; |
| 152 | + |
| 153 | + rate_limiting_technique?: string; |
| 154 | +} |
| 155 | + |
| 156 | +export interface GatewayListResponse { |
| 157 | + id: string; |
| 158 | + |
| 159 | + cache_invalidate_on_update: boolean; |
| 160 | + |
| 161 | + cache_ttl: number; |
| 162 | + |
| 163 | + collect_logs: boolean; |
| 164 | + |
| 165 | + created_at: string; |
| 166 | + |
| 167 | + modified_at: string; |
| 168 | + |
| 169 | + name: string; |
| 170 | + |
| 171 | + slug: string; |
| 172 | + |
| 173 | + rate_limiting_interval?: number; |
| 174 | + |
| 175 | + rate_limiting_limit?: number; |
| 176 | + |
| 177 | + rate_limiting_technique?: string; |
| 178 | +} |
| 179 | + |
| 180 | +export interface GatewayDeleteResponse { |
| 181 | + id: string; |
| 182 | + |
| 183 | + cache_invalidate_on_update: boolean; |
| 184 | + |
| 185 | + cache_ttl: number; |
| 186 | + |
| 187 | + collect_logs: boolean; |
| 188 | + |
| 189 | + created_at: string; |
| 190 | + |
| 191 | + modified_at: string; |
| 192 | + |
| 193 | + name: string; |
| 194 | + |
| 195 | + slug: string; |
| 196 | + |
| 197 | + rate_limiting_interval?: number; |
| 198 | + |
| 199 | + rate_limiting_limit?: number; |
| 200 | + |
| 201 | + rate_limiting_technique?: string; |
| 202 | +} |
| 203 | + |
| 204 | +export interface GatewayGetResponse { |
| 205 | + id: string; |
| 206 | + |
| 207 | + cache_invalidate_on_update: boolean; |
| 208 | + |
| 209 | + cache_ttl: number; |
| 210 | + |
| 211 | + collect_logs: boolean; |
| 212 | + |
| 213 | + created_at: string; |
| 214 | + |
| 215 | + modified_at: string; |
| 216 | + |
| 217 | + name: string; |
| 218 | + |
| 219 | + slug: string; |
| 220 | + |
| 221 | + rate_limiting_interval?: number; |
| 222 | + |
| 223 | + rate_limiting_limit?: number; |
| 224 | + |
| 225 | + rate_limiting_technique?: string; |
| 226 | +} |
| 227 | + |
| 228 | +export interface GatewayCreateParams { |
| 229 | + cache_invalidate_on_update: boolean; |
| 230 | + |
| 231 | + cache_ttl: number; |
| 232 | + |
| 233 | + collect_logs: boolean; |
| 234 | + |
| 235 | + name: string; |
| 236 | + |
| 237 | + slug: string; |
| 238 | + |
| 239 | + rate_limiting_interval?: number; |
| 240 | + |
| 241 | + rate_limiting_limit?: number; |
| 242 | + |
| 243 | + rate_limiting_technique?: string; |
| 244 | +} |
| 245 | + |
| 246 | +export interface GatewayUpdateParams { |
| 247 | + cache_invalidate_on_update: boolean; |
| 248 | + |
| 249 | + cache_ttl: number; |
| 250 | + |
| 251 | + collect_logs: boolean; |
| 252 | + |
| 253 | + name: string; |
| 254 | + |
| 255 | + slug: string; |
| 256 | + |
| 257 | + rate_limiting_interval?: number; |
| 258 | + |
| 259 | + rate_limiting_limit?: number; |
| 260 | + |
| 261 | + rate_limiting_technique?: string; |
| 262 | +} |
| 263 | + |
| 264 | +export interface GatewayListParams extends V4PagePaginationArrayParams { |
| 265 | + id?: string; |
| 266 | + |
| 267 | + /** |
| 268 | + * Order By Column Name |
| 269 | + */ |
| 270 | + order_by?: string; |
| 271 | +} |
| 272 | + |
| 273 | +export namespace Gateways { |
| 274 | + export import GatewayCreateResponse = GatewaysAPI.GatewayCreateResponse; |
| 275 | + export import GatewayUpdateResponse = GatewaysAPI.GatewayUpdateResponse; |
| 276 | + export import GatewayListResponse = GatewaysAPI.GatewayListResponse; |
| 277 | + export import GatewayDeleteResponse = GatewaysAPI.GatewayDeleteResponse; |
| 278 | + export import GatewayGetResponse = GatewaysAPI.GatewayGetResponse; |
| 279 | + export import GatewayListResponsesV4PagePaginationArray = GatewaysAPI.GatewayListResponsesV4PagePaginationArray; |
| 280 | + export import GatewayCreateParams = GatewaysAPI.GatewayCreateParams; |
| 281 | + export import GatewayUpdateParams = GatewaysAPI.GatewayUpdateParams; |
| 282 | + export import GatewayListParams = GatewaysAPI.GatewayListParams; |
| 283 | + export import Logs = LogsAPI.Logs; |
| 284 | + export import LogGetResponse = LogsAPI.LogGetResponse; |
| 285 | + export import LogGetParams = LogsAPI.LogGetParams; |
| 286 | +} |
0 commit comments