CCF
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
ccf::endpoints::Endpoint Struct Reference

#include <endpoint.h>

Inherits ccf::endpoints::EndpointDefinition.

Inherited by ccf::endpoints::PathTemplatedEndpoint, and ccf::js::CustomJSEndpoint.

Classes

struct  Installer
 

Public Types

using SchemaBuilderFn = std::function< void(nlohmann::json &, const Endpoint &)>
 

Public Member Functions

Endpointset_openapi_description (const std::string &description)
 
Endpointset_openapi_summary (const std::string &summary)
 
Endpointset_openapi_deprecated (bool is_deprecated)
 
Endpointset_openapi_deprecated_replaced (const std::string &deprecation_version, const std::string &replacement)
 
Endpointset_openapi_hidden (bool hidden)
 
Endpointset_params_schema (const nlohmann::json &j)
 
Endpointset_result_schema (const nlohmann::json &j, std::optional< http_status > status=std::nullopt)
 
template<typename In , typename Out >
Endpointset_auto_schema (std::optional< http_status > status=std::nullopt)
 
template<typename T >
Endpointset_auto_schema (std::optional< http_status > status=std::nullopt)
 
template<typename T >
Endpointadd_query_parameter (const std::string &param_name, QueryParamPresence presence=RequiredParameter)
 
Endpointset_forwarding_required (ForwardingRequired fr)
 
Endpointset_redirection_strategy (RedirectionStrategy rs)
 
void install ()
 
- Public Member Functions inherited from ccf::endpoints::EndpointDefinition
virtual ~EndpointDefinition ()=default
 

Public Attributes

EndpointFunction func = {}
 
LocallyCommittedEndpointFunction locally_committed_func = {}
 
Installerinstaller
 
std::vector< SchemaBuilderFnschema_builders = {}
 
bool openapi_hidden = false
 
http_status success_status = HTTP_STATUS_OK
 
nlohmann::json params_schema = nullptr
 
nlohmann::json result_schema = nullptr
 
std::optional< std::string > openapi_summary = std::nullopt
 
std::optional< std::string > openapi_description = std::nullopt
 
std::optional< bool > openapi_deprecated = std::nullopt
 
- Public Attributes inherited from ccf::endpoints::EndpointDefinition
EndpointKey dispatch
 
URI full_uri_path
 Full URI path to endpoint, including method prefix.
 
EndpointProperties properties
 
AuthnPolicies authn_policies
 

Detailed Description

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.

Member Typedef Documentation

◆ SchemaBuilderFn

using ccf::endpoints::Endpoint::SchemaBuilderFn = std::function<void(nlohmann::json&, const Endpoint&)>

Member Function Documentation

◆ add_query_parameter()

template<typename T >
Endpoint & ccf::endpoints::Endpoint::add_query_parameter ( const std::string &  param_name,
QueryParamPresence  presence = RequiredParameter 
)
inline

Add OpenAPI documentation for a query parameter which can be passed to this endpoint.

Template Parameters
TType with appropriate ds::json specialisations to generate a JSON schema description
Parameters
param_nameName to be used for the query parameter to this Endpoint
presenceEnum value indicating whether this parameter is required or optional
Returns
This Endpoint for further modification

◆ install()

void ccf::endpoints::Endpoint::install ( )

◆ set_auto_schema() [1/2]

template<typename In , typename Out >
Endpoint & ccf::endpoints::Endpoint::set_auto_schema ( std::optional< http_status status = std::nullopt)
inline

Sets the schema that the request and response bodies should comply with. These are used to populate the generated OpenAPI document, but do not introduce any constraints on the actual types that are parsed or produced by the handling functor.

embed:rst:leading-asterisk
* .. note::
*  See ``DECLARE_JSON_`` serialisation macros for serialising
*  user-defined data structures.
* 
Template Parameters
InRequest body JSON-serialisable data structure
OutResponse body JSON-serialisable data structure
Parameters
statusResponse status code
Returns
This Endpoint for further modification

◆ set_auto_schema() [2/2]

template<typename T >
Endpoint & ccf::endpoints::Endpoint::set_auto_schema ( std::optional< http_status status = std::nullopt)
inline

Sets schemas for request and response bodies using typedefs within T.

See also
set_auto_schema
embed:rst:leading-asterisk
* .. note::
*   ``T`` data structure should contain two nested ``In`` and ``Out``
*   structures for request parameters and response format, respectively.
* 
Template Parameters
TType containing In and Out typedefs with JSON-schema description specialisations
Parameters
statusRequest response status code
Returns
This Endpoint for further modification

◆ set_forwarding_required()

Endpoint & ccf::endpoints::Endpoint::set_forwarding_required ( endpoints::ForwardingRequired  fr)

Overrides whether a Endpoint is always forwarded, or whether it is safe to sometimes execute on followers.

Parameters
frEnum value with desired status
Returns
This Endpoint for further modification

◆ set_openapi_deprecated()

Endpoint & ccf::endpoints::Endpoint::set_openapi_deprecated ( bool  is_deprecated)

Set the endpoint as deprecated.

Returns
This Endpoint for further modification

◆ set_openapi_deprecated_replaced()

Endpoint & ccf::endpoints::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

◆ set_openapi_description()

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

Set the OpenAPI description for the endpoint.

Returns
This Endpoint for further modification

◆ set_openapi_hidden()

Endpoint & ccf::endpoints::Endpoint::set_openapi_hidden ( bool  hidden)

Whether the endpoint should be omitted from the OpenAPI document.

Returns
This Endpoint for further modification

◆ set_openapi_summary()

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

Set the OpenAPI summary for the endpoint.

Returns
This Endpoint for further modification

◆ set_params_schema()

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

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

Parameters
jRequest parameters JSON schema
Returns
This Endpoint for further modification

◆ set_redirection_strategy()

Endpoint & ccf::endpoints::Endpoint::set_redirection_strategy ( RedirectionStrategy  rs)

◆ set_result_schema()

Endpoint & ccf::endpoints::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
jRequest response JSON schema
statusRequest response status code
Returns
This Endpoint for further modification

Member Data Documentation

◆ func

EndpointFunction ccf::endpoints::Endpoint::func = {}

◆ installer

Installer* ccf::endpoints::Endpoint::installer

◆ locally_committed_func

LocallyCommittedEndpointFunction ccf::endpoints::Endpoint::locally_committed_func = {}

◆ openapi_deprecated

std::optional<bool> ccf::endpoints::Endpoint::openapi_deprecated = std::nullopt

◆ openapi_description

std::optional<std::string> ccf::endpoints::Endpoint::openapi_description = std::nullopt

◆ openapi_hidden

bool ccf::endpoints::Endpoint::openapi_hidden = false

◆ openapi_summary

std::optional<std::string> ccf::endpoints::Endpoint::openapi_summary = std::nullopt

◆ params_schema

nlohmann::json ccf::endpoints::Endpoint::params_schema = nullptr

◆ result_schema

nlohmann::json ccf::endpoints::Endpoint::result_schema = nullptr

◆ schema_builders

std::vector<SchemaBuilderFn> ccf::endpoints::Endpoint::schema_builders = {}

◆ success_status

http_status ccf::endpoints::Endpoint::success_status = HTTP_STATUS_OK

The documentation for this struct was generated from the following files: