CCF
Loading...
Searching...
No Matches
logging_schema.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4#include "ccf/ds/json.h"
5#include "ccf/receipt.h"
6
7namespace loggingapp
8{
9 // Private record/get
10 // Explicit target structs, macro-generated parsers + schema
11 // SNIPPET_START: macro_validation_macros
13 {
14 struct In
15 {
16 size_t id;
17 std::string msg;
18 bool record_claim = false;
19 };
20 };
21
23 {
24 struct Out
25 {
26 std::string msg;
27 };
28 };
29
31 {
32 using Out = bool;
33 };
34
36 {
37 struct Out
38 {
39 bool success;
40 std::string tx_id;
41 };
42 };
43
45 {
46 struct In
47 {
48 size_t id;
49 };
50
51 struct Out
52 {
53 std::string msg;
54 nlohmann::json receipt;
55 };
56 };
57
61
64
67
72
73 // SNIPPET_END: macro_validation_macros
74
76
78 {
79 struct Entry
80 {
81 size_t seqno;
82 size_t id;
83 std::string msg;
84 };
85
86 struct Out
87 {
88 std::vector<Entry> entries;
89 std::optional<std::string> next_link;
90 };
91 };
94 LoggingGetHistoricalRange::Entry, seqno, id, msg);
95
99 LoggingGetHistoricalRange::Out, next_link, "@nextLink");
100
101 // Public record/get
102 // Manual schemas, verified then parsed in handler
103 static const std::string j_record_public_in = R"!!!(
104 {
105 "properties": {
106 "id": {
107 "type": "number"
108 },
109 "msg": {
110 "type": "string"
111 }
112 },
113 "required": [
114 "id",
115 "msg"
116 ],
117 "title": "log/public/params",
118 "type": "object"
119 }
120 )!!!";
121
122 static const std::string j_record_public_out = R"!!!(
123 {
124 "title": "log/public/result",
125 "type": "boolean"
126 }
127 )!!!";
128
129 static const std::string j_get_public_in = R"!!!(
130 {
131 "properties": {
132 "id": {
133 "type": "number"
134 }
135 },
136 "required": [
137 "id"
138 ],
139 "title": "log/public/params",
140 "type": "object"
141 }
142 )!!!";
143
144 static const std::string j_get_public_out = R"!!!(
145 {
146 "properties": {
147 "msg": {
148 "type": "string"
149 }
150 },
151 "required": [
152 "msg"
153 ],
154 "title": "log/public/result",
155 "type": "object"
156 }
157 )!!!";
158}
#define DECLARE_JSON_REQUIRED_FIELDS(TYPE,...)
Definition json.h:712
#define DECLARE_JSON_TYPE(TYPE)
Definition json.h:661
#define DECLARE_JSON_OPTIONAL_FIELDS_WITH_RENAMES(TYPE,...)
Definition json.h:807
#define DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(TYPE)
Definition json.h:688
#define DECLARE_JSON_OPTIONAL_FIELDS(TYPE,...)
Definition json.h:784
Definition logging.cpp:29
Definition logging_schema.h:80
size_t id
Definition logging_schema.h:82
size_t seqno
Definition logging_schema.h:81
std::string msg
Definition logging_schema.h:83
Definition logging_schema.h:87
std::vector< Entry > entries
Definition logging_schema.h:88
std::optional< std::string > next_link
Definition logging_schema.h:89
Definition logging_schema.h:78
Definition logging_schema.h:47
size_t id
Definition logging_schema.h:48
Definition logging_schema.h:52
nlohmann::json receipt
Definition logging_schema.h:54
std::string msg
Definition logging_schema.h:53
Definition logging_schema.h:45
Definition logging_schema.h:25
std::string msg
Definition logging_schema.h:26
Definition logging_schema.h:23
Definition logging_schema.h:38
bool success
Definition logging_schema.h:39
std::string tx_id
Definition logging_schema.h:40
Definition logging_schema.h:36
Definition logging_schema.h:15
bool record_claim
Definition logging_schema.h:18
size_t id
Definition logging_schema.h:16
std::string msg
Definition logging_schema.h:17
Definition logging_schema.h:13
Definition logging_schema.h:31
bool Out
Definition logging_schema.h:32