зеркало из https://github.com/microsoft/CCF.git
Add `/gov/kv/endpoints` endpoint to access JS endpoint metadata (#5068)
This commit is contained in:
Родитель
84288d7659
Коммит
6eb3137723
|
@ -76,6 +76,39 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"EndpointKey": {
|
||||
"properties": {
|
||||
"uri_path": {
|
||||
"$ref": "#/components/schemas/string"
|
||||
},
|
||||
"verb": {
|
||||
"$ref": "#/components/schemas/HttpMethod"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri_path",
|
||||
"verb"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"EndpointKey_to_EndpointProperties": {
|
||||
"items": {
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/EndpointKey"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/EndpointProperties"
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxItems": 2,
|
||||
"minItems": 2,
|
||||
"type": "array"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"EndpointMetrics": {
|
||||
"properties": {
|
||||
"metrics": {
|
||||
|
@ -124,6 +157,36 @@
|
|||
},
|
||||
"type": "array"
|
||||
},
|
||||
"EndpointProperties": {
|
||||
"properties": {
|
||||
"authn_policies": {
|
||||
"$ref": "#/components/schemas/string_array"
|
||||
},
|
||||
"forwarding_required": {
|
||||
"$ref": "#/components/schemas/ForwardingRequired"
|
||||
},
|
||||
"js_function": {
|
||||
"$ref": "#/components/schemas/string"
|
||||
},
|
||||
"js_module": {
|
||||
"$ref": "#/components/schemas/string"
|
||||
},
|
||||
"mode": {
|
||||
"$ref": "#/components/schemas/Mode"
|
||||
},
|
||||
"openapi": {
|
||||
"$ref": "#/components/schemas/json"
|
||||
},
|
||||
"openapi_hidden": {
|
||||
"$ref": "#/components/schemas/boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"forwarding_required",
|
||||
"authn_policies"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"Failure": {
|
||||
"properties": {
|
||||
"reason": {
|
||||
|
@ -138,6 +201,14 @@
|
|||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ForwardingRequired": {
|
||||
"enum": [
|
||||
"sometimes",
|
||||
"always",
|
||||
"never"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"FullMemberDetails": {
|
||||
"properties": {
|
||||
"cert": {
|
||||
|
@ -265,6 +336,9 @@
|
|||
],
|
||||
"type": "object"
|
||||
},
|
||||
"HttpMethod": {
|
||||
"type": "string"
|
||||
},
|
||||
"JSRuntimeOptions": {
|
||||
"properties": {
|
||||
"max_execution_time_ms": {
|
||||
|
@ -444,6 +518,14 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"Mode": {
|
||||
"enum": [
|
||||
"readwrite",
|
||||
"readonly",
|
||||
"historical"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"NodeId_to_NodeInfo": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/NodeInfo"
|
||||
|
@ -1131,6 +1213,12 @@
|
|||
"string": {
|
||||
"type": "string"
|
||||
},
|
||||
"string_array": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"string_to_JwtIssuerMetadata": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/JwtIssuerMetadata"
|
||||
|
@ -1487,6 +1575,28 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/gov/kv/endpoints": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/EndpointKey_to_EndpointProperties"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Default response description"
|
||||
},
|
||||
"default": {
|
||||
"$ref": "#/components/responses/default"
|
||||
}
|
||||
},
|
||||
"x-ccf-forwarding": {
|
||||
"$ref": "#/components/x-ccf-forwarding/sometimes"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/gov/kv/history": {
|
||||
"get": {
|
||||
"responses": {
|
||||
|
|
|
@ -22,6 +22,11 @@ namespace ccf::endpoints
|
|||
URI uri_path;
|
||||
/// HTTP Verb
|
||||
RESTVerb verb = HTTP_POST;
|
||||
|
||||
std::string to_str() const
|
||||
{
|
||||
return fmt::format("{} {}", verb.c_str(), uri_path);
|
||||
}
|
||||
};
|
||||
|
||||
DECLARE_JSON_TYPE(EndpointKey);
|
||||
|
|
|
@ -102,4 +102,14 @@ namespace ccf
|
|||
|
||||
verb = RESTVerb(s.c_str());
|
||||
}
|
||||
|
||||
inline std::string schema_name(const RESTVerb*)
|
||||
{
|
||||
return "HttpMethod";
|
||||
}
|
||||
|
||||
inline void fill_json_schema(nlohmann::json& schema, const RESTVerb*)
|
||||
{
|
||||
schema["type"] = "string";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -499,6 +499,12 @@ namespace ccf
|
|||
{
|
||||
response_body[k.hex_str()] = v;
|
||||
}
|
||||
else if constexpr (std::is_same_v<
|
||||
typename T::Key,
|
||||
ccf::endpoints::EndpointKey>)
|
||||
{
|
||||
response_body[k.to_str()] = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
response_body[k] = v;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache 2.0 License.
|
||||
#pragma once
|
||||
|
||||
#include "ccf/endpoint.h"
|
||||
#include "ccf/service/signed_req.h"
|
||||
#include "ccf/service/tables/acme_certificates.h"
|
||||
#include "ccf/service/tables/cert_bundles.h"
|
||||
|
@ -143,11 +144,16 @@ namespace ccf
|
|||
const ModulesQuickJsVersion modules_quickjs_version = {
|
||||
Tables::MODULES_QUICKJS_VERSION};
|
||||
const JSEngine js_engine = {Tables::JSENGINE};
|
||||
const endpoints::EndpointsMap js_endpoints = {endpoints::Tables::ENDPOINTS};
|
||||
|
||||
inline auto get_all_js_generic_tables() const
|
||||
{
|
||||
return std::make_tuple(
|
||||
modules, modules_quickjs_bytecode, modules_quickjs_version, js_engine);
|
||||
modules,
|
||||
modules_quickjs_bytecode,
|
||||
modules_quickjs_version,
|
||||
js_engine,
|
||||
js_endpoints);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче