Kea 2.5.7
audit_entry.h
Go to the documentation of this file.
1// Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef AUDIT_ENTRY_H
8#define AUDIT_ENTRY_H
9
10#include <boost/date_time/posix_time/posix_time.hpp>
11#include <boost/multi_index/composite_key.hpp>
12#include <boost/multi_index_container.hpp>
13#include <boost/multi_index/hashed_index.hpp>
14#include <boost/multi_index/mem_fun.hpp>
15#include <boost/multi_index/ordered_index.hpp>
16#include <boost/shared_ptr.hpp>
17#include <cstdint>
18#include <string>
19
20namespace isc {
21namespace db {
22
23class AuditEntry;
24
26typedef boost::shared_ptr<AuditEntry> AuditEntryPtr;
27
67public:
68
73 enum class ModificationType : uint8_t {
74 CREATE = 0,
75 UPDATE = 1,
76 DELETE = 2
77 };
78
88 AuditEntry(const std::string& object_type,
89 const uint64_t object_id,
90 const ModificationType& modification_type,
91 const boost::posix_time::ptime& modification_time,
92 const uint64_t revision_id,
93 const std::string& log_message);
94
103 AuditEntry(const std::string& object_type,
104 const uint64_t object_id,
105 const ModificationType& modification_type,
106 const uint64_t revision_id,
107 const std::string& log_message);
108
125 static AuditEntryPtr create(const std::string& object_type,
126 const uint64_t object_id,
127 const ModificationType& modification_type,
128 const boost::posix_time::ptime& modification_time,
129 const uint64_t revision_id,
130 const std::string& log_message);
131
147 static AuditEntryPtr create(const std::string& object_type,
148 const uint64_t object_id,
149 const ModificationType& modification_type,
150 const uint64_t revision_id,
151 const std::string& log_message);
152
156 std::string getObjectType() const {
157 return (object_type_);
158 }
159
163 uint64_t getObjectId() const {
164 return (object_id_);
165 }
166
171 return (modification_type_);
172 }
173
177 boost::posix_time::ptime getModificationTime() const {
178 return (modification_time_);
179 }
180
187 uint64_t getRevisionId() const {
188 return (revision_id_);
189 }
190
194 std::string getLogMessage() const {
195 return (log_message_);
196 }
197
198private:
199
204 void validate() const;
205
207 std::string object_type_;
208
210 uint64_t object_id_;
211
213 ModificationType modification_type_;
214
216 boost::posix_time::ptime modification_time_;
217
222 uint64_t revision_id_;
223
225 std::string log_message_;
226};
227
230
233
236
241typedef boost::multi_index_container<
242 // The container holds pointers to @c AuditEntry objects.
244 // First index allows for accessing by the object type.
245 boost::multi_index::indexed_by<
246 boost::multi_index::ordered_non_unique<
247 boost::multi_index::tag<AuditEntryObjectTypeTag>,
248 boost::multi_index::composite_key<
250 boost::multi_index::const_mem_fun<
252 std::string,
254 >,
255 boost::multi_index::const_mem_fun<
259 >
260 >
261 >,
262
263 // Second index allows for accessing by the modification time and id.
264 boost::multi_index::ordered_non_unique<
265 boost::multi_index::tag<AuditEntryModificationTimeIdTag>,
266 boost::multi_index::composite_key<
268 boost::multi_index::const_mem_fun<
270 boost::posix_time::ptime,
272 >,
273 boost::multi_index::const_mem_fun<
275 uint64_t,
277 >
278 >
279 >,
280
281 // Third index allows for accessing by the object id.
282 boost::multi_index::hashed_non_unique<
283 boost::multi_index::tag<AuditEntryObjectIdTag>,
284 boost::multi_index::const_mem_fun<
286 uint64_t,
288 >
289 >
290 >
292
294typedef boost::shared_ptr<AuditEntryCollection> AuditEntryCollectionPtr;
295
296} // end of namespace isc::db
297} // end of namespace isc
298
299#endif
Represents a single entry in the audit table.
Definition: audit_entry.h:66
uint64_t getRevisionId() const
Returns revision id.
Definition: audit_entry.h:187
ModificationType
Types of the modifications.
Definition: audit_entry.h:73
ModificationType getModificationType() const
Returns modification type.
Definition: audit_entry.h:170
boost::posix_time::ptime getModificationTime() const
Returns modification time.
Definition: audit_entry.h:177
static AuditEntryPtr create(const std::string &object_type, const uint64_t object_id, const ModificationType &modification_type, const boost::posix_time::ptime &modification_time, const uint64_t revision_id, const std::string &log_message)
Factory function creating an instance of AuditEntry.
Definition: audit_entry.cc:48
std::string getObjectType() const
Returns object type.
Definition: audit_entry.h:156
std::string getLogMessage() const
Returns log message.
Definition: audit_entry.h:194
uint64_t getObjectId() const
Returns object id.
Definition: audit_entry.h:163
boost::shared_ptr< AuditEntry > AuditEntryPtr
Pointer to the AuditEntry object.
Definition: audit_entry.h:26
boost::multi_index_container< AuditEntryPtr, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::tag< AuditEntryObjectTypeTag >, boost::multi_index::composite_key< AuditEntry, boost::multi_index::const_mem_fun< AuditEntry, std::string, &AuditEntry::getObjectType >, boost::multi_index::const_mem_fun< AuditEntry, AuditEntry::ModificationType, &AuditEntry::getModificationType > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< AuditEntryModificationTimeIdTag >, boost::multi_index::composite_key< AuditEntry, boost::multi_index::const_mem_fun< AuditEntry, boost::posix_time::ptime, &AuditEntry::getModificationTime >, boost::multi_index::const_mem_fun< AuditEntry, uint64_t, &AuditEntry::getRevisionId > > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< AuditEntryObjectIdTag >, boost::multi_index::const_mem_fun< AuditEntry, uint64_t, &AuditEntry::getObjectId > > > > AuditEntryCollection
Multi index container holding AuditEntry instances.
Definition: audit_entry.h:291
boost::shared_ptr< AuditEntryCollection > AuditEntryCollectionPtr
Definition: audit_entry.h:294
Defines the logger used by the top-level component of kea-lfc.
Tag used to access index by modification time.
Definition: audit_entry.h:232
Tag used to access index by object id.
Definition: audit_entry.h:235
Tag used to access index by object type.
Definition: audit_entry.h:229