15 auto get_transaction_status = [&](
auto& ctx,
ApiVersion api_version) {
23 std::string tx_id_str;
26 ctx.rpc_ctx->get_request_path_params(),
31 detail::set_gov_error(
33 HTTP_STATUS_BAD_REQUEST,
34 ccf::errors::InvalidResourceName,
41 if (!tx_id.has_value())
43 detail::set_gov_error(
45 HTTP_STATUS_BAD_REQUEST,
46 ccf::errors::InvalidQueryParameterValue,
48 "The value '{}' passed as parameter 'transactionId' could not "
49 "be converted to a valid Transaction ID.",
60 detail::set_gov_error(
62 HTTP_STATUS_INTERNAL_SERVER_ERROR,
63 ccf::errors::InternalError,
65 "get_status_for_txid_v1 returned error: {}",
71 auto body = nlohmann::json::object();
73 body[
"status"] = status;
74 body[
"transactionId"] = tx_id->to_str();
76 ctx.rpc_ctx->set_response_json(body, HTTP_STATUS_OK);
83 "/service/transactions/{transactionId}",
90 auto get_commit = [&](
auto& ctx,
ApiVersion api_version) {
103 detail::set_gov_error(
105 HTTP_STATUS_INTERNAL_SERVER_ERROR,
106 ccf::errors::InternalError,
108 "get_last_committed_txid_v1 returned error: {}",
118 detail::set_gov_error(
120 HTTP_STATUS_INTERNAL_SERVER_ERROR,
121 ccf::errors::InternalError,
123 "get_status_for_txid_v1 returned error: {}",
129 auto body = nlohmann::json::object();
131 body[
"status"] = status;
134 ctx.rpc_ctx->set_response_json(body, HTTP_STATUS_OK);
141 "/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:65
ApiResult get_last_committed_txid_v1(ccf::View &view, ccf::SeqNo &seqno)
Definition base_endpoint_registry.cpp:93
virtual Endpoint make_command_endpoint(const std::string &method, RESTVerb verb, const CommandEndpointFunction &f, const AuthnPolicies &ap)
Definition endpoint_registry.cpp:254
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
ApiVersion
Definition api_version.h:13
auto api_version_adapter(Fn &&f, ApiVersion min_accepted=ApiVersion::MIN)
Definition api_version.h:101
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
TxStatus
Definition tx_status.h:13
view
Definition signatures.h:54
seqno
Definition signatures.h:54
uint64_t View
Definition tx_id.h:23
@ error
Definition tls_session.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:135