fireblocks_sdk/apis/
policy_editor_beta_api.rs

1// Fireblocks API
2//
3// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain.  - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10    super::{Error, configuration},
11    crate::{
12        apis::{ContentType, ResponseContent},
13        models,
14    },
15    async_trait::async_trait,
16    reqwest,
17    serde::{Deserialize, Serialize, de::Error as _},
18    std::sync::Arc,
19};
20
21#[async_trait]
22pub trait PolicyEditorBetaApi: Send + Sync {
23    /// GET /tap/active_policy
24    ///
25    /// Returns the active policy and its validation. </br> **Note:** These
26    /// endpoints are currently in beta and might be subject to changes. If you
27    /// want to participate and learn more about the Fireblocks TAP, please
28    /// contact your Fireblocks Customer Success Manager or send an email to
29    /// CSM@fireblocks.com. </br>Endpoint Permission: Admin, Non-Signing Admin.
30    async fn get_active_policy(
31        &self,
32    ) -> Result<models::PolicyAndValidationResponse, Error<GetActivePolicyError>>;
33
34    /// GET /tap/draft
35    ///
36    /// Returns the active draft and its validation. </br> **Note:** These
37    /// endpoints are currently in beta and might be subject to changes. If you
38    /// want to participate and learn more about the Fireblocks TAP, please
39    /// contact your Fireblocks Customer Success Manager or send an email to
40    /// CSM@fireblocks.com. </br>Endpoint Permission: Admin, Non-Signing Admin.
41    async fn get_draft(
42        &self,
43    ) -> Result<models::DraftReviewAndValidationResponse, Error<GetDraftError>>;
44
45    /// POST /tap/draft
46    ///
47    /// Send publish request of certain draft id and returns the response. </br>
48    /// **Note:** These endpoints are currently in beta and might be subject to
49    /// changes. If you want to participate and learn more about the Fireblocks
50    /// TAP, please contact your Fireblocks Customer Success Manager or send an
51    /// email to CSM@fireblocks.com. </br>Endpoint Permission: Admin,
52    /// Non-Signing Admin.
53    async fn publish_draft(
54        &self,
55        params: PublishDraftParams,
56    ) -> Result<models::PublishResult, Error<PublishDraftError>>;
57
58    /// POST /tap/publish
59    ///
60    /// Send publish request of set of policy rules and returns the response.
61    /// </br> **Note:** These endpoints are currently in beta and might be
62    /// subject to changes. If you want to participate and learn more about the
63    /// Fireblocks TAP, please contact your Fireblocks Customer Success Manager
64    /// or send an email to CSM@fireblocks.com. </br>Endpoint Permission: Admin,
65    /// Non-Signing Admin.
66    async fn publish_policy_rules(
67        &self,
68        params: PublishPolicyRulesParams,
69    ) -> Result<models::PublishResult, Error<PublishPolicyRulesError>>;
70
71    /// PUT /tap/draft
72    ///
73    /// Update the draft and return its validation. </br> **Note:** These endpoints are currently in beta and might be subject to changes. If you want to participate and learn more about the Fireblocks TAP, please contact your Fireblocks Customer Success Manager or send an email to CSM@fireblocks.com. Learn more about Fireblocks Transaction Authorization Policy in the following [guide](https://developers.fireblocks.com/docs/set-transaction-authorization-policy). </br>Endpoint Permission: Admin, Non-Signing Admin.
74    async fn update_draft(
75        &self,
76        params: UpdateDraftParams,
77    ) -> Result<models::DraftReviewAndValidationResponse, Error<UpdateDraftError>>;
78}
79
80pub struct PolicyEditorBetaApiClient {
81    configuration: Arc<configuration::Configuration>,
82}
83
84impl PolicyEditorBetaApiClient {
85    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
86        Self { configuration }
87    }
88}
89
90/// struct for passing parameters to the method [`publish_draft`]
91#[derive(Clone, Debug)]
92#[cfg_attr(feature = "bon", derive(::bon::Builder))]
93pub struct PublishDraftParams {
94    pub publish_draft_request: models::PublishDraftRequest,
95    /// A unique identifier for the request. If the request is sent multiple
96    /// times with the same idempotency key, the server will return the same
97    /// response as the first request. The idempotency key is valid for 24
98    /// hours.
99    pub idempotency_key: Option<String>,
100}
101
102/// struct for passing parameters to the method [`publish_policy_rules`]
103#[derive(Clone, Debug)]
104#[cfg_attr(feature = "bon", derive(::bon::Builder))]
105pub struct PublishPolicyRulesParams {
106    pub policy_rules: models::PolicyRules,
107    /// A unique identifier for the request. If the request is sent multiple
108    /// times with the same idempotency key, the server will return the same
109    /// response as the first request. The idempotency key is valid for 24
110    /// hours.
111    pub idempotency_key: Option<String>,
112}
113
114/// struct for passing parameters to the method [`update_draft`]
115#[derive(Clone, Debug)]
116#[cfg_attr(feature = "bon", derive(::bon::Builder))]
117pub struct UpdateDraftParams {
118    pub policy_rules: models::PolicyRules,
119    /// A unique identifier for the request. If the request is sent multiple
120    /// times with the same idempotency key, the server will return the same
121    /// response as the first request. The idempotency key is valid for 24
122    /// hours.
123    pub idempotency_key: Option<String>,
124}
125
126#[async_trait]
127impl PolicyEditorBetaApi for PolicyEditorBetaApiClient {
128    /// Returns the active policy and its validation. </br> **Note:** These
129    /// endpoints are currently in beta and might be subject to changes. If you
130    /// want to participate and learn more about the Fireblocks TAP, please
131    /// contact your Fireblocks Customer Success Manager or send an email to
132    /// CSM@fireblocks.com. </br>Endpoint Permission: Admin, Non-Signing Admin.
133    async fn get_active_policy(
134        &self,
135    ) -> Result<models::PolicyAndValidationResponse, Error<GetActivePolicyError>> {
136        let local_var_configuration = &self.configuration;
137
138        let local_var_client = &local_var_configuration.client;
139
140        let local_var_uri_str = format!("{}/tap/active_policy", local_var_configuration.base_path);
141        let mut local_var_req_builder =
142            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
143
144        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
145            local_var_req_builder = local_var_req_builder
146                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
147        }
148
149        let local_var_req = local_var_req_builder.build()?;
150        let local_var_resp = local_var_client.execute(local_var_req).await?;
151
152        let local_var_status = local_var_resp.status();
153        let local_var_content_type = local_var_resp
154            .headers()
155            .get("content-type")
156            .and_then(|v| v.to_str().ok())
157            .unwrap_or("application/octet-stream");
158        let local_var_content_type = super::ContentType::from(local_var_content_type);
159        let local_var_content = local_var_resp.text().await?;
160
161        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
162            match local_var_content_type {
163                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
164                ContentType::Text => {
165                    return Err(Error::from(serde_json::Error::custom(
166                        "Received `text/plain` content type response that cannot be converted to \
167                         `models::PolicyAndValidationResponse`",
168                    )));
169                }
170                ContentType::Unsupported(local_var_unknown_type) => {
171                    return Err(Error::from(serde_json::Error::custom(format!(
172                        "Received `{local_var_unknown_type}` content type response that cannot be \
173                         converted to `models::PolicyAndValidationResponse`"
174                    ))));
175                }
176            }
177        } else {
178            let local_var_entity: Option<GetActivePolicyError> =
179                serde_json::from_str(&local_var_content).ok();
180            let local_var_error = ResponseContent {
181                status: local_var_status,
182                content: local_var_content,
183                entity: local_var_entity,
184            };
185            Err(Error::ResponseError(local_var_error))
186        }
187    }
188
189    /// Returns the active draft and its validation. </br> **Note:** These
190    /// endpoints are currently in beta and might be subject to changes. If you
191    /// want to participate and learn more about the Fireblocks TAP, please
192    /// contact your Fireblocks Customer Success Manager or send an email to
193    /// CSM@fireblocks.com. </br>Endpoint Permission: Admin, Non-Signing Admin.
194    async fn get_draft(
195        &self,
196    ) -> Result<models::DraftReviewAndValidationResponse, Error<GetDraftError>> {
197        let local_var_configuration = &self.configuration;
198
199        let local_var_client = &local_var_configuration.client;
200
201        let local_var_uri_str = format!("{}/tap/draft", local_var_configuration.base_path);
202        let mut local_var_req_builder =
203            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
204
205        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
206            local_var_req_builder = local_var_req_builder
207                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208        }
209
210        let local_var_req = local_var_req_builder.build()?;
211        let local_var_resp = local_var_client.execute(local_var_req).await?;
212
213        let local_var_status = local_var_resp.status();
214        let local_var_content_type = local_var_resp
215            .headers()
216            .get("content-type")
217            .and_then(|v| v.to_str().ok())
218            .unwrap_or("application/octet-stream");
219        let local_var_content_type = super::ContentType::from(local_var_content_type);
220        let local_var_content = local_var_resp.text().await?;
221
222        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
223            match local_var_content_type {
224                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
225                ContentType::Text => {
226                    return Err(Error::from(serde_json::Error::custom(
227                        "Received `text/plain` content type response that cannot be converted to \
228                         `models::DraftReviewAndValidationResponse`",
229                    )));
230                }
231                ContentType::Unsupported(local_var_unknown_type) => {
232                    return Err(Error::from(serde_json::Error::custom(format!(
233                        "Received `{local_var_unknown_type}` content type response that cannot be \
234                         converted to `models::DraftReviewAndValidationResponse`"
235                    ))));
236                }
237            }
238        } else {
239            let local_var_entity: Option<GetDraftError> =
240                serde_json::from_str(&local_var_content).ok();
241            let local_var_error = ResponseContent {
242                status: local_var_status,
243                content: local_var_content,
244                entity: local_var_entity,
245            };
246            Err(Error::ResponseError(local_var_error))
247        }
248    }
249
250    /// Send publish request of certain draft id and returns the response. </br>
251    /// **Note:** These endpoints are currently in beta and might be subject to
252    /// changes. If you want to participate and learn more about the Fireblocks
253    /// TAP, please contact your Fireblocks Customer Success Manager or send an
254    /// email to CSM@fireblocks.com. </br>Endpoint Permission: Admin,
255    /// Non-Signing Admin.
256    async fn publish_draft(
257        &self,
258        params: PublishDraftParams,
259    ) -> Result<models::PublishResult, Error<PublishDraftError>> {
260        let PublishDraftParams {
261            publish_draft_request,
262            idempotency_key,
263        } = params;
264
265        let local_var_configuration = &self.configuration;
266
267        let local_var_client = &local_var_configuration.client;
268
269        let local_var_uri_str = format!("{}/tap/draft", local_var_configuration.base_path);
270        let mut local_var_req_builder =
271            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
272
273        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
274            local_var_req_builder = local_var_req_builder
275                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
276        }
277        if let Some(local_var_param_value) = idempotency_key {
278            local_var_req_builder =
279                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
280        }
281        local_var_req_builder = local_var_req_builder.json(&publish_draft_request);
282
283        let local_var_req = local_var_req_builder.build()?;
284        let local_var_resp = local_var_client.execute(local_var_req).await?;
285
286        let local_var_status = local_var_resp.status();
287        let local_var_content_type = local_var_resp
288            .headers()
289            .get("content-type")
290            .and_then(|v| v.to_str().ok())
291            .unwrap_or("application/octet-stream");
292        let local_var_content_type = super::ContentType::from(local_var_content_type);
293        let local_var_content = local_var_resp.text().await?;
294
295        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
296            match local_var_content_type {
297                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
298                ContentType::Text => {
299                    return Err(Error::from(serde_json::Error::custom(
300                        "Received `text/plain` content type response that cannot be converted to \
301                         `models::PublishResult`",
302                    )));
303                }
304                ContentType::Unsupported(local_var_unknown_type) => {
305                    return Err(Error::from(serde_json::Error::custom(format!(
306                        "Received `{local_var_unknown_type}` content type response that cannot be \
307                         converted to `models::PublishResult`"
308                    ))));
309                }
310            }
311        } else {
312            let local_var_entity: Option<PublishDraftError> =
313                serde_json::from_str(&local_var_content).ok();
314            let local_var_error = ResponseContent {
315                status: local_var_status,
316                content: local_var_content,
317                entity: local_var_entity,
318            };
319            Err(Error::ResponseError(local_var_error))
320        }
321    }
322
323    /// Send publish request of set of policy rules and returns the response.
324    /// </br> **Note:** These endpoints are currently in beta and might be
325    /// subject to changes. If you want to participate and learn more about the
326    /// Fireblocks TAP, please contact your Fireblocks Customer Success Manager
327    /// or send an email to CSM@fireblocks.com. </br>Endpoint Permission: Admin,
328    /// Non-Signing Admin.
329    async fn publish_policy_rules(
330        &self,
331        params: PublishPolicyRulesParams,
332    ) -> Result<models::PublishResult, Error<PublishPolicyRulesError>> {
333        let PublishPolicyRulesParams {
334            policy_rules,
335            idempotency_key,
336        } = params;
337
338        let local_var_configuration = &self.configuration;
339
340        let local_var_client = &local_var_configuration.client;
341
342        let local_var_uri_str = format!("{}/tap/publish", local_var_configuration.base_path);
343        let mut local_var_req_builder =
344            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
345
346        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
347            local_var_req_builder = local_var_req_builder
348                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
349        }
350        if let Some(local_var_param_value) = idempotency_key {
351            local_var_req_builder =
352                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
353        }
354        local_var_req_builder = local_var_req_builder.json(&policy_rules);
355
356        let local_var_req = local_var_req_builder.build()?;
357        let local_var_resp = local_var_client.execute(local_var_req).await?;
358
359        let local_var_status = local_var_resp.status();
360        let local_var_content_type = local_var_resp
361            .headers()
362            .get("content-type")
363            .and_then(|v| v.to_str().ok())
364            .unwrap_or("application/octet-stream");
365        let local_var_content_type = super::ContentType::from(local_var_content_type);
366        let local_var_content = local_var_resp.text().await?;
367
368        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
369            match local_var_content_type {
370                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
371                ContentType::Text => {
372                    return Err(Error::from(serde_json::Error::custom(
373                        "Received `text/plain` content type response that cannot be converted to \
374                         `models::PublishResult`",
375                    )));
376                }
377                ContentType::Unsupported(local_var_unknown_type) => {
378                    return Err(Error::from(serde_json::Error::custom(format!(
379                        "Received `{local_var_unknown_type}` content type response that cannot be \
380                         converted to `models::PublishResult`"
381                    ))));
382                }
383            }
384        } else {
385            let local_var_entity: Option<PublishPolicyRulesError> =
386                serde_json::from_str(&local_var_content).ok();
387            let local_var_error = ResponseContent {
388                status: local_var_status,
389                content: local_var_content,
390                entity: local_var_entity,
391            };
392            Err(Error::ResponseError(local_var_error))
393        }
394    }
395
396    /// Update the draft and return its validation. </br> **Note:** These endpoints are currently in beta and might be subject to changes. If you want to participate and learn more about the Fireblocks TAP, please contact your Fireblocks Customer Success Manager or send an email to CSM@fireblocks.com. Learn more about Fireblocks Transaction Authorization Policy in the following [guide](https://developers.fireblocks.com/docs/set-transaction-authorization-policy). </br>Endpoint Permission: Admin, Non-Signing Admin.
397    async fn update_draft(
398        &self,
399        params: UpdateDraftParams,
400    ) -> Result<models::DraftReviewAndValidationResponse, Error<UpdateDraftError>> {
401        let UpdateDraftParams {
402            policy_rules,
403            idempotency_key,
404        } = params;
405
406        let local_var_configuration = &self.configuration;
407
408        let local_var_client = &local_var_configuration.client;
409
410        let local_var_uri_str = format!("{}/tap/draft", local_var_configuration.base_path);
411        let mut local_var_req_builder =
412            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
413
414        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
415            local_var_req_builder = local_var_req_builder
416                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
417        }
418        if let Some(local_var_param_value) = idempotency_key {
419            local_var_req_builder =
420                local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
421        }
422        local_var_req_builder = local_var_req_builder.json(&policy_rules);
423
424        let local_var_req = local_var_req_builder.build()?;
425        let local_var_resp = local_var_client.execute(local_var_req).await?;
426
427        let local_var_status = local_var_resp.status();
428        let local_var_content_type = local_var_resp
429            .headers()
430            .get("content-type")
431            .and_then(|v| v.to_str().ok())
432            .unwrap_or("application/octet-stream");
433        let local_var_content_type = super::ContentType::from(local_var_content_type);
434        let local_var_content = local_var_resp.text().await?;
435
436        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
437            match local_var_content_type {
438                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
439                ContentType::Text => {
440                    return Err(Error::from(serde_json::Error::custom(
441                        "Received `text/plain` content type response that cannot be converted to \
442                         `models::DraftReviewAndValidationResponse`",
443                    )));
444                }
445                ContentType::Unsupported(local_var_unknown_type) => {
446                    return Err(Error::from(serde_json::Error::custom(format!(
447                        "Received `{local_var_unknown_type}` content type response that cannot be \
448                         converted to `models::DraftReviewAndValidationResponse`"
449                    ))));
450                }
451            }
452        } else {
453            let local_var_entity: Option<UpdateDraftError> =
454                serde_json::from_str(&local_var_content).ok();
455            let local_var_error = ResponseContent {
456                status: local_var_status,
457                content: local_var_content,
458                entity: local_var_entity,
459            };
460            Err(Error::ResponseError(local_var_error))
461        }
462    }
463}
464
465/// struct for typed errors of method [`get_active_policy`]
466#[derive(Debug, Clone, Serialize, Deserialize)]
467#[serde(untagged)]
468pub enum GetActivePolicyError {
469    DefaultResponse(models::ErrorSchema),
470    UnknownValue(serde_json::Value),
471}
472
473/// struct for typed errors of method [`get_draft`]
474#[derive(Debug, Clone, Serialize, Deserialize)]
475#[serde(untagged)]
476pub enum GetDraftError {
477    DefaultResponse(models::ErrorSchema),
478    UnknownValue(serde_json::Value),
479}
480
481/// struct for typed errors of method [`publish_draft`]
482#[derive(Debug, Clone, Serialize, Deserialize)]
483#[serde(untagged)]
484pub enum PublishDraftError {
485    DefaultResponse(models::ErrorSchema),
486    UnknownValue(serde_json::Value),
487}
488
489/// struct for typed errors of method [`publish_policy_rules`]
490#[derive(Debug, Clone, Serialize, Deserialize)]
491#[serde(untagged)]
492pub enum PublishPolicyRulesError {
493    DefaultResponse(models::ErrorSchema),
494    UnknownValue(serde_json::Value),
495}
496
497/// struct for typed errors of method [`update_draft`]
498#[derive(Debug, Clone, Serialize, Deserialize)]
499#[serde(untagged)]
500pub enum UpdateDraftError {
501    DefaultResponse(models::ErrorSchema),
502    UnknownValue(serde_json::Value),
503}