Changes between Version 14 and Version 15 of documentation/tools/monitoring/rest
- Timestamp:
- 02/20/12 17:08:28 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
documentation/tools/monitoring/rest
v14 v15 2 2 3 3 The components of the monitoring framework use a restful web interface to exchange data. 4 This section is a full documentation of the interface as well as codesexamples, showcasing how the interface can be used and extended.4 This section is a full documentation of the interfaces as well as code examples, showcasing how the interface can be used and extended. 5 5 6 6 == Concept == 7 7 8 Restful web service is a light weight remote procedure call (rpc) interface, using a client-server architecture.8 A restful web service is a light weight remote procedure call (rpc) interface, using a client-server architecture. 9 9 The server provides a number of methods that can be called by the client. 10 Therefor client and server are connected via TCP using HTTP as message protocol.10 Therefore client and server are connected via TCP using HTTP as message protocol. 11 11 Methods are identified by an URI in the HTTP header. 12 The payload of a message , the returned value of a method, isencoded in XML.12 The payload of a message and return values of a method are encoded in XML. 13 13 14 A detailed description of RESTful web service can be found at : [[BR]]15 [http://en.wikipedia.org/wiki/Representational_state_transfer][[BR]]16 [http://www.ibm.com/developerworks/webservices/library/ws-restful/]14 A detailed description of RESTful web service can be found at : 15 * [http://en.wikipedia.org/wiki/Representational_state_transfer] 16 * [http://www.ibm.com/developerworks/webservices/library/ws-restful/] 17 17 18 == Example call ==18 == Example Call == 19 19 20 To call a method on the Rest server a HTTP POST message has to be send to the server.20 To call a method on a RESTful server a HTTP POST message has to be send. 21 21 This POST message has to contain the URL (name of the method) and a number of arguments, if necessary for the call. 22 22 23 For example, if we want to call the method ''hello_client(int i)'' we use the name of the call as the URL for the HTTP header. The method also takes one argument, in the payload of the HTTP POST we append this argument using a prefix that indicates the order of the arguments.23 For example, if we want to call the method ''hello_client(int i)''. We use the name of the call as the URL for the HTTP header. The method also takes one argument, in the payload of the HTTP POST we append this argument using a prefix that indicates the order of the arguments. 24 24 25 25 {{{ … … 32 32 }}} 33 33 34 On every call a response will be created using HTTP REPLY messages and a XML encoded payload. The payload will always start with the name of the call followed by the returned values. There are basically two types of values lists and single values. In case of the ''hello_client''method the returned value will be a string and a list of numbers counting from 1 to 3.34 On every call a response will be created using HTTP REPLY messages and a XML encoded payload. The payload will always start with the name of the call followed by the returned values. There are basically two types of values (i) ''lists'' and (ii) ''single values''. In case of {{{hello_client}}} method the returned value will be a string and a list of numbers counting from 1 to 3. 35 35 36 36 … … 60 60 }}} 61 61 62 == Example method ==62 == Example Method == 63 63 64 This example will show you how to create a method for the restinterface.64 This example will show you how to create a method for the RESTful interface. 65 65 For this example we add the ''hello_client'' method to the collectors interface. 66 The function_wrapper.hpp and function_wrapper.cpp are where themethod has to be defined and implemented.66 The function_wrapper.hpp and function_wrapper.cpp are where method has to be defined and implemented. 67 67 68 68 We add {{{std::string hello_client(std::vector<std::strings>);}}} to the header file and implement the method. … … 71 71 First the number of arguments will be checked, if they don’t match a empty string will be returned. On returning an empty string the caller will create a error message 404 NOT FOUND and send it to the client. This message can be interpreted by the client, that either the method was not found or there are missing/wrong arguments. 72 72 After that a XML document is created using boost property tree. The last step is to register this method by calling 73 {{{register_function("/hello_client",(function_call) &function_wrapper::hello_client);}}}. The first argument of this call defines the URL of the call and thesecond argument is a function pointer to the method.73 {{{register_function("/hello_client",(function_call) &function_wrapper::hello_client);}}}. First argument of this call defines is the URL of the call and second argument is a function pointer to the method. 74 74 75 75 … … 107 107 }}} 108 108 109 == REST interfaces ==109 == RESTful Interfaces == 110 110 111 * [wiki:documentation/tools/monitoring/rest/daemon Interfaces description of thedaemon]111 * [wiki:documentation/tools/monitoring/rest/daemon RESTful interface of mdaemon] 112 112 113 * [wiki:documentation/tools/monitoring/rest/collector Interfaces description of thecollector]113 * [wiki:documentation/tools/monitoring/rest/collector RESTful interfaces of mcollector] 114 114 115 115