summaryrefslogtreecommitdiffstats
path: root/src/hooks/dhcp/stat_cmds/stat_cmds.h
blob: 2474574fa7d6e54e05f9333754a9368a038ce8a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef STAT_CMDS_H
#define STAT_CMDS_H

#include <hooks/hooks.h>

#include <boost/shared_ptr.hpp>

namespace isc {
namespace stat_cmds {

/// @brief Forward declaration of implementation class.
class StatCmdsImpl;

/// @brief Implements the logic for processing commands pertaining to
/// stat manipulation.
///
/// This class is used by the callouts implementing command handlers for
/// stat manipulations.
class StatCmds {
public:
    /// @brief Default Constructor.
    StatCmds() {};

    /// @brief stat-lease4-get command handler
    ///
    /// This command attempts to fetch lease4 statistics for one or
    /// more subnets based upon subnet selection criteria (or lack thereof).
    /// It extracts the command name and arguments from the given Callouthandle,
    /// attempts to process them, and then set's the handle's "response"
    /// arguments accordingly.
    /// {
    ///     "command": "stat-lease4-get",
    ///     "arguments": {
    ///         "subnet-id": 10         // optional
    ///         "subnet-range": {       // optional
    ///             "first-subnet-id": 10,  // id >= 10
    ///             "last-subnet-id": 50    // id <= 50
    ///         }
    ///      }
    /// }
    ///
    /// It produces a response as described below:
    ///
    /// {
    ///     "result": 0,
    ///     "text": "<message>",
    ///     "arguments": {
    ///         "result-set": {
    ///             "timestamp": "2018-03-22 09:43:30.815371",
    ///             "columns": ["subnet_id", "total-addresses",
    ///                         "cumulative-assigned-addresses",
    ///                         "assigned-addresses", "declined-addresses"],
    ///             "rows": [
    ///                 [1, 600, 1000, 450, 3],
    ///                 :
    ///             ]
    ///         }
    ///     }
    /// }
    ///
    /// @param handle Callout context - which is expected to contain the
    ///
    /// add command JSON text in the "command" argument
    /// @return result of the operation
    int
    statLease4GetHandler(hooks::CalloutHandle& handle);

    /// @brief stat-lease6-get command handler
    ///
    /// This command attempts to fetch lease6 statistics for one or
    /// more subnets based upon subnet selection criteria (or lack thereof).
    /// It extracts the command name and arguments from the given Callouthandle,
    /// attempts to process them, and then set's the handle's "response"
    /// argument accordingly.
    /// {
    ///     "command": "stat-lease6-get",
    ///     "arguments": {
    ///         "subnet-id": 10         // optional
    ///         "subnet-range": {       // optional
    ///                 "first-subnet-id": 10,  // id >= 10
    ///                 "last-subnet-id":  50   // id <= 50
    ///         }
    ///      }
    /// }
    ///
    /// It produces a response as described below:
    ///
    /// {
    ///     "result": 0,
    ///     "text": "<message>",
    ///     "arguments": {
    ///         "result-set": {
    ///             "timestamp": "2018-03-22 09:43:30.815371",
    ///             "columns": ["subnet_id", "total-nas",
    ///                         "cumulative-assigned-nas",
    ///                         "assigned-nas", "declined-nas",
    ///                         "total-pds", "cumulative-assigned-pds",
    ///                         "assigned-pds"],
    ///             "rows": [
    ///                 [1, 600, 1000, 450, 3, 64, 20, 10],
    ///                 :
    ///             ]
    ///         }
    ///     }
    /// }
    ///
    ///
    /// @param handle Callout context - which is expected to contain the
    /// add command JSON text in the "command" argument
    /// @return result of the operation
    int
    statLease6GetHandler(hooks::CalloutHandle& handle);
};

};
};

#endif