<reponame>shinesolutions/swagger-aem
/**
 * Adobe Experience Manager (AEM) API
 * Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
 *
 * The version of the OpenAPI document: 3.5.0-pre.0
 * Contact: <EMAIL>
 *
 * NOTE: This class is auto generated by OpenAPI-Generator 5.2.1.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


#include <corvusoft/restbed/byte.hpp>
#include <corvusoft/restbed/string.hpp>
#include <corvusoft/restbed/settings.hpp>
#include <corvusoft/restbed/request.hpp>

#include "ConsoleApi.h"

namespace org {
namespace openapitools {
namespace server {
namespace api {

using namespace org::openapitools::server::model;

ConsoleApi::ConsoleApi() {
}

ConsoleApi::~ConsoleApi() {}

void ConsoleApi::startService(int const& port) {
	// A typical pattern is to derive a class from ConsoleApi and allocate the shared pointers for restbed::Resource objects
	// and manipulate them (e.g. binding GET/POST handler functions) before this startService() gets called.
	// In such a case we want to use our m_spXXX variables.
	// However in case these shared pointers are nullptr, then allocate the restbed::Resources now:
	if (!m_spConsoleApiSystemConsoleStatus-productinfo.jsonResource)
		m_spConsoleApiSystemConsoleStatus-productinfo.jsonResource = std::make_shared<ConsoleApiSystemConsoleStatus-productinfo.jsonResource>();
	this->publish(m_spConsoleApiSystemConsoleStatus-productinfo.jsonResource);
	if (!m_spConsoleApiSystemConsoleBundles{name}.jsonResource)
		m_spConsoleApiSystemConsoleBundles{name}.jsonResource = std::make_shared<ConsoleApiSystemConsoleBundles{name}.jsonResource>();
	this->publish(m_spConsoleApiSystemConsoleBundles{name}.jsonResource);
	if (!m_spConsoleApiSystemConsoleConfigMgrResource)
		m_spConsoleApiSystemConsoleConfigMgrResource = std::make_shared<ConsoleApiSystemConsoleConfigMgrResource>();
	this->publish(m_spConsoleApiSystemConsoleConfigMgrResource);
	if (!m_spConsoleApiSystemConsoleBundlesNameResource)
		m_spConsoleApiSystemConsoleBundlesNameResource = std::make_shared<ConsoleApiSystemConsoleBundlesNameResource>();
	this->publish(m_spConsoleApiSystemConsoleBundlesNameResource);
	if (!m_spConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource)
		m_spConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource = std::make_shared<ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource>();
	this->publish(m_spConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource);
	if (!m_spConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource)
		m_spConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource = std::make_shared<ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource>();
	this->publish(m_spConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource);

	std::shared_ptr<restbed::Settings> settings = std::make_shared<restbed::Settings>();
	settings->set_port(port);
	settings->set_root("");
	
	this->start(settings);
}

void ConsoleApi::stopService() {
	this->stop();
}

ConsoleApiSystemConsoleStatus-productinfo.jsonResource::ConsoleApiSystemConsoleStatus-productinfo.jsonResource()
{
	this->set_path("/system/console/status-productinfo.json/");
	this->set_method_handler("GET",
		std::bind(&ConsoleApiSystemConsoleStatus-productinfo.jsonResource::GET_method_handler, this,
			std::placeholders::_1));
}

ConsoleApiSystemConsoleStatus-productinfo.jsonResource::~ConsoleApiSystemConsoleStatus-productinfo.jsonResource()
{
}

void ConsoleApiSystemConsoleStatus-productinfo.jsonResource::set_handler_GET(
	std::function<std::pair<int, std::string>(
		
	)> handler) {
	handler_GET_ = std::move(handler);
}


void ConsoleApiSystemConsoleStatus-productinfo.jsonResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {

	const auto request = session->get_request();




			// Change the value of this variable to the appropriate response before sending the response
			int status_code = 200;
			std::string result = "successful operation";

			if (handler_GET_)
			{
				std::tie(status_code, result) = handler_GET_(
					
				);
			}

			if (status_code == 0) {
				session->close(0, result.empty() ? "Default response" : std::move(result), { {"Connection", "close"} });
				return;
			}

}



ConsoleApiSystemConsoleBundles{name}.jsonResource::ConsoleApiSystemConsoleBundles{name}.jsonResource()
{
	this->set_path("/system/console/bundles/{name}.json/");
	this->set_method_handler("GET",
		std::bind(&ConsoleApiSystemConsoleBundles{name}.jsonResource::GET_method_handler, this,
			std::placeholders::_1));
}

ConsoleApiSystemConsoleBundles{name}.jsonResource::~ConsoleApiSystemConsoleBundles{name}.jsonResource()
{
}

void ConsoleApiSystemConsoleBundles{name}.jsonResource::set_handler_GET(
	std::function<std::pair<int, std::string>(
		std::string const &
	)> handler) {
	handler_GET_ = std::move(handler);
}


void ConsoleApiSystemConsoleBundles{name}.jsonResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {

	const auto request = session->get_request();

			// Getting the path params
			const std::string name = request->get_path_parameter("name", "");



			// Change the value of this variable to the appropriate response before sending the response
			int status_code = 200;
			std::string result = "successful operation";

			if (handler_GET_)
			{
				std::tie(status_code, result) = handler_GET_(
					name
				);
			}

			if (status_code == 200) {
				session->close(200, result.empty() ? "Retrieved bundle info" : std::move(result), { {"Connection", "close"} });
				return;
			}
			if (status_code == 0) {
				session->close(0, result.empty() ? "Default response" : std::move(result), { {"Connection", "close"} });
				return;
			}

}



ConsoleApiSystemConsoleConfigMgrResource::ConsoleApiSystemConsoleConfigMgrResource()
{
	this->set_path("/system/console/configMgr/");
	this->set_method_handler("GET",
		std::bind(&ConsoleApiSystemConsoleConfigMgrResource::GET_method_handler, this,
			std::placeholders::_1));
}

ConsoleApiSystemConsoleConfigMgrResource::~ConsoleApiSystemConsoleConfigMgrResource()
{
}

void ConsoleApiSystemConsoleConfigMgrResource::set_handler_GET(
	std::function<std::pair<int, std::string>(
		
	)> handler) {
	handler_GET_ = std::move(handler);
}


void ConsoleApiSystemConsoleConfigMgrResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {

	const auto request = session->get_request();




			// Change the value of this variable to the appropriate response before sending the response
			int status_code = 200;
			std::string result = "successful operation";

			if (handler_GET_)
			{
				std::tie(status_code, result) = handler_GET_(
					
				);
			}

			if (status_code == 200) {
				session->close(200, result.empty() ? "OK" : std::move(result), { {"Connection", "close"} });
				return;
			}
			if (status_code == 5XX) {
				session->close(5XX, result.empty() ? "Unexpected error." : std::move(result), { {"Connection", "close"} });
				return;
			}

}



ConsoleApiSystemConsoleBundlesNameResource::ConsoleApiSystemConsoleBundlesNameResource()
{
	this->set_path("/system/console/bundles/{name: .*}/");
	this->set_method_handler("POST",
		std::bind(&ConsoleApiSystemConsoleBundlesNameResource::POST_method_handler, this,
			std::placeholders::_1));
}

ConsoleApiSystemConsoleBundlesNameResource::~ConsoleApiSystemConsoleBundlesNameResource()
{
}

void ConsoleApiSystemConsoleBundlesNameResource::set_handler_POST(
	std::function<std::pair<int, std::string>(
		std::string const &, std::string const &
	)> handler) {
	handler_POST_ = std::move(handler);
}


void ConsoleApiSystemConsoleBundlesNameResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {

	const auto request = session->get_request();

			// Getting the path params
			const std::string name = request->get_path_parameter("name", "");

			// Getting the query params
			const std::string action = request->get_query_parameter("action", "");


			// Change the value of this variable to the appropriate response before sending the response
			int status_code = 200;
			std::string result = "successful operation";

			if (handler_POST_)
			{
				std::tie(status_code, result) = handler_POST_(
					name, action
				);
			}

			if (status_code == 0) {
				session->close(0, result.empty() ? "Default response" : std::move(result), { {"Connection", "close"} });
				return;
			}

}



ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource::ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource()
{
	this->set_path("/system/console/jmx/com.adobe.granite:type&#x3D;Repository/op/{action: .*}/");
	this->set_method_handler("POST",
		std::bind(&ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource::POST_method_handler, this,
			std::placeholders::_1));
}

ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource::~ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource()
{
}

void ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource::set_handler_POST(
	std::function<std::pair<int, std::string>(
		std::string const &
	)> handler) {
	handler_POST_ = std::move(handler);
}


void ConsoleApiSystemConsoleJmxCom.adobe.granite:type&#x3D;RepositoryOpActionResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {

	const auto request = session->get_request();

			// Getting the path params
			const std::string action = request->get_path_parameter("action", "");



			// Change the value of this variable to the appropriate response before sending the response
			int status_code = 200;
			std::string result = "successful operation";

			if (handler_POST_)
			{
				std::tie(status_code, result) = handler_POST_(
					action
				);
			}

			if (status_code == 0) {
				session->close(0, result.empty() ? "Default response" : std::move(result), { {"Connection", "close"} });
				return;
			}

}



ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource::ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource()
{
	this->set_path("/system/console/configMgr/com.adobe.granite.auth.saml.SamlAuthenticationHandler/");
	this->set_method_handler("POST",
		std::bind(&ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource::POST_method_handler, this,
			std::placeholders::_1));
}

ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource::~ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource()
{
}

void ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource::set_handler_POST(
	std::function<std::pair<int, std::string>(
		bool const &, bool const &, bool const &, std::string const &, std::string const &, std::vector<std::string> const &, int32_t const &, std::string const &, std::string const &, bool const &, std::string const &, std::string const &, std::string const &, std::string const &, std::string const &, std::string const &, bool const &, bool const &, bool const &, std::string const &, std::vector<std::string> const &, std::string const &, std::vector<std::string> const &, bool const &, std::string const &, int32_t const &, std::string const &, std::string const &, std::string const &, std::vector<std::string> const &
	)> handler) {
	handler_POST_ = std::move(handler);
}


void ConsoleApiSystemConsoleConfigMgrCom.adobe.granite.auth.saml.SamlAuthenticationHandlerResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {

	const auto request = session->get_request();


			// Getting the query params
			const bool post = request->get_query_parameter("post", false);
			const bool apply = request->get_query_parameter("apply", false);
			const bool r_delete = request->get_query_parameter("r_delete", false);
			const std::string action = request->get_query_parameter("action", "");
			const std::string Dollarlocation = request->get_query_parameter("Dollarlocation", "");
			const int32_t servicePeriodranking = request->get_query_parameter("servicePeriodranking", 0);
			const std::string idpUrl = request->get_query_parameter("idpUrl", "");
			const std::string idpCertAlias = request->get_query_parameter("idpCertAlias", "");
			const bool idpHttpRedirect = request->get_query_parameter("idpHttpRedirect", false);
			const std::string serviceProviderEntityId = request->get_query_parameter("serviceProviderEntityId", "");
			const std::string assertionConsumerServiceURL = request->get_query_parameter("assertionConsumerServiceURL", "");
			const std::string spPrivateKeyAlias = request->get_query_parameter("spPrivateKeyAlias", "");
			const std::string keyStorePassword = request->get_query_parameter("keyStorePassword", "");
			const std::string defaultRedirectUrl = request->get_query_parameter("defaultRedirectUrl", "");
			const std::string userIDAttribute = request->get_query_parameter("userIDAttribute", "");
			const bool useEncryption = request->get_query_parameter("useEncryption", false);
			const bool createUser = request->get_query_parameter("createUser", false);
			const bool addGroupMemberships = request->get_query_parameter("addGroupMemberships", false);
			const std::string groupMembershipAttribute = request->get_query_parameter("groupMembershipAttribute", "");
			const std::string nameIdFormat = request->get_query_parameter("nameIdFormat", "");
			const bool handleLogout = request->get_query_parameter("handleLogout", false);
			const std::string logoutUrl = request->get_query_parameter("logoutUrl", "");
			const int32_t clockTolerance = request->get_query_parameter("clockTolerance", 0);
			const std::string digestMethod = request->get_query_parameter("digestMethod", "");
			const std::string signatureMethod = request->get_query_parameter("signatureMethod", "");
			const std::string userIntermediatePath = request->get_query_parameter("userIntermediatePath", "");


			// Change the value of this variable to the appropriate response before sending the response
			int status_code = 200;
			std::string result = "successful operation";

			if (handler_POST_)
			{
				std::tie(status_code, result) = handler_POST_(
					post, apply, r_delete, action, Dollarlocation, path, servicePeriodranking, idpUrl, idpCertAlias, idpHttpRedirect, serviceProviderEntityId, assertionConsumerServiceURL, spPrivateKeyAlias, keyStorePassword, defaultRedirectUrl, userIDAttribute, useEncryption, createUser, addGroupMemberships, groupMembershipAttribute, defaultGroups, nameIdFormat, synchronizeAttributes, handleLogout, logoutUrl, clockTolerance, digestMethod, signatureMethod, userIntermediatePath, propertylist
				);
			}

			if (status_code == 200) {
				session->close(200, result.empty() ? "Retrieved AEM SAML Configuration" : std::move(result), { {"Connection", "close"} });
				return;
			}
			if (status_code == 302) {
				session->close(302, result.empty() ? "Default response" : std::move(result), { {"Connection", "close"} });
				return;
			}
			if (status_code == 0) {
				session->close(0, result.empty() ? "Default response" : std::move(result), { {"Connection", "close"} });
				return;
			}

}




}
}
}
}

