Skip to main content

quicknode_sdk/admin/
endpoint_security.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/// A single security feature's name, status, and optional value.
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#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct SecurityOption {
17    /// Name of the security feature (e.g. `tokens`, `jwts`, `ips`).
18    pub option: String,
19    /// Whether the feature is `enabled` or `disabled`.
20    pub status: String,
21    /// Optional configuration value associated with the feature.
22    pub value: Option<String>,
23}
24
25/// Response from `get_security_options`.
26#[cfg_attr(feature = "python", gen_stub_pyclass)]
27#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
28#[cfg_attr(feature = "node", napi(object))]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct GetSecurityOptionsResponse {
31    /// Security options on the endpoint.
32    #[serde(default)]
33    pub data: Vec<SecurityOption>,
34    /// Error message when the request did not succeed.
35    pub error: Option<String>,
36}
37
38/// Per-feature toggles for `update_security_options`. Each field accepts
39/// `enabled` or `disabled`.
40#[cfg_attr(feature = "python", gen_stub_pyclass)]
41#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
42#[cfg_attr(feature = "node", napi(object))]
43#[cfg_attr(feature = "rust", derive(Builder))]
44#[derive(Debug, Clone, Default, Serialize)]
45pub struct SecurityOptionsUpdate {
46    /// Token authentication toggle.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub tokens: Option<String>,
49    /// Referrer validation toggle.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub referrers: Option<String>,
52    /// JWT validation toggle.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub jwts: Option<String>,
55    /// IP whitelist toggle.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub ips: Option<String>,
58    /// Domain masking toggle.
59    #[serde(rename = "domainMasks", skip_serializing_if = "Option::is_none")]
60    pub domain_masks: Option<String>,
61    /// HSTS (HTTP Strict Transport Security) toggle.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub hsts: Option<String>,
64    /// CORS toggle.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub cors: Option<String>,
67    /// Request (method) filter toggle.
68    #[serde(rename = "requestFilters", skip_serializing_if = "Option::is_none")]
69    pub request_filters: Option<String>,
70    /// Custom IP header toggle.
71    #[serde(rename = "ipCustomHeader", skip_serializing_if = "Option::is_none")]
72    pub ip_custom_header: Option<String>,
73}
74
75/// Parameters for `update_security_options`.
76#[cfg_attr(feature = "python", gen_stub_pyclass)]
77#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
78#[cfg_attr(feature = "node", napi(object))]
79#[cfg_attr(feature = "rust", derive(Builder))]
80#[derive(Debug, Clone, Default, Serialize)]
81pub struct UpdateSecurityOptionsRequest {
82    /// Security toggles to apply.
83    pub options: SecurityOptionsUpdate,
84}
85
86/// Response from `update_security_options`.
87#[cfg_attr(feature = "python", gen_stub_pyclass)]
88#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
89#[cfg_attr(feature = "node", napi(object))]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct UpdateSecurityOptionsResponse {
92    /// Updated security options.
93    #[serde(default)]
94    pub data: Vec<SecurityOption>,
95    /// Error message when the request did not succeed.
96    pub error: Option<String>,
97}
98
99/// Parameters for `create_referrer`.
100#[cfg_attr(feature = "python", gen_stub_pyclass)]
101#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
102#[cfg_attr(feature = "node", napi(object))]
103#[cfg_attr(feature = "rust", derive(Builder))]
104#[derive(Debug, Clone, Default, Serialize)]
105pub struct CreateReferrerRequest {
106    /// Allowed referrer URL or domain.
107    pub referrer: String,
108}
109
110/// Parameters for `create_ip`.
111#[cfg_attr(feature = "python", gen_stub_pyclass)]
112#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
113#[cfg_attr(feature = "node", napi(object))]
114#[cfg_attr(feature = "rust", derive(Builder))]
115#[derive(Debug, Clone, Default, Serialize)]
116pub struct CreateIpRequest {
117    /// IP address to whitelist.
118    pub ip: String,
119}
120
121/// Parameters for `create_domain_mask`.
122#[cfg_attr(feature = "python", gen_stub_pyclass)]
123#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
124#[cfg_attr(feature = "node", napi(object))]
125#[cfg_attr(feature = "rust", derive(Builder))]
126#[derive(Debug, Clone, Default, Serialize)]
127pub struct CreateDomainMaskRequest {
128    /// Custom domain that will mask the endpoint's Quicknode URL.
129    #[serde(skip_serializing_if = "Option::is_none")]
130    pub domain_mask: Option<String>,
131}
132
133/// Parameters for `create_jwt`.
134#[cfg_attr(feature = "python", gen_stub_pyclass)]
135#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
136#[cfg_attr(feature = "node", napi(object))]
137#[cfg_attr(feature = "rust", derive(Builder))]
138#[derive(Debug, Clone, Default, Serialize)]
139pub struct CreateJwtRequest {
140    /// Public key used to verify signed JWTs.
141    pub public_key: String,
142    /// Key identifier (`kid`) embedded in JWT headers.
143    pub kid: String,
144    /// Human-readable name for the JWT configuration.
145    pub name: String,
146}
147
148/// Parameters for `create_request_filter`.
149#[cfg_attr(feature = "python", gen_stub_pyclass)]
150#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
151#[cfg_attr(feature = "node", napi(object))]
152#[cfg_attr(feature = "rust", derive(Builder))]
153#[derive(Debug, Clone, Default, Serialize)]
154pub struct CreateRequestFilterRequest {
155    /// Whitelisted RPC methods; other methods will be blocked.
156    pub method: Vec<String>,
157}
158
159/// Response from `create_request_filter`.
160#[cfg_attr(feature = "python", gen_stub_pyclass)]
161#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
162#[cfg_attr(feature = "node", napi(object))]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164pub struct CreateRequestFilterResponse {
165    /// The created filter payload.
166    pub data: Option<CreateRequestFilterData>,
167    /// Error message when the request did not succeed.
168    pub error: Option<String>,
169}
170
171/// Data wrapper for a created request filter.
172#[cfg_attr(feature = "python", gen_stub_pyclass)]
173#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
174#[cfg_attr(feature = "node", napi(object))]
175#[derive(Debug, Clone, Serialize, Deserialize)]
176pub struct CreateRequestFilterData {
177    /// Identifier of the newly created request filter.
178    pub id: String,
179}
180
181/// Parameters for `update_request_filter`.
182#[cfg_attr(feature = "python", gen_stub_pyclass)]
183#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
184#[cfg_attr(feature = "node", napi(object))]
185#[cfg_attr(feature = "rust", derive(Builder))]
186#[derive(Debug, Clone, Default, Serialize)]
187pub struct UpdateRequestFilterRequest {
188    /// New set of whitelisted RPC methods.
189    #[serde(skip_serializing_if = "Option::is_none")]
190    pub method: Option<Vec<String>>,
191}
192
193/// Parameters for `create_or_update_ip_custom_header`.
194#[cfg_attr(feature = "python", gen_stub_pyclass)]
195#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
196#[cfg_attr(feature = "node", napi(object))]
197#[cfg_attr(feature = "rust", derive(Builder))]
198#[derive(Debug, Clone, Default, Serialize)]
199pub struct CreateOrUpdateIpCustomHeaderRequest {
200    /// Header name used to identify the client IP (e.g. `X-Forwarded-For`).
201    pub header_name: String,
202}
203
204/// Data wrapper for the IP custom header configuration.
205#[cfg_attr(feature = "python", gen_stub_pyclass)]
206#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
207#[cfg_attr(feature = "node", napi(object))]
208#[derive(Debug, Clone, Serialize, Deserialize)]
209pub struct IpCustomHeaderData {
210    /// Configured header name.
211    pub header_name: String,
212}
213
214/// Response from `create_or_update_ip_custom_header`.
215#[cfg_attr(feature = "python", gen_stub_pyclass)]
216#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
217#[cfg_attr(feature = "node", napi(object))]
218#[derive(Debug, Clone, Serialize, Deserialize)]
219pub struct CreateOrUpdateIpCustomHeaderResponse {
220    /// Stored header configuration.
221    pub data: Option<IpCustomHeaderData>,
222    /// Error message when the request did not succeed.
223    pub error: Option<String>,
224}
225
226/// Response wrapper for delete operations that return a boolean success flag.
227#[cfg_attr(feature = "python", gen_stub_pyclass)]
228#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
229#[cfg_attr(feature = "node", napi(object))]
230#[derive(Debug, Clone, Serialize, Deserialize)]
231pub struct DeleteBoolResponse {
232    /// `true` when the deletion succeeded.
233    pub data: Option<bool>,
234    /// Error message when the request did not succeed.
235    pub error: Option<String>,
236}