45 if (service ==
"ca") {
54 if (service ==
"ca") {
57 return (sendCommand(
createCommand(
"config-test", config, service)));
63 if (service ==
"ca") {
66 return (sendCommand(
createCommand(
"config-set", config, service)));
76 request->setBodyAsJson(command);
79 }
catch (
const std::exception& ex) {
80 isc_throw(ControlSocketError,
"failed to create request: "
86 boost::system::error_code received_ec;
87 string receive_errmsg;
91 [&io_service, &received_ec, &receive_errmsg]
92 (
const boost::system::error_code& ec,
96 receive_errmsg = errmsg;
100 io_service->stopWork();
109 isc_throw(ControlSocketError,
"communication error (code): "
110 << received_ec.message());
113 if (!receive_errmsg.empty()) {
115 isc_throw(ControlSocketError,
"communication error (message): "
121 isc_throw(ControlSocketError,
"empty response");
125 return (response->getBodyAsJson());
126 }
catch (
const std::exception& ex) {
127 isc_throw(ControlSocketError,
"unparsable response: " << ex.what());
Represents HTTP POST request with JSON body.
Contains declarations for HTTP control socket communication.
boost::shared_ptr< HttpControlSocket > HttpControlSocketPtr
Type definition for the pointer to the HttpControlSocket.
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
boost::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.
HTTP request/response timeout value.
Base class for control socket communication.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Class for control socket communication over HTTP socket.
The IOService class is a wrapper for the ASIO io_service class.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
virtual data::ConstElementPtr configTest(data::ConstElementPtr config, const std::string &service)
Test configuration.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
virtual ~HttpControlSocket()
Destructor (does nothing).
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" }) ...
boost::shared_ptr< const Element > ConstElementPtr
constexpr long TIMEOUT_AGENT_FORWARD_COMMAND
Timeout for the Control Agent to forward command to a Kea server, e.g.
Represents HTTP response with JSON content.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual data::ConstElementPtr configSet(data::ConstElementPtr config, const std::string &service)
Set configuration.
virtual data::ConstElementPtr configGet(const std::string &service)
Get configuration.
This file contains several functions and constants that are used for handling commands and responses ...
const isc::http::Url getUrl() const
Returns the HTTP server URL.
boost::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.