Implement dynamic procedure at REST interface
[anna.git] / example / diameter / launcher / EventOperation.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef example_diameter_launcher_EventOperation_hpp
10 #define example_diameter_launcher_EventOperation_hpp
11
12 // STL
13 #include <string>
14
15 // Project
16 #include <anna/json/json.hpp>
17
18
19 class EventOperation {
20
21   bool a_http;
22
23 public:
24   /**
25   * EventOperation constructor
26   *
27   * @param http Indicates that HTTP interface is used.
28   *
29   * At signal interface, the response is written directly as output, but HTTP
30   * one answers json.
31   *
32   * TODO: xml2json implementation (i.e., https://github.com/Cheedoong/xml2json).
33   * As only 3 operations are going to answer xml content:
34   * - working node report ('node')
35   * - diameter hex decode ('decode')
36   * - reinterpret json into xml ('loadmsg')
37   * the effort does not compensate having them responding full json representation.
38   *
39   * So, base64 encoding will be used for those xml representations.
40   *
41   * Anna Suite used xml natively for many things, json will be only used for
42   * REST API on requests and will be transformed internally.
43   */
44   EventOperation(bool http) : a_http(http) {;}
45
46   // Node management
47   bool node(std::string &response, const std::string & name);
48   bool node_auto(std::string &response);
49
50   // Parsing operations
51   bool code(std::string &response, const std::string & diameterJson);
52   bool decode(std::string &response, const std::string & diameterHex);
53   bool loadmsg(std::string &response, const std::string & diameterJson);
54
55   // Hot changes
56   bool services(std::string &response, const std::string & servicesJson);
57   bool diameterServerSessions(std::string &response, int sessions);
58   bool change_dir(std::string &response, const std::string & directory = "");
59
60   // Client sessions visibility
61   bool visibility(std::string &response, const std::string & action, const std::string &addressPort = "", int socket = -1);
62
63   // Snapshots
64   bool collect(std::string &response);
65   bool context(std::string &response, const std::string & targetFile = "");
66   bool forceCountersRecord(std::string &response);
67   bool log_statistics_samples(std::string &response, const std::string & list);
68   bool show_oam(std::string &response);
69   bool show_stats(std::string &response);
70
71   // Flow operations
72   bool sendmsg_hex_2e(std::string &response, const std::string & diameterJson_or_Hex, bool msg_or_hex);
73   bool sendmsg_hex_2c(std::string &response, const std::string & diameterJson_or_Hex, bool msg_or_hex);
74   bool answermsg_action_2e(std::string &response, const std::string & diameterJson_or_action, bool msg_or_action);
75   bool answermsg_action_2c(std::string &response, const std::string & diameterJson_or_action, bool msg_or_action);
76
77   // FSM testing
78   // test_id__<command>
79   bool test_id__description(std::string &response, unsigned int id, const std::string & description);
80   bool test_id__ip_limit(std::string &response, unsigned int id, int amount = 1);
81   bool test_id__timeout(std::string &response, unsigned int id, int msecs);
82   bool test_id__sendmsg2e_2c(std::string &response, unsigned int id, bool _2e_or_2c, const std::string & diameterJson, int stepNumber = -1);
83   bool test_id__delay(std::string &response, unsigned int id, int msecs);
84   bool test_id__sh_command(std::string &response, unsigned int id, const std::string & script);
85   bool test_id__waitfefc_hex(std::string &response, unsigned int id, bool fe_or_fc, const std::string & hex, bool strict = false);
86   bool test_id__waitfefc_msg(std::string &response, unsigned int id, bool fe_or_fc, const std::string & diameterJson, bool strict = false);
87   bool test_id__waitfefc(std::string &response, unsigned int id, bool fe_or_fc,
88                          const std::string & code,
89                          const std::string & bitR,
90                          const std::string & hopByHop,
91                          const std::string & applicationId,
92                          const std::string & sessionId,
93                          const std::string & resultCode,
94                          const std::string & msisdn,
95                          const std::string & imsi,
96                          const std::string & serviceContextId);
97
98   // Testcases execution
99   // test__<command>
100   bool test__ttps(std::string &response, int amount);
101   bool test__next(std::string &response, int syncAmount = 1);
102   bool test__ip_limit(std::string &response, int amount = -2 /* show current ip-limit and in-progress test cases amount */);
103   bool test__goto(std::string &response, int id);
104   bool test__run(std::string &response, int id);
105   bool test__look(std::string &response, int id = -1 /* current */);
106   bool test__state(std::string &response, int id = -1 /* current */);
107   bool test__interact(std::string &response, int amount, unsigned int id = -1 /* current */);
108   bool test__reset(std::string &response, bool soft_hard = true, int id = -1 /* apply to all the tests */);
109   bool test__repeats(std::string &response, int amount);
110   bool test__auto_reset(std::string &response, bool soft_hard);
111   bool test__initialized(std::string &response);
112   bool test__finished(std::string &response);
113   bool test__clear(std::string &response);
114   bool test__junit(std::string &response, const std::string & targetFile);
115   bool test__summary_counts(std::string &response);
116   bool test__summary_states(std::string &response);
117   bool test__summary(std::string &response);
118   bool test__report(std::string &response,
119                     const std::string & state = "all" /* initialized|in-progress|failed|success|[all]|none */, bool enable = true);
120   bool test__report_hex(std::string &response, bool enable = true);
121   bool test__dump_stdout(std::string &response, bool enable = true);
122
123   // Dynamic procedure
124   bool test__dynamic(std::string &response, const nlohmann::json &arguments);
125 };
126
127 #endif