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    #[serde(skip_serializing_if = "Option::is_none")]
108    pub referrer: Option<String>,
109}
110
111/// Parameters for `create_ip`.
112#[cfg_attr(feature = "python", gen_stub_pyclass)]
113#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
114#[cfg_attr(feature = "node", napi(object))]
115#[cfg_attr(feature = "rust", derive(Builder))]
116#[derive(Debug, Clone, Default, Serialize)]
117pub struct CreateIpRequest {
118    /// IP address to whitelist.
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub ip: Option<String>,
121}
122
123/// Parameters for `create_domain_mask`.
124#[cfg_attr(feature = "python", gen_stub_pyclass)]
125#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
126#[cfg_attr(feature = "node", napi(object))]
127#[cfg_attr(feature = "rust", derive(Builder))]
128#[derive(Debug, Clone, Default, Serialize)]
129pub struct CreateDomainMaskRequest {
130    /// Custom domain that will mask the endpoint's Quicknode URL.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub domain_mask: Option<String>,
133}
134
135/// Parameters for `create_jwt`.
136#[cfg_attr(feature = "python", gen_stub_pyclass)]
137#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
138#[cfg_attr(feature = "node", napi(object))]
139#[cfg_attr(feature = "rust", derive(Builder))]
140#[derive(Debug, Clone, Default, Serialize)]
141pub struct CreateJwtRequest {
142    /// Public key used to verify signed JWTs.
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub public_key: Option<String>,
145    /// Key identifier (`kid`) embedded in JWT headers.
146    #[serde(skip_serializing_if = "Option::is_none")]
147    pub kid: Option<String>,
148    /// Human-readable name for the JWT configuration.
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub name: Option<String>,
151}
152
153/// Parameters for `create_request_filter`.
154#[cfg_attr(feature = "python", gen_stub_pyclass)]
155#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
156#[cfg_attr(feature = "node", napi(object))]
157#[cfg_attr(feature = "rust", derive(Builder))]
158#[derive(Debug, Clone, Default, Serialize)]
159pub struct CreateRequestFilterRequest {
160    /// Whitelisted RPC methods; other methods will be blocked.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub method: Option<Vec<String>>,
163}
164
165/// Response from `create_request_filter`.
166#[cfg_attr(feature = "python", gen_stub_pyclass)]
167#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
168#[cfg_attr(feature = "node", napi(object))]
169#[derive(Debug, Clone, Serialize, Deserialize)]
170pub struct CreateRequestFilterResponse {
171    /// The created filter payload.
172    pub data: Option<CreateRequestFilterData>,
173    /// Error message when the request did not succeed.
174    pub error: Option<String>,
175}
176
177/// Data wrapper for a created request filter.
178#[cfg_attr(feature = "python", gen_stub_pyclass)]
179#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
180#[cfg_attr(feature = "node", napi(object))]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182pub struct CreateRequestFilterData {
183    /// Identifier of the newly created request filter.
184    pub id: String,
185}
186
187/// Parameters for `update_request_filter`.
188#[cfg_attr(feature = "python", gen_stub_pyclass)]
189#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
190#[cfg_attr(feature = "node", napi(object))]
191#[cfg_attr(feature = "rust", derive(Builder))]
192#[derive(Debug, Clone, Default, Serialize)]
193pub struct UpdateRequestFilterRequest {
194    /// New set of whitelisted RPC methods.
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub method: Option<Vec<String>>,
197}
198
199/// Parameters for `create_or_update_ip_custom_header`.
200#[cfg_attr(feature = "python", gen_stub_pyclass)]
201#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
202#[cfg_attr(feature = "node", napi(object))]
203#[cfg_attr(feature = "rust", derive(Builder))]
204#[derive(Debug, Clone, Default, Serialize)]
205pub struct CreateOrUpdateIpCustomHeaderRequest {
206    /// Header name used to identify the client IP (e.g. `X-Forwarded-For`).
207    pub header_name: String,
208}
209
210/// Data wrapper for the IP custom header configuration.
211#[cfg_attr(feature = "python", gen_stub_pyclass)]
212#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
213#[cfg_attr(feature = "node", napi(object))]
214#[derive(Debug, Clone, Serialize, Deserialize)]
215pub struct IpCustomHeaderData {
216    /// Configured header name.
217    pub header_name: String,
218}
219
220/// Response from `create_or_update_ip_custom_header`.
221#[cfg_attr(feature = "python", gen_stub_pyclass)]
222#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
223#[cfg_attr(feature = "node", napi(object))]
224#[derive(Debug, Clone, Serialize, Deserialize)]
225pub struct CreateOrUpdateIpCustomHeaderResponse {
226    /// Stored header configuration.
227    pub data: Option<IpCustomHeaderData>,
228    /// Error message when the request did not succeed.
229    pub error: Option<String>,
230}
231
232/// Response wrapper for delete operations that return a boolean success flag.
233#[cfg_attr(feature = "python", gen_stub_pyclass)]
234#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
235#[cfg_attr(feature = "node", napi(object))]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237pub struct DeleteBoolResponse {
238    /// `true` when the deletion succeeded.
239    pub data: Option<bool>,
240    /// Error message when the request did not succeed.
241    pub error: Option<String>,
242}