Kea 2.7.5
isc::config::CmdResponseCreator Class Reference

Concrete implementation of the HTTP response creator used for processing API commands. More...

#include <cmd_response_creator.h>

+ Inheritance diagram for isc::config::CmdResponseCreator:

Public Member Functions

 CmdResponseCreator (bool emulate_agent_response=true)
 Constructor.
 
virtual http::HttpRequestPtr createNewHttpRequest () const
 Create a new request.
 
virtual http::HttpResponsePtr createStockHttpResponse (const http::HttpRequestPtr &request, const http::HttpStatusCode &status_code) const
 Creates stock HTTP response.
 
bool emulateAgentResponse ()
 Indicates whether or not agent response emulation is enabled.
 
http::HttpResponseJsonPtr filterCommand (const http::HttpRequestPtr &request, const data::ConstElementPtr &body, const std::unordered_set< std::string > &accept)
 Filter commands.
 
- Public Member Functions inherited from isc::http::HttpResponseCreator
virtual ~HttpResponseCreator ()
 Destructor.
 
virtual HttpResponsePtr createHttpResponse (HttpRequestPtr request) final
 Create HTTP response from HTTP request received.
 

Static Public Attributes

static std::unordered_set< std::string > command_accept_list_
 The server command accept list.
 
static http::HttpAuthConfigPtr http_auth_config_
 The server current authentication configuration.
 

Additional Inherited Members

Detailed Description

Concrete implementation of the HTTP response creator used for processing API commands.

See the documentation of the isc::http::HttpResponseCreator for the basic information how HTTP response creators are utilized by the libkea-http library to generate HTTP responses.

This creator expects that received requests are encapsulated in the isc::http::PostHttpRequestJson objects. The generated responses are encapsulated in the HttpResponseJson objects.

This class uses CommandMgr singleton to process commands conveyed in the HTTP body. The JSON responses returned by the manager are placed in the body of the generated HTTP responses.

Definition at line 32 of file cmd_response_creator.h.

Constructor & Destructor Documentation

◆ CmdResponseCreator()

isc::config::CmdResponseCreator::CmdResponseCreator ( bool emulate_agent_response = true)
inline

Constructor.

Parameters
emulate_agent_responseif true, responses for normal command outcomes are guaranteed to be wrapped in an Element::list. This emulates how kea-ctrl-agent forms responses. Defaults to true.

Definition at line 40 of file cmd_response_creator.h.

Member Function Documentation

◆ createNewHttpRequest()

HttpRequestPtr isc::config::CmdResponseCreator::createNewHttpRequest ( ) const
virtual

Create a new request.

This method creates a bare instance of the isc::http::PostHttpRequestJson.

Returns
Pointer to the new instance of the isc::http::PostHttpRequestJson.

Implements isc::http::HttpResponseCreator.

Definition at line 31 of file cmd_response_creator.cc.

◆ createStockHttpResponse()

HttpResponsePtr isc::config::CmdResponseCreator::createStockHttpResponse ( const http::HttpRequestPtr & request,
const http::HttpStatusCode & status_code ) const
virtual

Creates stock HTTP response.

Parameters
requestPointer to an object representing HTTP request.
status_codeStatus code of the response.
Returns
Pointer to an isc::http::HttpResponseJson object representing stock HTTP response.

Implements isc::http::HttpResponseCreator.

Definition at line 36 of file cmd_response_creator.cc.

◆ emulateAgentResponse()

bool isc::config::CmdResponseCreator::emulateAgentResponse ( )
inline

Indicates whether or not agent response emulation is enabled.

Returns
true if emulation is enabled.

Definition at line 65 of file cmd_response_creator.h.

◆ filterCommand()

HttpResponseJsonPtr isc::config::CmdResponseCreator::filterCommand ( const http::HttpRequestPtr & request,
const data::ConstElementPtr & body,
const std::unordered_set< std::string > & accept )

Filter commands.

From RBAC code: if the access list is empty or the command cannot be found just return.

Parameters
requestThe HTTP request (for the HTTP version).
bodyThe request body.
acceptThe accept access list.

Definition at line 130 of file cmd_response_creator.cc.

References isc::config::COMMAND_HTTP_LISTENER_COMMAND_REJECTED, isc::config::command_logger, isc::config::CONTROL_COMMAND, isc::config::CONTROL_RESULT, isc::config::CONTROL_TEXT, isc::data::Element::create(), isc::data::Element::createMap(), isc::config::DBG_COMMAND, LOG_DEBUG, isc::data::Element::map, isc::http::HttpResponse::statusCodeToNumber(), isc::http::HttpResponse::statusCodeToString(), and isc::data::Element::string.

+ Here is the call graph for this function:

Member Data Documentation

◆ command_accept_list_

unordered_set< string > isc::config::CmdResponseCreator::command_accept_list_
static

The server command accept list.

Default to the empty list which means to accept everything.

Definition at line 94 of file cmd_response_creator.h.

Referenced by isc::ha::HAService::HAService().

◆ http_auth_config_

HttpAuthConfigPtr isc::config::CmdResponseCreator::http_auth_config_
static

The server current authentication configuration.

Default to the empty HttpAuthConfigPtr.

Note
: This is currently not used, except in unit-tests. For the time being, we postponed writing the corresponding code in the HA, so http_auth_config_ is left to its empty default value.

Definition at line 89 of file cmd_response_creator.h.


The documentation for this class was generated from the following files: