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    pub kid: String,
147    /// Human-readable name for the JWT configuration.
148    #[serde(skip_serializing_if = "Option::is_none")]
149    pub name: Option<String>,
150}
151
152/// Parameters for `create_request_filter`.
153#[cfg_attr(feature = "python", gen_stub_pyclass)]
154#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
155#[cfg_attr(feature = "node", napi(object))]
156#[cfg_attr(feature = "rust", derive(Builder))]
157#[derive(Debug, Clone, Default, Serialize)]
158pub struct CreateRequestFilterRequest {
159    /// Whitelisted RPC methods; other methods will be blocked.
160    #[serde(skip_serializing_if = "Option::is_none")]
161    pub method: Option<Vec<String>>,
162}
163
164/// Response from `create_request_filter`.
165#[cfg_attr(feature = "python", gen_stub_pyclass)]
166#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
167#[cfg_attr(feature = "node", napi(object))]
168#[derive(Debug, Clone, Serialize, Deserialize)]
169pub struct CreateRequestFilterResponse {
170    /// The created filter payload.
171    pub data: Option<CreateRequestFilterData>,
172    /// Error message when the request did not succeed.
173    pub error: Option<String>,
174}
175
176/// Data wrapper for a created request filter.
177#[cfg_attr(feature = "python", gen_stub_pyclass)]
178#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
179#[cfg_attr(feature = "node", napi(object))]
180#[derive(Debug, Clone, Serialize, Deserialize)]
181pub struct CreateRequestFilterData {
182    /// Identifier of the newly created request filter.
183    pub id: String,
184}
185
186/// Parameters for `update_request_filter`.
187#[cfg_attr(feature = "python", gen_stub_pyclass)]
188#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
189#[cfg_attr(feature = "node", napi(object))]
190#[cfg_attr(feature = "rust", derive(Builder))]
191#[derive(Debug, Clone, Default, Serialize)]
192pub struct UpdateRequestFilterRequest {
193    /// New set of whitelisted RPC methods.
194    #[serde(skip_serializing_if = "Option::is_none")]
195    pub method: Option<Vec<String>>,
196}
197
198/// Parameters for `create_or_update_ip_custom_header`.
199#[cfg_attr(feature = "python", gen_stub_pyclass)]
200#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
201#[cfg_attr(feature = "node", napi(object))]
202#[cfg_attr(feature = "rust", derive(Builder))]
203#[derive(Debug, Clone, Default, Serialize)]
204pub struct CreateOrUpdateIpCustomHeaderRequest {
205    /// Header name used to identify the client IP (e.g. `X-Forwarded-For`).
206    pub header_name: String,
207}
208
209/// Data wrapper for the IP custom header configuration.
210#[cfg_attr(feature = "python", gen_stub_pyclass)]
211#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
212#[cfg_attr(feature = "node", napi(object))]
213#[derive(Debug, Clone, Serialize, Deserialize)]
214pub struct IpCustomHeaderData {
215    /// Configured header name.
216    pub header_name: String,
217}
218
219/// Response from `create_or_update_ip_custom_header`.
220#[cfg_attr(feature = "python", gen_stub_pyclass)]
221#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
222#[cfg_attr(feature = "node", napi(object))]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224pub struct CreateOrUpdateIpCustomHeaderResponse {
225    /// Stored header configuration.
226    pub data: Option<IpCustomHeaderData>,
227    /// Error message when the request did not succeed.
228    pub error: Option<String>,
229}
230
231/// Response wrapper for delete operations that return a boolean success flag.
232#[cfg_attr(feature = "python", gen_stub_pyclass)]
233#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
234#[cfg_attr(feature = "node", napi(object))]
235#[derive(Debug, Clone, Serialize, Deserialize)]
236pub struct DeleteBoolResponse {
237    /// `true` when the deletion succeeded.
238    pub data: Option<bool>,
239    /// Error message when the request did not succeed.
240    pub error: Option<String>,
241}