UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

124 lines • 4.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Logs = exports.BaseLogs = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseLogs = /* @__PURE__ */ (() => { class BaseLogs extends resource_1.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((0, path_1.path) `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/logs`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/logs/${id}/response`, options); } } BaseLogs._key = Object.freeze([ 'aiGateway', 'logs', ]); return BaseLogs; })(); exports.BaseLogs = BaseLogs; class Logs extends BaseLogs { } exports.Logs = Logs; //# sourceMappingURL=logs.js.map