15 auto get_transaction_status = [&](
auto& ctx,
ApiVersion api_version) {
23 std::string tx_id_str,
error;
25 ctx.rpc_ctx->get_request_path_params(),
30 detail::set_gov_error(
32 HTTP_STATUS_BAD_REQUEST,
33 ccf::errors::InvalidResourceName,
40 if (!tx_id.has_value())
42 detail::set_gov_error(
44 HTTP_STATUS_BAD_REQUEST,
45 ccf::errors::InvalidQueryParameterValue,
47 "The value '{}' passed as parameter 'transactionId' could not "
48 "be converted to a valid Transaction ID.",
59 detail::set_gov_error(
61 HTTP_STATUS_INTERNAL_SERVER_ERROR,
62 ccf::errors::InternalError,
64 "get_status_for_txid_v1 returned error: {}",
70 auto body = nlohmann::json::object();
72 body[
"status"] = status;
73 body[
"transactionId"] = tx_id->to_str();
75 ctx.rpc_ctx->set_response_json(body, HTTP_STATUS_OK);
82 "/service/transactions/{transactionId}",
89 auto get_commit = [&](
auto& ctx,
ApiVersion api_version) {
102 detail::set_gov_error(
104 HTTP_STATUS_INTERNAL_SERVER_ERROR,
105 ccf::errors::InternalError,
107 "get_last_committed_txid_v1 returned error: {}",
117 detail::set_gov_error(
119 HTTP_STATUS_INTERNAL_SERVER_ERROR,
120 ccf::errors::InternalError,
122 "get_status_for_txid_v1 returned error: {}",
128 auto body = nlohmann::json::object();
130 body[
"status"] = status;
133 ctx.rpc_ctx->set_response_json(body, HTTP_STATUS_OK);
140 "/service/transactions/commit",
Definition base_endpoint_registry.h:121
ApiResult get_status_for_txid_v1(ccf::View view, ccf::SeqNo seqno, ccf::TxStatus &tx_status)
Definition base_endpoint_registry.cpp:64
ApiResult get_last_committed_txid_v1(ccf::View &view, ccf::SeqNo &seqno)
Definition base_endpoint_registry.cpp:92
virtual Endpoint make_command_endpoint(const std::string &method, RESTVerb verb, const CommandEndpointFunction &f, const AuthnPolicies &ap)
Definition endpoint_registry.cpp:278
bool get_path_param(const ccf::PathParams ¶ms, const std::string ¶m_name, T &value, std::string &error)
Definition endpoint_registry.h:64
Definition api_version.h:11
auto api_version_adapter(Fn &&f, ApiVersion min_accepted=ApiVersion::MIN)
Definition api_version.h:101
ApiVersion
Definition api_version.h:13
void init_transactions_handlers(ccf::BaseEndpointRegistry ®istry)
Definition transactions.h:13
constexpr char const * api_result_to_str(ApiResult result)
Definition base_endpoint_registry.h:35
@ error
Definition tls_session.h:24
view
Definition signatures.h:54
TxStatus
Definition tx_status.h:13
seqno
Definition signatures.h:54
uint64_t View
Definition tx_id.h:23
uint64_t SeqNo
Definition tx_id.h:36
static std::optional< TxID > from_str(const std::string_view &sv)
Definition tx_id.h:53
Endpoint & set_openapi_hidden(bool hidden)
Definition endpoint.cpp:10
void install()
Definition endpoint.cpp:122