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
102 {
103 struct Out
104 {
105 std::optional<ccf::SerialisedCoseEndorsements> endorsements;
106 };
107 };
110
120
121 // Public record/get
122 // Manual schemas, verified then parsed in handler
123 static const std::string j_record_public_in = R"!!!(
124 {
125 "properties": {
126 "id": {
127 "type": "number"
128 },
129 "msg": {
130 "type": "string"
131 }
132 },
133 "required": [
134 "id",
135 "msg"
136 ],
137 "title": "log/public/params",
138 "type": "object"
139 }
140 )!!!";
141
142 static const std::string j_record_public_out = R"!!!(
143 {
144 "title": "log/public/result",
145 "type": "boolean"
146 }
147 )!!!";
148
149 static const std::string j_get_public_in = R"!!!(
150 {
151 "properties": {
152 "id": {
153 "type": "number"
154 }
155 },
156 "required": [
157 "id"
158 ],
159 "title": "log/public/params",
160 "type": "object"
161 }
162 )!!!";
163
164 static const std::string j_get_public_out = R"!!!(
165 {
166 "properties": {
167 "msg": {
168 "type": "string"
169 }
170 },
171 "required": [
172 "msg"
173 ],
174 "title": "log/public/result",
175 "type": "object"
176 }
177 )!!!";
178}
#define DECLARE_JSON_REQUIRED_FIELDS(TYPE,...)
Definition json.h:714
#define DECLARE_JSON_TYPE(TYPE)
Definition json.h:663
#define DECLARE_JSON_OPTIONAL_FIELDS_WITH_RENAMES(TYPE,...)
Definition json.h:809
#define DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(TYPE)
Definition json.h:690
#define DECLARE_JSON_OPTIONAL_FIELDS(TYPE,...)
Definition json.h:786
std::vector< uint8_t > SerialisedCoseSignature
Definition receipt.h:151
Definition logging.cpp:31
Definition logging_schema.h:104
std::optional< ccf::SerialisedCoseEndorsements > endorsements
Definition logging_schema.h:105
Definition logging_schema.h:102
Definition logging_schema.h:114
ccf::SerialisedCoseSignature cose_signature
Definition logging_schema.h:115
Definition logging_schema.h:112
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