Trait core::ApiModuleInterface
source · [−]pub trait ApiModuleInterface {
Show 15 methods
fn create_request<'life0, 'async_trait>(
&'life0 self,
request_type: CreateRequest
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn external_request<'life0, 'async_trait>(
&'life0 self,
event_request: ExternalEventRequest
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn create_event<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn simulate_event<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<SubjectData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_all_subjects<'life0, 'async_trait>(
&'life0 self,
namespace: String,
from: Option<usize>,
quantity: Option<usize>
) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectData>, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_all_governances<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectData>, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_event_of_subject<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
from: Option<i64>,
quantity: Option<i64>
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn create_subject<'life0, 'async_trait>(
&'life0 self,
governance_id: String,
schema_id: String,
namespace: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_subject<'life0, 'async_trait>(
&'life0 self,
subject_id: String
) -> Pin<Box<dyn Future<Output = Result<SubjectData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn create_governance<'life0, 'async_trait>(
&'life0 self,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_signatures<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
sn: u64,
from: Option<usize>,
quantity: Option<usize>
) -> Pin<Box<dyn Future<Output = Result<Vec<Signature>, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn shutdown<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'async_trait>>
where
Self: 'async_trait;
fn approval_request<'life0, 'async_trait>(
&'life0 self,
request_id: String,
acceptance: Acceptance
) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_pending_requests<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRequest>, ApiError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_single_request<'async_trait>(
self,
id: String
) -> Pin<Box<dyn Future<Output = Result<EventRequest, ApiError>> + Send + 'async_trait>>
where
Self: 'async_trait;
}
Expand description
Trait that allows implementing the interface of a TAPLE node. The only native implementation is NodeAPI. Users can use the trait to add specific behaviors to an existing node interface. For example, a NodeAPI wrapper could be created that again implements the trait and perform certain intermediate operations, such as incrementing a counter to find out how many API queries have been made.
Required Methods
sourcefn create_request<'life0, 'async_trait>(
&'life0 self,
request_type: CreateRequest
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_request<'life0, 'async_trait>(
&'life0 self,
request_type: CreateRequest
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Allows to generate a voting request in the system. This request will be sent to the node that will be in charge of handling the votes of the rest of the nodes belonging to the same governance.
Possible errors
• ApiError::InternalError if an internal error occurs during operation execution.
• ApiError::InvalidParameters if the specified request identifier does not match a valid [DigestIdentifier].
sourcefn external_request<'life0, 'async_trait>(
&'life0 self,
event_request: ExternalEventRequest
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn external_request<'life0, 'async_trait>(
&'life0 self,
event_request: ExternalEventRequest
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Allows to make a request to the node from an external Invoker
sourcefn create_event<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_event<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Allows adding a new event to the chain of a subject previously existing in the node. The event identifier and its payload are required. This method returns the enumerated [CreateRequestResponse], being the identifier of a request when the event intends to update a governance, in which case it will be communicated to the rest of the nodes aware of the governance with the intention that they vote the change contained in the request. In case the event is from a conventional subject, the system returns the created event.
Possible errors
This method will return ApiError::EventCreationError if it has not been possible to create the event, while ApiError::InternalError will be obtained if an internal error has occurred during the management of the operation. If it has not been possible to create the signature accompanying the creation of the event with the node identity, then ApiError::SignError will be obtained.
sourcefn simulate_event<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<SubjectData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn simulate_event<'life0, 'async_trait>(
&'life0 self,
subject_id: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<SubjectData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
It allows to simulate the creation of an event, obtaining the state that would result from the subject in case the event is actually created.
Possible errors
• ApiError::InvalidParameters if the specified identifier does not match a valid [DigestIdentifier].
• ApiError::SignError if it has not been possible to create the signature that accompanies
the creation of the event with the identity of the node.
• ApiError::NotFound if the specified subject is not registered in the node.
• ApiError::InternalError if an error occurred during simulation execution.
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.
sourcefn get_all_governances<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectData>, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_all_governances<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectData>, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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.
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].
sourcefn create_subject<'life0, 'async_trait>(
&'life0 self,
governance_id: String,
schema_id: String,
namespace: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_subject<'life0, 'async_trait>(
&'life0 self,
governance_id: String,
schema_id: String,
namespace: String,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Allows to create a new subject in the node, being its owner the node in question.
Possible errors
• ApiError::InternalError if an internal error occurred during the execution of the operation.
• ApiError::SignError if it has not been possible to create the signature that accompanies
the creation of the event with the identity of the node.
• ApiError::EventCreationError if it has not been possible to create the subject,
for example, because its governance does not exist.
• ApiError::InvalidParameters if the specified governance identifier does not match a valid [DigestIdentifier].
sourcefn get_subject<'life0, 'async_trait>(
&'life0 self,
subject_id: String
) -> Pin<Box<dyn Future<Output = Result<SubjectData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_subject<'life0, 'async_trait>(
&'life0 self,
subject_id: String
) -> Pin<Box<dyn Future<Output = Result<SubjectData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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.
sourcefn create_governance<'life0, 'async_trait>(
&'life0 self,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_governance<'life0, 'async_trait>(
&'life0 self,
payload: RequestPayload
) -> Pin<Box<dyn Future<Output = Result<RequestData, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Method for creating governance in the system.
Possible errors
• ApiError::InternalError if an internal error occurred during the execution of the operation.
• ApiError::SignError if it has not been possible to create the signature that accompanies
the creation of the event with the identity of the node.
• ApiError::EventCreationError if it has not been possible to create the governance.
Method to obtain the validation signatures of an event from a specified subject.
Paging can be performed using the optional arguments from
and quantity
.
Regarding the first one, it is worth mentioning that it admits negative values, in which case
the pagination is performed in the opposite direction starting from the end of the collection.
Possible errors
• ApiError::NotFound if the specified subject or subject event does not exist.
• ApiError::InvalidParameters if the specified subject identifier does not match a valid [DigestIdentifier].
Stops the node, consuming the instance on the fly. This implies that any previously created API or [NotificationHandler] instances will no longer be functional.
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.
sourcefn get_pending_requests<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRequest>, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_pending_requests<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRequest>, ApiError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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.
sourcefn get_single_request<'async_trait>(
self,
id: String
) -> Pin<Box<dyn Future<Output = Result<EventRequest, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn get_single_request<'async_trait>(
self,
id: String
) -> Pin<Box<dyn Future<Output = Result<EventRequest, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
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.
Implementors
impl ApiModuleInterface for NodeAPI
Feature that allows implementing the API Rest of an Taple node.