Kea  2.3.5-git
cmd_response_creator.h
Go to the documentation of this file.
1 // Copyright (C) 2021-2022 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef CMD__RESPONSE_CREATOR_H
8 #define CMD__RESPONSE_CREATOR_H
9 
10 #include <http/response_creator.h>
11 #include <http/basic_auth_config.h>
12 #include <boost/shared_ptr.hpp>
13 #include <unordered_set>
14 
15 namespace isc {
16 namespace config {
17 
33 public:
34 
40  CmdResponseCreator(bool emulate_agent_response = true)
41  : emulate_agent_response_(emulate_agent_response) {};
42 
51 
58  virtual http::HttpResponsePtr
60  const http::HttpStatusCode& status_code) const;
61 
66  return (emulate_agent_response_);
67  }
68 
78  filterCommand(const http::HttpRequestPtr& request,
79  const data::ConstElementPtr& body,
80  const std::unordered_set<std::string>& accept);
81 
90 
94  static std::unordered_set<std::string> command_accept_list_;
95 
96 private:
97 
109  createStockHttpResponseInternal(const http::HttpRequestPtr& request,
110  const http::HttpStatusCode& status_code) const;
111 
116  virtual http::HttpResponsePtr
117  createDynamicHttpResponse(http::HttpRequestPtr request);
118 
123  bool emulate_agent_response_;
124 };
125 
127 typedef boost::shared_ptr<CmdResponseCreator> CmdResponseCreatorPtr;
128 
129 } // end of namespace isc::config
130 } // end of namespace isc
131 
132 #endif
bool emulateAgentResponse()
Indicates whether or not agent response emulation is enabled.
virtual http::HttpRequestPtr createNewHttpRequest() const
Create a new request.
boost::shared_ptr< CmdResponseCreator > CmdResponseCreatorPtr
Pointer to the CmdResponseCreator.
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
Definition: response_json.h:24
static std::unordered_set< std::string > command_accept_list_
The server command accept list.
Specifies an interface for classes creating HTTP responses from HTTP requests.
http::HttpResponseJsonPtr filterCommand(const http::HttpRequestPtr &request, const data::ConstElementPtr &body, const std::unordered_set< std::string > &accept)
Filter commands.
static http::HttpAuthConfigPtr http_auth_config_
The server current authentication configuration.
virtual http::HttpResponsePtr createStockHttpResponse(const http::HttpRequestPtr &request, const http::HttpStatusCode &status_code) const
Creates stock HTTP response.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
Definition: response.h:78
CmdResponseCreator(bool emulate_agent_response=true)
Constructor.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
Defines the logger used by the top-level component of kea-lfc.
Concrete implementation of the HTTP response creator used for processing API commands.
boost::shared_ptr< HttpRequest > HttpRequestPtr
Pointer to the HttpRequest object.
Definition: request.h:27
boost::shared_ptr< HttpAuthConfig > HttpAuthConfigPtr
Type of shared pointers to HTTP authentication configuration.
Definition: auth_config.h:97
HttpStatusCode
HTTP status codes (cf RFC 2068)
Definition: response.h:30