Struct taple_core::Api
source · pub struct Api { /* private fields */ }
Expand description
Object that allows interaction with a TAPLE node.
It has methods to perform all available read and write operations.
Implementations§
source§impl Api
impl Api
pub fn new( peer_id: PeerId, controller_id: String, public_key: Vec<u8>, sender: SenderEnd<APICommands, ApiResponses> ) -> Self
pub fn peer_id(&self) -> &PeerId
pub fn controller_id(&self) -> &String
pub fn public_key(&self) -> &Vec<u8> ⓘ
pub async fn get_request( &self, request_id: DigestIdentifier ) -> Result<TapleRequest, ApiError>
sourcepub async fn external_request(
&self,
event_request: Signed<EventRequest>
) -> Result<DigestIdentifier, ApiError>
pub async fn external_request( &self, event_request: Signed<EventRequest> ) -> Result<DigestIdentifier, ApiError>
Allows to make a request to the node from an external Invoker
sourcepub async fn get_pending_requests(
&self
) -> Result<Vec<ApprovalEntity>, ApiError>
pub async fn get_pending_requests( &self ) -> Result<Vec<ApprovalEntity>, ApiError>
It allows to obtain all the voting requests pending to be resolved in the node. These requests are received from other nodes in the network when they try to update a governance subject. It is necessary to vote their agreement or disagreement with the proposed changes in order for the events to be implemented.
Possible errors
• [ApiError::InternalError] if an internal error occurs during operation execution.
sourcepub async fn get_single_request(
&self,
id: DigestIdentifier
) -> Result<ApprovalEntity, ApiError>
pub async fn get_single_request( &self, id: DigestIdentifier ) -> Result<ApprovalEntity, ApiError>
It allows to obtain a single voting request pending to be resolved in the node. This request is received from other nodes in the network when they try to update a governance subject. It is necessary to vote its agreement or disagreement with the proposed changes in order for the events to be implemented.
Possible errors
• [ApiError::InternalError] if an internal error occurs during operation execution. • ApiError::NotFound if the requested request does not exist.
sourcepub async fn get_subjects(
&self,
namespace: String,
from: Option<String>,
quantity: Option<i64>
) -> Result<Vec<SubjectData>, ApiError>
pub async fn get_subjects( &self, namespace: String, from: Option<String>, quantity: Option<i64> ) -> Result<Vec<SubjectData>, ApiError>
Allows to get all subjects that are known to the current node, regardless of their governance.
Paging can be performed using the optional arguments from
and quantity
.
Regarding the first one, note that it admits negative values, in which case the paging is
performed in the opposite direction starting from the end of the collection. Note that this method
also returns the subjects that model governance.
Possible errors
• [ApiError::InternalError] if an internal error occurred during the execution of the operation.
pub async fn get_subjects_by_governance( &self, governance_id: DigestIdentifier, from: Option<String>, quantity: Option<i64> ) -> Result<Vec<SubjectData>, ApiError>
sourcepub async fn get_governances(
&self,
namespace: String,
from: Option<String>,
quantity: Option<i64>
) -> Result<Vec<SubjectData>, ApiError>
pub async fn get_governances( &self, namespace: String, from: Option<String>, quantity: Option<i64> ) -> Result<Vec<SubjectData>, ApiError>
It allows to obtain all the subjects that model existing governance in the node.
Possible errors
• [ApiError::InternalError] if an internal error occurred during the execution of the operation.
pub async fn get_event( &self, subject_id: DigestIdentifier, sn: u64 ) -> Result<Signed<Event>, ApiError>
sourcepub async fn get_events(
&self,
subject_id: DigestIdentifier,
from: Option<i64>,
quantity: Option<i64>
) -> Result<Vec<Signed<Event>>, ApiError>
pub async fn get_events( &self, subject_id: DigestIdentifier, from: Option<i64>, quantity: Option<i64> ) -> Result<Vec<Signed<Event>>, ApiError>
Allows to obtain events from a specific subject previously existing in the node.
Paging can be performed by means of the optional arguments from
and quantity
.
Regarding the former, it should be noted that negative values are allowed, in which case
the paging is performed in the opposite direction starting from the end of the string.
Possible errors
• ApiError::InvalidParameters if the specified subject identifier does not match a valid DigestIdentifier.
sourcepub async fn get_subject(
&self,
subject_id: DigestIdentifier
) -> Result<SubjectData, ApiError>
pub async fn get_subject( &self, subject_id: DigestIdentifier ) -> Result<SubjectData, ApiError>
Allows to obtain a specified subject by specifying its identifier.
Possible errors
• ApiError::InvalidParameters if the specified identifier does not match a valid DigestIdentifier.
• ApiError::NotFound if the subject does not exist.
sourcepub async fn approval_request(
&self,
request_id: DigestIdentifier,
acceptance: bool
) -> Result<ApprovalEntity, ApiError>
pub async fn approval_request( &self, request_id: DigestIdentifier, acceptance: bool ) -> Result<ApprovalEntity, ApiError>
Allows to vote on a voting request that previously exists in the system. This vote will be sent to the corresponding node in charge of its collection.
Possible errors
• [ApiError::InternalError] if an internal error occurs during operation execution.
• ApiError::NotFound if the request does not exist in the system.
• ApiError::InvalidParameters if the specified request identifier does not match a valid DigestIdentifier.
• ApiError::VoteNotNeeded if the node’s vote is no longer required.
This occurs when the acceptance of the changes proposed by the petition has already been resolved by the rest of
the nodes in the network or when the node cannot participate in the voting process because it lacks the voting role.