MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mrs::rest Namespace Reference

Namespaces

namespace  anonymous_namespace{handler.cc}
 
namespace  anonymous_namespace{openapi_object_creator.cc}
 
namespace  cvt
 
namespace  entry
 

Classes

class  Handler
 
class  OpenApiCreator
 Helper class that facilitates generating OpenAPI swagger for the given DBobject entry. More...
 
class  ParseOptions
 
struct  RequestContext
 
class  RestRequestHandler
 

Typedefs

using RestError = mrs::interface::RestError
 
using ETagMismatch = mrs::interface::ETagMismatch
 
using AuthHandler = mrs::interface::AuthorizeManager::AuthorizeHandlerPtr
 
using AuthHandlers = mrs::interface::AuthorizeManager::AuthHandlers
 
using WwwAuthenticationHandler = mrs::authentication::WwwAuthenticationHandler
 
using Parameters = mrs::interface::RestHandler::Parameters
 
using HttpHeaders = ::http::base::Headers
 
using HttpBuffer = ::http::base::IOBuffer
 
using HttpRequest = ::http::base::Request
 
using ApplyToV3 = mrs::database::entry::AuthPrivilege::ApplyToV3
 
using ApplyToV4 = mrs::database::entry::AuthPrivilege::ApplyToV4
 
using DbObject = mrs::database::entry::DbObject
 
using DbService = mrs::database::entry::DbService
 
using DbObjectPtr = std::shared_ptr< DbObject >
 

Functions

template<typename T >
std::string to_string (const std::optional< T > &v)
 
static bool check_privileges_v3 (const ApplyToV3 &p, const UniversalId &service_id, const UniversalId &schema_id, const UniversalId &db_object_id)
 
static bool check_privileges_v4 (const ApplyToV4 &p, const std::string &service_path, const std::string &schema_path, const std::string &db_object_path)
 
uint32_t do_privilege_check (const std::vector< database::entry::AuthPrivilege > &privileges, const UniversalId &service_id, const std::string &service_path, const UniversalId &schema_id, const std::string &schema_path, const UniversalId &db_object_id, const std::string &db_object_path)
 
uint32_t get_access_right_from_http_method (const uint32_t method)
 
static const char * get_content_type (const Handler::HttpResult::Type type, const std::optional< std::string > &type_text)
 
std::string get_http_method_name (HttpMethod::key_type type)
 
static const char * to_cstr (const bool b)
 
template<typename ValueType , bool default_value = false>
bool to_bool (const ValueType &value)
 
template<typename ValueType >
uint64_t to_uint (const ValueType &value)
 
template<typename ValueType >
double to_double (const ValueType &value)
 
mrs::interface::Options parse_json_options (const std::optional< std::string > &options)
 
rapidjson::Value get_header_info (std::shared_ptr< DbService > service, rapidjson::Document::AllocatorType &allocator)
 Create OpenAPI title, version and description. More...
 
rapidjson::Value get_security_scheme (rapidjson::Document::AllocatorType &allocator)
 Create security scheme for OpenAPI. More...
 
static std::optional< int > get_type_size (std::string_view datatype)
 
rapidjson::Value get_route_openapi_component (DbObjectPtr entry, rapidjson::Document::AllocatorType &allocator)
 Create OpenAPI components section containing security schemes and schemas (type information with constraints) for each db object passed as a parameter. More...
 
void get_procedure_metadata_component (rapidjson::Value &schema_properties, rapidjson::Document::AllocatorType &allocator)
 Create "_metadata" schema component item from a procedure call. More...
 
static rapidjson::Value get_http_500_schema (rapidjson::Document::AllocatorType &allocator)
 
rapidjson::Value get_route_openapi_schema_path (const std::optional< uint32_t > privileges, DbObjectPtr entry, const std::string &url, rapidjson::Document::AllocatorType &allocator)
 Create OpenAPI 'paths' section. More...
 
bool is_supported (const std::shared_ptr< mrs::database::entry::DbObject > &db_obj, const std::shared_ptr< mrs::database::entry::DbSchema > &db_schema)
 Check if the given DB Object entry can be used for getting an OpenAPI description. More...
 
template<typename R >
std::vector< R * > sort_children_by_request_path (std::vector< std::shared_ptr< mrs::interface::EndpointBase > > children)
 Sort Endpoint children by request path. More...
 

Variables

constexpr std::string_view k_auth_method_name = "mrs_login"
 
constexpr std::string_view k_schema_version {"1.0.0"}
 
constexpr std::string_view k_openapi_version {"3.1.0"}
 

Typedef Documentation

◆ ApplyToV3

◆ ApplyToV4

◆ AuthHandler

◆ AuthHandlers

◆ DbObject

◆ DbObjectPtr

using mrs::rest::DbObjectPtr = typedef std::shared_ptr<DbObject>

◆ DbService

◆ ETagMismatch

◆ HttpBuffer

◆ HttpHeaders

◆ HttpRequest

◆ Parameters

◆ RestError

◆ WwwAuthenticationHandler

Function Documentation

◆ check_privileges_v3()

static bool mrs::rest::check_privileges_v3 ( const ApplyToV3 p,
const UniversalId service_id,
const UniversalId schema_id,
const UniversalId db_object_id 
)
static

◆ check_privileges_v4()

static bool mrs::rest::check_privileges_v4 ( const ApplyToV4 p,
const std::string &  service_path,
const std::string &  schema_path,
const std::string &  db_object_path 
)
static

◆ do_privilege_check()

uint32_t mrs::rest::do_privilege_check ( const std::vector< database::entry::AuthPrivilege > &  privileges,
const UniversalId service_id,
const std::string &  service_path,
const UniversalId schema_id,
const std::string &  schema_path,
const UniversalId db_object_id,
const std::string &  db_object_path 
)

◆ get_access_right_from_http_method()

uint32_t mrs::rest::get_access_right_from_http_method ( const uint32_t  method)

◆ get_content_type()

static const char * mrs::rest::get_content_type ( const Handler::HttpResult::Type  type,
const std::optional< std::string > &  type_text 
)
static

◆ get_header_info()

rapidjson::Value mrs::rest::get_header_info ( std::shared_ptr< DbService service,
rapidjson::Document::AllocatorType &  allocator 
)

Create OpenAPI title, version and description.

Parameters
[in]serviceDBservice entry.
[in]allocatorJSON allocator that is used to create OpenAPI swagger.
Returns
OpenAPI header JSON.

◆ get_http_500_schema()

static rapidjson::Value mrs::rest::get_http_500_schema ( rapidjson::Document::AllocatorType &  allocator)
static

◆ get_http_method_name()

std::string mrs::rest::get_http_method_name ( HttpMethod::key_type  type)

◆ get_procedure_metadata_component()

void mrs::rest::get_procedure_metadata_component ( rapidjson::Value &  schema_properties,
rapidjson::Document::AllocatorType &  allocator 
)

Create "_metadata" schema component item from a procedure call.

Parameters
[in,out]schema_propertiesJSON containing schema components.
[in]allocatorJSON allocator that is used to create OpenAPI swagger.

◆ get_route_openapi_component()

rapidjson::Value mrs::rest::get_route_openapi_component ( DbObjectPtr  entry,
rapidjson::Document::AllocatorType &  allocator 
)

Create OpenAPI components section containing security schemes and schemas (type information with constraints) for each db object passed as a parameter.

Parameters
[in]entryDBobject entry
[in]allocatorJSON allocator that is used to create OpenAPI swagger.
Returns
OpenAPI components JSON.

◆ get_route_openapi_schema_path()

rapidjson::Value mrs::rest::get_route_openapi_schema_path ( const std::optional< uint32_t >  privileges,
DbObjectPtr  entry,
const std::string &  url,
rapidjson::Document::AllocatorType &  allocator 
)

Create OpenAPI 'paths' section.

Each path contains supported HTTP methods with HTTP responses and optional parameters.

Parameters
[in]privilegesUser privileges
[in]entryDBobject entry
[in]urlpath used by DBobject entry
[in]allocatorJSON allocator that is used to create OpenAPI swagger.
Returns
OpenAPI paths JSON.

◆ get_security_scheme()

rapidjson::Value mrs::rest::get_security_scheme ( rapidjson::Document::AllocatorType &  allocator)

Create security scheme for OpenAPI.

Parameters
[in]allocatorJSON allocator that is used to create OpenAPI swagger.
Returns
OpenAPI security scheme object.

◆ get_type_size()

static std::optional< int > mrs::rest::get_type_size ( std::string_view  datatype)
static

◆ is_supported()

bool mrs::rest::is_supported ( const std::shared_ptr< mrs::database::entry::DbObject > &  db_obj,
const std::shared_ptr< mrs::database::entry::DbSchema > &  db_schema 
)

Check if the given DB Object entry can be used for getting an OpenAPI description.

It must be enabled, its schema must be enabled, and it have to be in appropriate type.

Parameters
[in]db_objDB Object entry
[in]db_schemaDB Schema entry
Return values
trueDB Object entry might be used.
falseDB Object entry might not be used.

◆ parse_json_options()

mrs::interface::Options mrs::rest::parse_json_options ( const std::optional< std::string > &  options)

◆ sort_children_by_request_path()

template<typename R >
std::vector< R * > mrs::rest::sort_children_by_request_path ( std::vector< std::shared_ptr< mrs::interface::EndpointBase > >  children)

Sort Endpoint children by request path.

Parameters
[in]childrenEndpoint children.
Template Parameters
Rreturned Endpoint type.
Returns
sorted endpoints.

◆ to_bool()

template<typename ValueType , bool default_value = false>
bool mrs::rest::to_bool ( const ValueType &  value)

◆ to_cstr()

static const char * mrs::rest::to_cstr ( const bool  b)
static

◆ to_double()

template<typename ValueType >
double mrs::rest::to_double ( const ValueType &  value)

◆ to_string()

template<typename T >
std::string mrs::rest::to_string ( const std::optional< T > &  v)

◆ to_uint()

template<typename ValueType >
uint64_t mrs::rest::to_uint ( const ValueType &  value)

Variable Documentation

◆ k_auth_method_name

constexpr std::string_view mrs::rest::k_auth_method_name = "mrs_login"
constexpr

◆ k_openapi_version

constexpr std::string_view mrs::rest::k_openapi_version {"3.1.0"}
constexpr

◆ k_schema_version

constexpr std::string_view mrs::rest::k_schema_version {"1.0.0"}
constexpr