UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

119 lines • 4.44 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseLogs = /* @__PURE__ */ (() => { class BaseLogs extends APIResource { /** * Lists request/response log entries for the AI gateway with filtering and * pagination. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const logListResponse of client.aiGateway.logs.list( * 'my-gateway', * { account_id: '0d37909e38d3e99c29fa2cd343ac421a' }, * )) { * // ... * } * ``` */ list(gatewayID, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/logs`, (V4PagePaginationArray), { query, ...options }); } /** * Deletes gateway log entries matching the specified criteria. * * @example * ```ts * const log = await client.aiGateway.logs.delete( * 'my-gateway', * { account_id: '0d37909e38d3e99c29fa2cd343ac421a' }, * ); * ``` */ delete(gatewayID, params, options) { const { account_id, filters, limit, order_by, order_by_direction } = params; return this._client.delete(path `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/logs`, { query: { filters, limit, order_by, order_by_direction }, ...options, }); } /** * Updates metadata for an AI Gateway log entry. * * @example * ```ts * const response = await client.aiGateway.logs.edit('id', { * account_id: '0d37909e38d3e99c29fa2cd343ac421a', * gateway_id: 'my-gateway', * }); * ``` */ edit(id, params, options) { const { account_id, gateway_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/logs/${id}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieves detailed information for a specific AI Gateway log entry. * * @example * ```ts * const log = await client.aiGateway.logs.get('id', { * account_id: '0d37909e38d3e99c29fa2cd343ac421a', * gateway_id: 'my-gateway', * }); * ``` */ get(id, params, options) { const { account_id, gateway_id } = params; return this._client.get(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/logs/${id}`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves the original request payload for an AI Gateway log entry. * * @example * ```ts * const response = await client.aiGateway.logs.request('id', { * account_id: '0d37909e38d3e99c29fa2cd343ac421a', * gateway_id: 'my-gateway', * }); * ``` */ request(id, params, options) { const { account_id, gateway_id } = params; return this._client.get(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/logs/${id}/request`, options); } /** * Retrieves the response payload for an AI Gateway log entry. * * @example * ```ts * const response = await client.aiGateway.logs.response( * 'id', * { * account_id: '0d37909e38d3e99c29fa2cd343ac421a', * gateway_id: 'my-gateway', * }, * ); * ``` */ response(id, params, options) { const { account_id, gateway_id } = params; return this._client.get(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/logs/${id}/response`, options); } } BaseLogs._key = Object.freeze([ 'aiGateway', 'logs', ]); return BaseLogs; })(); export class Logs extends BaseLogs { } //# sourceMappingURL=logs.mjs.map