Developer API

A CCF application is composed of the following:

Application Entry Point

std::unique_ptr<ccf::endpoints::EndpointRegistry> ccf::make_user_endpoints(ccf::AbstractNodeContext &context)

To be implemented by the application. Creates a collection of endpoints which will be exposed to callers under /app.

Parameters:

context – Access to node and host services

Returns:

Unique pointer to the endpoint registry instance

Application Endpoint Registration

struct Endpoint : public ccf::endpoints::EndpointDefinition

An Endpoint represents a user-defined resource that can be invoked by authorised users via HTTP requests, over TLS. An Endpoint is accessible at a specific verb and URI, e.g. POST /app/accounts or GET /app/records.

Endpoints can read from and mutate the state of the replicated key-value store.

A CCF application is a collection of Endpoints recorded in the application’s EndpointRegistry.

Subclassed by ccf::endpoints::PathTemplatedEndpoint, ccf::js::CustomJSEndpoint

Public Functions

Endpoint &set_openapi_description(const std::string &description)

Set the OpenAPI description for the endpoint.

Returns:

This Endpoint for further modification

Endpoint &set_openapi_summary(const std::string &summary)

Set the OpenAPI summary for the endpoint.

Returns:

This Endpoint for further modification

Endpoint &set_openapi_deprecated(bool is_deprecated)

Set the endpoint as deprecated.

Returns:

This Endpoint for further modification

Endpoint &set_openapi_deprecated_replaced(const std::string &deprecation_version, const std::string &replacement)

Set the endpoint as deprecated and overwrites the description to include deprecation version and point to a replacement endpoint.

Returns:

This Endpoint for further modification

Endpoint &set_openapi_hidden(bool hidden)

Whether the endpoint should be omitted from the OpenAPI document.

Returns:

This Endpoint for further modification

Endpoint &require_operator_feature(OperatorFeature feature)

Add an opt-in feature which this endpoint uses. The endpoint will only be available on interfaces which have opted in to enabling all required features.

Returns:

This Endpoint for further modification

Endpoint &set_params_schema(const nlohmann::json &j)

Sets the JSON schema that the request parameters must comply with.

Parameters:

j – Request parameters JSON schema

Returns:

This Endpoint for further modification

Endpoint &set_result_schema(const nlohmann::json &j, std::optional<http_status> status = std::nullopt)

Sets the JSON schema that the request response must comply with.

Parameters:
  • j – Request response JSON schema

  • status – Request response status code