// Fireblocks API
//
// 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)
//
// The version of the OpenAPI document: 1.8.0
// Contact: developers@fireblocks.com
// Generated by: https://openapi-generator.tech
use {
super::{Error, configuration},
crate::{
apis::{ContentType, ResponseContent},
models,
},
async_trait::async_trait,
reqwest,
serde::{Deserialize, Serialize, de::Error as _},
std::sync::Arc,
};
#[async_trait]
pub trait PolicyEditorBetaApi: Send + Sync {
/// GET /tap/active_policy
///
/// Returns the active policy and 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. </br>Endpoint Permission: Admin, Non-Signing Admin.
async fn get_active_policy(
&self,
) -> Result<models::PolicyAndValidationResponse, Error<GetActivePolicyError>>;
/// GET /tap/draft
///
/// Returns the active draft and 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. </br>Endpoint Permission: Admin, Non-Signing Admin.
async fn get_draft(
&self,
) -> Result<models::DraftReviewAndValidationResponse, Error<GetDraftError>>;
/// POST /tap/draft
///
/// Send publish request of certain draft id and returns the response. </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. </br>Endpoint Permission: Admin,
/// Non-Signing Admin.
async fn publish_draft(
&self,
params: PublishDraftParams,
) -> Result<models::PublishResult, Error<PublishDraftError>>;
/// POST /tap/publish
///
/// Send publish request of set of policy rules and returns the response.
/// </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. </br>Endpoint Permission: Admin,
/// Non-Signing Admin.
async fn publish_policy_rules(
&self,
params: PublishPolicyRulesParams,
) -> Result<models::PublishResult, Error<PublishPolicyRulesError>>;
/// PUT /tap/draft
///
/// 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.
async fn update_draft(
&self,
params: UpdateDraftParams,
) -> Result<models::DraftReviewAndValidationResponse, Error<UpdateDraftError>>;
}
pub struct PolicyEditorBetaApiClient {
configuration: Arc<configuration::Configuration>,
}
impl PolicyEditorBetaApiClient {
pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
Self { configuration }
}
}
/// struct for passing parameters to the method
/// [`PolicyEditorBetaApi::publish_draft`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct PublishDraftParams {
pub publish_draft_request_v2: models::PublishDraftRequestV2,
/// A unique identifier for the request. If the request is sent multiple
/// times with the same idempotency key, the server will return the same
/// response as the first request. The idempotency key is valid for 24
/// hours.
pub idempotency_key: Option<String>,
}
/// struct for passing parameters to the method
/// [`PolicyEditorBetaApi::publish_policy_rules`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct PublishPolicyRulesParams {
pub policy_rules: models::PolicyRules,
/// A unique identifier for the request. If the request is sent multiple
/// times with the same idempotency key, the server will return the same
/// response as the first request. The idempotency key is valid for 24
/// hours.
pub idempotency_key: Option<String>,
}
/// struct for passing parameters to the method
/// [`PolicyEditorBetaApi::update_draft`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct UpdateDraftParams {
pub policy_rules: models::PolicyRules,
/// A unique identifier for the request. If the request is sent multiple
/// times with the same idempotency key, the server will return the same
/// response as the first request. The idempotency key is valid for 24
/// hours.
pub idempotency_key: Option<String>,
}
#[async_trait]
impl PolicyEditorBetaApi for PolicyEditorBetaApiClient {
/// Returns the active policy and 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. </br>Endpoint Permission: Admin, Non-Signing Admin.
async fn get_active_policy(
&self,
) -> Result<models::PolicyAndValidationResponse, Error<GetActivePolicyError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tap/active_policy", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => {
crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
}
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to \
`models::PolicyAndValidationResponse`",
)));
}
ContentType::Unsupported(local_var_unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{local_var_unknown_type}` content type response that cannot be \
converted to `models::PolicyAndValidationResponse`"
))));
}
}
} else {
let local_var_entity: Option<GetActivePolicyError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Returns the active draft and 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. </br>Endpoint Permission: Admin, Non-Signing Admin.
async fn get_draft(
&self,
) -> Result<models::DraftReviewAndValidationResponse, Error<GetDraftError>> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tap/draft", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => {
crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
}
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to \
`models::DraftReviewAndValidationResponse`",
)));
}
ContentType::Unsupported(local_var_unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{local_var_unknown_type}` content type response that cannot be \
converted to `models::DraftReviewAndValidationResponse`"
))));
}
}
} else {
let local_var_entity: Option<GetDraftError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Send publish request of certain draft id and returns the response. </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. </br>Endpoint Permission: Admin,
/// Non-Signing Admin.
async fn publish_draft(
&self,
params: PublishDraftParams,
) -> Result<models::PublishResult, Error<PublishDraftError>> {
let PublishDraftParams {
publish_draft_request_v2,
idempotency_key,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tap/draft", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = idempotency_key {
local_var_req_builder =
local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
}
local_var_req_builder = local_var_req_builder.json(&publish_draft_request_v2);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => {
crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
}
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to \
`models::PublishResult`",
)));
}
ContentType::Unsupported(local_var_unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{local_var_unknown_type}` content type response that cannot be \
converted to `models::PublishResult`"
))));
}
}
} else {
let local_var_entity: Option<PublishDraftError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Send publish request of set of policy rules and returns the response.
/// </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. </br>Endpoint Permission: Admin,
/// Non-Signing Admin.
async fn publish_policy_rules(
&self,
params: PublishPolicyRulesParams,
) -> Result<models::PublishResult, Error<PublishPolicyRulesError>> {
let PublishPolicyRulesParams {
policy_rules,
idempotency_key,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tap/publish", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = idempotency_key {
local_var_req_builder =
local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
}
local_var_req_builder = local_var_req_builder.json(&policy_rules);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => {
crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
}
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to \
`models::PublishResult`",
)));
}
ContentType::Unsupported(local_var_unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{local_var_unknown_type}` content type response that cannot be \
converted to `models::PublishResult`"
))));
}
}
} else {
let local_var_entity: Option<PublishPolicyRulesError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
async fn update_draft(
&self,
params: UpdateDraftParams,
) -> Result<models::DraftReviewAndValidationResponse, Error<UpdateDraftError>> {
let UpdateDraftParams {
policy_rules,
idempotency_key,
} = params;
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/tap/draft", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder
.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = idempotency_key {
local_var_req_builder =
local_var_req_builder.header("Idempotency-Key", local_var_param_value.to_string());
}
local_var_req_builder = local_var_req_builder.json(&policy_rules);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content_type = local_var_resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let local_var_content_type = super::ContentType::from(local_var_content_type);
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
match local_var_content_type {
ContentType::Json => {
crate::deserialize_wrapper(&local_var_content).map_err(Error::from)
}
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to \
`models::DraftReviewAndValidationResponse`",
)));
}
ContentType::Unsupported(local_var_unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{local_var_unknown_type}` content type response that cannot be \
converted to `models::DraftReviewAndValidationResponse`"
))));
}
}
} else {
let local_var_entity: Option<UpdateDraftError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
}
/// struct for typed errors of method [`PolicyEditorBetaApi::get_active_policy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetActivePolicyError {
DefaultResponse(models::ErrorSchema),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`PolicyEditorBetaApi::get_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDraftError {
DefaultResponse(models::ErrorSchema),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`PolicyEditorBetaApi::publish_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PublishDraftError {
DefaultResponse(models::ErrorSchema),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method
/// [`PolicyEditorBetaApi::publish_policy_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PublishPolicyRulesError {
DefaultResponse(models::ErrorSchema),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`PolicyEditorBetaApi::update_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateDraftError {
DefaultResponse(models::ErrorSchema),
UnknownValue(serde_json::Value),
}