Leosac
0.8.0
Open Source Access Control
UpdateSerializer.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2016 Leosac
3
4
This file is part of Leosac.
5
6
Leosac is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Affero General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Leosac is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Affero General Public License for more details.
15
16
You should have received a copy of the GNU Affero General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include "
UpdateSerializer.hpp
"
21
#include "
core/update/IUpdate.hpp
"
22
#include "
tools/JSONUtils.hpp
"
23
#include <date/date.h>
24
25
namespace
Leosac
26
{
27
namespace
update
28
{
29
json
UpdateJSONSerializer::serialize
(
const
update::IUpdate
&in,
30
const
SecurityContext
&)
31
{
32
json
serialized;
33
serialized[
"type"
] =
"update"
;
34
serialized[
"id"
] = in.
id
();
35
36
serialized[
"attributes"
][
"status"
] =
static_cast<
int
>
(in.
status
());
37
serialized[
"attributes"
][
"checkpoint"
] = in.
get_checkpoint
();
38
serialized[
"attributes"
][
"generated-at"
] =
39
date::format
(
"%FT%T%z"
, in.
generated_at
());
40
serialized[
"attributes"
][
"status-updated-at"
] =
41
date::format
(
"%FT%T%z"
, in.
status_updated_at
());
42
43
serialized[
"attributes"
][
"source-module"
] = in.
source_module
();
44
serialized[
"attributes"
][
"description"
] = in.
description
();
45
46
return
serialized;
47
}
48
}
49
}
Leosac::update::IUpdate::generated_at
virtual const TimePoint & generated_at() const =0
IUpdate.hpp
Leosac::json
nlohmann::json json
Definition:
AuditSerializer.hpp:29
Leosac::update::UpdateJSONSerializer::serialize
static json serialize(const update::IUpdate &in, const SecurityContext &sc)
Definition:
UpdateSerializer.cpp:29
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
UpdateSerializer.hpp
Leosac::update::IUpdate::get_checkpoint
virtual Audit::AuditEntryId get_checkpoint() const =0
JSONUtils.hpp
Leosac::update::IUpdate
Definition:
IUpdate.hpp:30
Leosac::update::IUpdate::description
virtual const std::string & description() const =0
Leosac::Colorize::detail::format
std::string format(const std::string &escape_code, const T &in)
Return a string containing the escape code, a string representation of T and the clear escape string.
Definition:
Colorize.hpp:49
Leosac::update::IUpdate::status_updated_at
virtual const TimePoint & status_updated_at() const =0
Leosac::update::IUpdate::status
virtual Status status() const =0
Leosac::update::IUpdate::source_module
virtual const std::string & source_module() const =0
Leosac::SecurityContext
A SecurityContext is used to query permission while doing an operation.
Definition:
SecurityContext.hpp:40
Leosac::update::IUpdate::id
virtual UpdateId id() const =0
src
core
update
serializers
UpdateSerializer.cpp
Generated on Tue Mar 22 2022 10:48:21 for Leosac by
1.8.17