using System;
using System.Threading.Tasks;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.Modules;
using EmbedIO;
using EmbedIO.WebApi;
namespace Artemis.Core.Services
{
///
/// A service that provides access to the local Artemis web server
///
public interface IWebServerService : IArtemisService
{
///
/// Gets the current instance of the web server, replaced when occurs.
///
WebServer? Server { get; }
///
/// Gets the plugins module containing all plugin end points
///
PluginsModule PluginsModule { get; }
///
/// Adds a new endpoint for the given plugin feature receiving an object of type
/// Note: Object will be deserialized using JSON.
///
/// The type of object to be received
/// The plugin feature the end point is associated with
/// The name of the end point, must be unique
///
/// The resulting end point
JsonPluginEndPoint AddJsonEndPoint(PluginFeature feature, string endPointName, Action requestHandler);
///
/// Adds a new endpoint for the given plugin feature receiving an object of type and
/// returning any .
/// Note: Both will be deserialized and serialized respectively using JSON.
///
/// The type of object to be received
/// The plugin feature the end point is associated with
/// The name of the end point, must be unique
///
/// The resulting end point
JsonPluginEndPoint AddResponsiveJsonEndPoint(PluginFeature feature, string endPointName, Func requestHandler);
///
/// Adds a new endpoint that directly maps received JSON to the data model of the provided .
///
/// The data model type of the module
/// The module whose datamodel to apply the received JSON to
/// The name of the end point, must be unique
/// The resulting end point
DataModelJsonPluginEndPoint AddDataModelJsonEndPoint(Module module, string endPointName) where T : DataModel;
///
/// Adds a new endpoint that directly maps received JSON to the data model of the provided .
///
/// The data model type of the module
/// The data model expansion whose datamodel to apply the received JSON to
/// The name of the end point, must be unique
/// The resulting end point
DataModelJsonPluginEndPoint AddDataModelJsonEndPoint(DataModelExpansion dataModelExpansion, string endPointName) where T : DataModel;
///
/// Adds a new endpoint for the given plugin feature receiving an a .
///
/// The plugin feature the end point is associated with
/// The name of the end point, must be unique
///
/// The resulting end point
StringPluginEndPoint AddStringEndPoint(PluginFeature feature, string endPointName, Action requestHandler);
///
/// Adds a new endpoint for the given plugin feature receiving an a and returning a
/// or .
///
/// The plugin feature the end point is associated with
/// The name of the end point, must be unique
///
/// The resulting end point
StringPluginEndPoint AddResponsiveStringEndPoint(PluginFeature feature, string endPointName, Func requestHandler);
///
/// Adds a new endpoint for the given plugin feature that handles a raw .
///
/// Note: This requires that you reference the EmbedIO
/// Nuget package.
///
///
/// The plugin feature the end point is associated with
/// The name of the end point, must be unique
///
/// The resulting end point
RawPluginEndPoint AddRawEndPoint(PluginFeature feature, string endPointName, Func requestHandler);
///
/// Removes an existing endpoint
///
/// The end point to remove
void RemovePluginEndPoint(PluginEndPoint endPoint);
///
/// Adds a new Web API controller and restarts the web server
///
/// The type of Web API controller to remove
void AddController() where T : WebApiController;
///
/// Removes an existing Web API controller and restarts the web server
///
/// The type of Web API controller to remove
void RemoveController() where T : WebApiController;
///
/// Occurs when the web server has been created and is about to start. This is the ideal place to add your own modules.
///
event EventHandler? WebServerStarting;
}
}