dfns-sdk-rust 0.2.0

Dfns API SDK for Rust
Documentation
// Code generated by rust-sdk-generator. DO NOT EDIT.

pub mod delegated;
pub mod types;

#[allow(unused_imports)]
use types::*;

/// Client for signers operations.
#[derive(Clone)]
pub struct SignersClient {
    client: crate::client::Client,
}

impl SignersClient {
    pub fn new(client: crate::client::Client) -> Self {
        SignersClient { client }
    }

    /// Cancel Fleet Operation
    pub async fn cancel_fleet_operation(
        &self,
        store_id: String,
        body: CancelFleetOperationRequest,
    ) -> Result<CancelFleetOperationResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/fleet-operations/cancel",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request::<CancelFleetOperationResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                true,
            )
            .await
    }

    /// Creates the input archive for an add-mac-user fleet operation, which registers a new Mac operator machine with an HSM in the key store's trust set.
    pub async fn create_add_mac_user_input(
        &self,
        store_id: String,
        body: CreateAddMacUserInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!(
            "/key-stores/{}/add-mac-user/input",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Creates the input archive for an add-provisioner fleet operation, which registers a new provisioner YubiKey into the key store's governance set.
    pub async fn create_add_provisioner_input(
        &self,
        store_id: String,
        body: CreateAddProvisionerInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!(
            "/key-stores/{}/add-provisioner/input",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Creates the input archive for a clone fleet operation, which replicates a key store from a source HSM to a target HSM.
    pub async fn create_clone_input(
        &self,
        store_id: String,
        body: CreateCloneInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!("/key-stores/{}/clone/input", urlencoding::encode(&store_id));
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Creates the input archive for a genesis fleet operation, which provisions a new offline signer fleet and generates the key store's initial signing keys.
    pub async fn create_genesis_input(
        &self,
        store_id: String,
        body: CreateGenesisInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!(
            "/key-stores/{}/genesis/input",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Create Key Harvest Input
    pub async fn create_key_harvest_input(
        &self,
        store_id: String,
        body: CreateKeyHarvestInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!(
            "/key-stores/{}/key-harvest/input",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Creates the input archive for an onchain-sign operation covering the key store's pending signature requests.
    pub async fn create_onchain_sign_input(
        &self,
        store_id: String,
        body: CreateOnchainSignInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!(
            "/key-stores/{}/onchain-sign/input",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Creates the input archive for a proof-of-control operation covering the keys of the specified wallets.
    pub async fn create_proof_of_control_input(
        &self,
        store_id: String,
        body: CreateProofOfControlInputRequest,
    ) -> Result<(), crate::error::Error> {
        let path = format!(
            "/key-stores/{}/proof-of-control/input",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_no_content(reqwest::Method::POST, &path, Some(&body), true)
            .await
    }

    /// Lists the key stores of your organization.
    pub async fn list_key_stores(&self) -> Result<ListKeyStoresResponse, crate::error::Error> {
        let path = String::from("/key-stores");
        self.client
            .request::<ListKeyStoresResponse>(reqwest::Method::GET, &path, None, false)
            .await
    }

    /// Lists the signer clusters of your key store, including each signer's ID and encryption public key.
    pub async fn list_signers(&self) -> Result<ListSignersResponse, crate::error::Error> {
        let path = String::from("/signers");
        self.client
            .request::<ListSignersResponse>(reqwest::Method::GET, &path, None, false)
            .await
    }

    /// Submits the output archive produced by the offline signer fleet for an add-mac-user operation.
    pub async fn submit_add_mac_user_output(
        &self,
        store_id: String,
        body: SubmitAddMacUserOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitAddMacUserOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/add-mac-user/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitAddMacUserOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }

    /// Submits the output archive produced by the offline signer fleet for an add-provisioner operation.
    pub async fn submit_add_provisioner_output(
        &self,
        store_id: String,
        body: SubmitAddProvisionerOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitAddProvisionerOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/add-provisioner/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitAddProvisionerOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }

    /// Submits the output archive produced by the offline signer fleet for a clone operation.
    pub async fn submit_clone_output(
        &self,
        store_id: String,
        body: SubmitCloneOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitCloneOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/clone/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitCloneOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }

    /// Submits the output archive produced by the offline signer fleet for a genesis operation.
    pub async fn submit_genesis_output(
        &self,
        store_id: String,
        body: SubmitGenesisOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitGenesisOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/genesis/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitGenesisOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }

    /// Submit Key Harvest Output
    pub async fn submit_key_harvest_output(
        &self,
        store_id: String,
        body: SubmitKeyHarvestOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitKeyHarvestOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/key-harvest/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitKeyHarvestOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }

    /// Submits the output archive produced by the offline signer fleet for an onchain-sign operation.
    pub async fn submit_onchain_sign_output(
        &self,
        store_id: String,
        body: SubmitOnchainSignOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitOnchainSignOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/onchain-sign/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitOnchainSignOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }

    /// Submits the output archive produced by the offline signer fleet for a proof-of-control operation.
    pub async fn submit_proof_of_control_output(
        &self,
        store_id: String,
        body: SubmitProofOfControlOutputRequest,
        file: crate::client::MultipartFile,
    ) -> Result<SubmitProofOfControlOutputResponse, crate::error::Error> {
        let path = format!(
            "/key-stores/{}/proof-of-control/output",
            urlencoding::encode(&store_id)
        );
        let body = serde_json::to_value(&body)?;
        self.client
            .request_multipart::<SubmitProofOfControlOutputResponse>(
                reqwest::Method::POST,
                &path,
                Some(&body),
                file,
                true,
            )
            .await
    }
}