|
| 1 | +#include <unordered_map> |
| 2 | +#include <ydb/library/actors/core/actor_bootstrapped.h> |
| 3 | +#include <library/cpp/json/json_writer.h> |
| 4 | +#include "viewer.h" |
| 5 | +#include "json_handlers.h" |
| 6 | +#include "json_pipe_req.h" |
| 7 | + |
| 8 | +namespace NKikimr { |
| 9 | +namespace NViewer { |
| 10 | + |
| 11 | +using namespace NActors; |
| 12 | + |
| 13 | +class TViewerCapabilities : public TViewerPipeClient<TViewerCapabilities> { |
| 14 | +public: |
| 15 | + using TBase = TViewerPipeClient<TViewerCapabilities>; |
| 16 | + |
| 17 | + static constexpr NKikimrServices::TActivity::EType ActorActivityType() { |
| 18 | + return NKikimrServices::TActivity::VIEWER_HANDLER; |
| 19 | + } |
| 20 | + |
| 21 | + TViewerCapabilities(IViewer* viewer, NMon::TEvHttpInfo::TPtr& ev) |
| 22 | + : TBase(viewer, ev) |
| 23 | + {} |
| 24 | + |
| 25 | + void Bootstrap() { |
| 26 | + ReplyAndPassAway(); |
| 27 | + } |
| 28 | + |
| 29 | + void ReplyAndPassAway() { |
| 30 | + NJson::TJsonValue json; |
| 31 | + json["Capabilities"] = Viewer->GetCapabilities(); |
| 32 | + TBase::ReplyAndPassAway(GetHTTPOKJSON(NJson::WriteJson(json, false))); |
| 33 | + } |
| 34 | +}; |
| 35 | + |
| 36 | +template <> |
| 37 | +YAML::Node TJsonRequestSwagger<TViewerCapabilities>::GetSwagger() { |
| 38 | + YAML::Node node = YAML::Load(R"___( |
| 39 | + post: |
| 40 | + tags: |
| 41 | + - viewer |
| 42 | + summary: Viewer capabilities |
| 43 | + description: Viewer capabilities |
| 44 | + responses: |
| 45 | + 200: |
| 46 | + description: OK |
| 47 | + content: |
| 48 | + application/json: |
| 49 | + schema: |
| 50 | + type: object |
| 51 | + description: format depends on schema parameter |
| 52 | + 400: |
| 53 | + description: Bad Request |
| 54 | + 403: |
| 55 | + description: Forbidden |
| 56 | + 504: |
| 57 | + description: Gateway Timeout |
| 58 | + )___"); |
| 59 | + return node; |
| 60 | +} |
| 61 | + |
| 62 | + |
| 63 | +void InitViewerCapabilitiesJsonHandler(TJsonHandlers& jsonHandlers) { |
| 64 | + jsonHandlers.AddHandler("/viewer/capabilities", new TJsonHandler<TViewerCapabilities>()); |
| 65 | +} |
| 66 | + |
| 67 | +} // namespace NViewer |
| 68 | +} // namespace NKikimr |
0 commit comments