cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/ai-gateway/urls.ts
54lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import { isRequestOptions } from '../../core'; |
| 5 | import * as Core from '../../core'; |
| 6 | |
| 7 | export class URLs extends APIResource { |
| 8 | /** |
| 9 | * Retrieves the endpoint URL for an AI Gateway. |
| 10 | * |
| 11 | * @example |
| 12 | * ```ts |
| 13 | * const url = await client.aiGateway.urls.get( |
| 14 | * 'my-gateway', |
| 15 | * 'workers-ai', |
| 16 | * { account_id: '0d37909e38d3e99c29fa2cd343ac421a' }, |
| 17 | * ); |
| 18 | * ``` |
| 19 | */ |
| 20 | get( |
| 21 | gatewayId: string, |
| 22 | provider: string, |
| 23 | params?: URLGetParams, |
| 24 | options?: Core.RequestOptions, |
| 25 | ): Core.APIPromise<URLGetResponse>; |
| 26 | get(gatewayId: string, provider: string, options?: Core.RequestOptions): Core.APIPromise<URLGetResponse>; |
| 27 | get( |
| 28 | gatewayId: string, |
| 29 | provider: string, |
| 30 | params: URLGetParams | Core.RequestOptions = {}, |
| 31 | options?: Core.RequestOptions, |
| 32 | ): Core.APIPromise<URLGetResponse> { |
| 33 | if (isRequestOptions(params)) { |
| 34 | return this.get(gatewayId, provider, {}, params); |
| 35 | } |
| 36 | const { account_id = this._client.accountId } = params; |
| 37 | return ( |
| 38 | this._client.get( |
| 39 | `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/url/${provider}`, |
| 40 | options, |
| 41 | ) as Core.APIPromise<{ result: URLGetResponse }> |
| 42 | )._thenUnwrap((obj) => obj.result); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export type URLGetResponse = string; |
| 47 | |
| 48 | export interface URLGetParams { |
| 49 | account_id?: string; |
| 50 | } |
| 51 | |
| 52 | export declare namespace URLs { |
| 53 | export { type URLGetResponse as URLGetResponse, type URLGetParams as URLGetParams }; |
| 54 | } |
| 55 | |