Skip to main content

quicknode_sdk/admin/
logs.rs

1#[cfg(feature = "rust")]
2use bon::Builder;
3#[cfg(feature = "node")]
4use napi_derive::napi;
5#[cfg(feature = "python")]
6use pyo3::pyclass;
7#[cfg(feature = "python")]
8use pyo3_stub_gen::derive::gen_stub_pyclass;
9use serde::{Deserialize, Serialize};
10
11/// Parameters for `get_endpoint_logs`.
12#[cfg_attr(feature = "python", gen_stub_pyclass)]
13#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
14#[cfg_attr(feature = "node", napi(object))]
15#[cfg_attr(feature = "rust", derive(Builder))]
16#[derive(Debug, Clone, Default, Serialize)]
17pub struct GetEndpointLogsRequest {
18    /// Start of the query window (timestamp).
19    pub from: String,
20    /// End of the query window (timestamp).
21    pub to: String,
22    /// When true, include full request/response payloads in each entry.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub include_details: Option<bool>,
25    /// Maximum number of log entries returned.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub limit: Option<i32>,
28    /// Cursor returned by a previous page; pass to fetch the next page.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub next_at: Option<String>,
31}
32
33/// Raw request/response payloads attached to a log entry.
34#[cfg_attr(feature = "python", gen_stub_pyclass)]
35#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
36#[cfg_attr(feature = "node", napi(object))]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct LogDetails {
39    /// JSON-encoded request body (truncated at 2KB).
40    pub request: Option<String>,
41    /// JSON-encoded response body (truncated at 2KB).
42    pub response: Option<String>,
43}
44
45/// A single endpoint log entry.
46#[cfg_attr(feature = "python", gen_stub_pyclass)]
47#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
48#[cfg_attr(feature = "node", napi(object))]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct EndpointLog {
51    /// Time the request was received.
52    pub timestamp: String,
53    /// RPC method called (e.g. `eth_blockNumber`).
54    pub method: Option<String>,
55    /// Network the request was routed to.
56    pub network: Option<String>,
57    /// HTTP verb (e.g. `POST`).
58    pub http_method: Option<String>,
59    /// Response HTTP status code.
60    pub status: Option<i32>,
61    /// JSON-RPC error code, when present.
62    pub error_code: Option<i64>,
63    /// Request URL.
64    pub url: Option<String>,
65    /// Request UUID used to fetch full log details.
66    pub request_id: Option<String>,
67    /// Full payloads, included when requested.
68    pub details: Option<LogDetails>,
69}
70
71/// Response from `get_endpoint_logs`.
72#[cfg_attr(feature = "python", gen_stub_pyclass)]
73#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
74#[cfg_attr(feature = "node", napi(object))]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct GetEndpointLogsResponse {
77    /// Log entries on the current page.
78    #[serde(default)]
79    pub data: Vec<EndpointLog>,
80    /// Cursor for the next page; `None` when there are no more entries.
81    pub next_at: Option<String>,
82}
83
84/// Response from `get_log_details`.
85#[cfg_attr(feature = "python", gen_stub_pyclass)]
86#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
87#[cfg_attr(feature = "node", napi(object))]
88#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct GetLogDetailsResponse {
90    /// Raw request and response payloads for the log entry.
91    pub data: Option<LogDetails>,
92}