mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Added Swagger
This commit is contained in:
parent
43dbe854a6
commit
03a8319f5c
14 changed files with 360 additions and 4 deletions
|
@ -11,6 +11,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ombi.Api.Discord\Ombi.Api.Discord.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
|
||||
<ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" />
|
||||
|
|
|
@ -21,6 +21,11 @@ namespace Ombi.Controllers.External
|
|||
private IEmbyApi EmbyApi { get; }
|
||||
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Signs into the Emby Api
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<EmbySettings> SignIn([FromBody] EmbySettings request)
|
||||
|
|
15
src/Ombi/Controllers/External/PlexController.cs
vendored
15
src/Ombi/Controllers/External/PlexController.cs
vendored
|
@ -25,6 +25,11 @@ namespace Ombi.Controllers.External
|
|||
private IPlexApi PlexApi { get; }
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Signs into the Plex API.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<PlexAuthentication> SignIn([FromBody] UserRequest request)
|
||||
|
@ -75,6 +80,11 @@ PlexAuthToken = result.user.authentication_token,
|
|||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plex libraries.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Libraries")]
|
||||
public async Task<PlexLibraries> GetPlexLibraries([FromBody] PlexServers settings)
|
||||
{
|
||||
|
@ -83,6 +93,11 @@ PlexAuthToken = result.user.authentication_token,
|
|||
return libs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plex servers.
|
||||
/// </summary>
|
||||
/// <param name="u">The u.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("servers")]
|
||||
public async Task<PlexServersViewModel> GetServers([FromBody] UserRequest u)
|
||||
{
|
||||
|
|
|
@ -21,12 +21,22 @@ namespace Ombi.Controllers.External
|
|||
private IRadarrApi RadarrApi { get; }
|
||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Radarr profiles.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Profiles")]
|
||||
public async Task<IEnumerable<RadarrProfile>> GetProfiles([FromBody] RadarrSettings settings)
|
||||
{
|
||||
return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Radar root folders.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("RootFolders")]
|
||||
public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders([FromBody] RadarrSettings settings)
|
||||
{
|
||||
|
|
|
@ -22,12 +22,22 @@ namespace Ombi.Controllers.External
|
|||
private ISonarrApi SonarrApi { get; }
|
||||
private ISettingsService<SonarrSettings> SonarrSettings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Sonarr profiles.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Profiles")]
|
||||
public async Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSettings settings)
|
||||
{
|
||||
return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Sonarr root folders.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("RootFolders")]
|
||||
public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders([FromBody] SonarrSettings settings)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
namespace Ombi.Controllers
|
||||
{
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Indexes this instance.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
|
|
|
@ -16,6 +16,10 @@ using Ombi.Models;
|
|||
|
||||
namespace Ombi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// The Identity Controller, the API for everything Identity/User related
|
||||
/// </summary>
|
||||
/// <seealso cref="Ombi.Controllers.BaseV1ApiController" />
|
||||
[PowerUser]
|
||||
public class IdentityController : BaseV1ApiController
|
||||
{
|
||||
|
@ -28,6 +32,10 @@ namespace Ombi.Controllers
|
|||
private IUserIdentityManager IdentityManager { get; }
|
||||
private IMapper Mapper { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current user.
|
||||
/// </summary>
|
||||
/// <returns>Information about the current user</returns>
|
||||
[HttpGet]
|
||||
public async Task<UserViewModel> GetUser()
|
||||
{
|
||||
|
@ -40,11 +48,12 @@ namespace Ombi.Controllers
|
|||
/// This should never be called after this.
|
||||
/// The reason why we return false if users exists is that this method doesn't have any
|
||||
/// authorization and could be called from anywhere.
|
||||
/// <remarks>We have [AllowAnonymous] since when going through the wizard we do not have a JWT Token yet</remarks>
|
||||
/// </summary>
|
||||
/// <remarks>We have [AllowAnonymous] since when going through the wizard we do not have a JWT Token yet</remarks>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Wizard")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
[AllowAnonymous]
|
||||
public async Task<bool> CreateWizardUser([FromBody] UserAuthModel user)
|
||||
{
|
||||
|
@ -66,6 +75,10 @@ namespace Ombi.Controllers
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all users.
|
||||
/// </summary>
|
||||
/// <returns>Information about all users</returns>
|
||||
[HttpGet("Users")]
|
||||
public async Task<IEnumerable<UserViewModel>> GetAllUsers()
|
||||
{
|
||||
|
@ -95,6 +108,11 @@ namespace Ombi.Controllers
|
|||
return users;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<UserViewModel> CreateUser([FromBody] UserViewModel user)
|
||||
{
|
||||
|
@ -103,6 +121,11 @@ namespace Ombi.Controllers
|
|||
return Mapper.Map<UserViewModel>(userResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<UserViewModel> UpdateUser([FromBody] UserViewModel user)
|
||||
{
|
||||
|
@ -110,6 +133,11 @@ namespace Ombi.Controllers
|
|||
return Mapper.Map<UserViewModel>(userResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<StatusCodeResult> DeleteUser([FromBody] UserViewModel user)
|
||||
{
|
||||
|
@ -117,6 +145,10 @@ namespace Ombi.Controllers
|
|||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all available claims in the system.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("claims")]
|
||||
public IEnumerable<ClaimCheckboxes> GetAllClaims()
|
||||
{
|
||||
|
|
|
@ -24,78 +24,140 @@ namespace Ombi.Controllers
|
|||
private IMovieRequestEngine MovieRequestEngine { get; }
|
||||
private ITvRequestEngine TvRequestEngine { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets movie requests.
|
||||
/// </summary>
|
||||
/// <param name="count">The count of items you want to return.</param>
|
||||
/// <param name="position">The position.</param>
|
||||
[HttpGet("movie/{count:int}/{position:int}")]
|
||||
public async Task<IEnumerable<MovieRequestModel>> GetRequests(int count, int position)
|
||||
{
|
||||
return await MovieRequestEngine.GetRequests(count, position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all movie requests.
|
||||
/// </summary>
|
||||
[HttpGet("movie")]
|
||||
public async Task<IEnumerable<MovieRequestModel>> GetRequests()
|
||||
{
|
||||
return await MovieRequestEngine.GetRequests();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests a movie.
|
||||
/// </summary>
|
||||
/// <param name="movie">The movie.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("movie")]
|
||||
public async Task<RequestEngineResult> RequestMovie([FromBody] SearchMovieViewModel movie)
|
||||
{
|
||||
return await MovieRequestEngine.RequestMovie(movie);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a specific movie request
|
||||
/// </summary>
|
||||
/// <param name="searchTerm">The search term.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/search/{searchTerm}")]
|
||||
public async Task<IEnumerable<MovieRequestModel>> Search(string searchTerm)
|
||||
{
|
||||
return await MovieRequestEngine.SearchMovieRequest(searchTerm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified movie request.
|
||||
/// </summary>
|
||||
/// <param name="requestId">The request identifier.</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("movie/{requestId:int}")]
|
||||
public async Task DeleteRequest(int requestId)
|
||||
{
|
||||
await MovieRequestEngine.RemoveMovieRequest(requestId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the specified movie request.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("movie")]
|
||||
public async Task<MovieRequestModel> UpdateRequest([FromBody] MovieRequestModel model)
|
||||
{
|
||||
return await MovieRequestEngine.UpdateMovieRequest(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tv requests.
|
||||
/// </summary>
|
||||
/// <param name="count">The count of items you want to return.</param>
|
||||
/// <param name="position">The position.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/{count:int}/{position:int}")]
|
||||
public async Task<IEnumerable<TvRequestModel>> GetTvRequests(int count, int position)
|
||||
{
|
||||
return await TvRequestEngine.GetRequests(count, position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tv requests.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv")]
|
||||
public async Task<IEnumerable<TvRequestModel>> GetTvRequests()
|
||||
{
|
||||
return await TvRequestEngine.GetRequests();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests a tv show/episode/season.
|
||||
/// </summary>
|
||||
/// <param name="tv">The tv.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("tv")]
|
||||
public async Task<RequestEngineResult> RequestTv([FromBody] SearchTvShowViewModel tv)
|
||||
{
|
||||
return await TvRequestEngine.RequestTvShow(tv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a specific tv request
|
||||
/// </summary>
|
||||
/// <param name="searchTerm">The search term.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/search/{searchTerm}")]
|
||||
public async Task<IEnumerable<TvRequestModel>> SearchTv(string searchTerm)
|
||||
{
|
||||
return await TvRequestEngine.SearchTvRequest(searchTerm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the a specific tv request
|
||||
/// </summary>
|
||||
/// <param name="requestId">The request identifier.</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("tv/{requestId:int}")]
|
||||
public async Task DeleteTvRequest(int requestId)
|
||||
{
|
||||
await TvRequestEngine.RemoveTvRequest(requestId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the a specific tv request
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("tv")]
|
||||
public async Task<TvRequestModel> UpdateRequest([FromBody] TvRequestModel model)
|
||||
{
|
||||
return await TvRequestEngine.UpdateTvRequest(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the count of total requests
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("count")]
|
||||
[AllowAnonymous]
|
||||
public RequestCountModel GetCountOfRequests()
|
||||
|
@ -104,13 +166,23 @@ namespace Ombi.Controllers
|
|||
return TvRequestEngine.RequestCount();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specific grid model for the requests (for modelling the UI).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/grid")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public async Task<RequestGridModel<TvRequestModel>> GetTvRequestsGrid()
|
||||
{
|
||||
return await GetGrid(TvRequestEngine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specific grid model for the requests (for modelling the UI).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/grid")]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public async Task<RequestGridModel<MovieRequestModel>> GetMovieRequestsGrid()
|
||||
{
|
||||
return await GetGrid(MovieRequestEngine);
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace Ombi.Controllers
|
|||
private IMovieEngine MovieEngine { get; }
|
||||
private ITvSearchEngine TvEngine { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a movie.
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <param name="searchTerm">The search term.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/{searchTerm}")]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> SearchMovie(string searchTerm)
|
||||
{
|
||||
|
@ -33,60 +39,118 @@ namespace Ombi.Controllers
|
|||
return await MovieEngine.Search(searchTerm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets extra information on the movie e.g. IMDBId
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("movie/extrainfo")]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> GetImdbInfo([FromBody]IEnumerable<SearchMovieViewModel> model)
|
||||
{
|
||||
return await MovieEngine.LookupImdbInformation(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Popular Movies
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/popular")]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> Popular()
|
||||
{
|
||||
return await MovieEngine.PopularMovies();
|
||||
}
|
||||
/// <summary>
|
||||
/// Retuns Now Playing Movies
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/nowplaying")]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies()
|
||||
{
|
||||
return await MovieEngine.NowPlayingMovies();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns top rated movies.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
[HttpGet("movie/toprated")]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies()
|
||||
{
|
||||
return await MovieEngine.TopRatedMovies();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns Upcoming movies.
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/upcoming")]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies()
|
||||
{
|
||||
return await MovieEngine.UpcomingMovies();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a Tv Show.
|
||||
/// </summary>
|
||||
/// <param name="searchTerm">The search term.</param>
|
||||
/// <remarks>We use TvMaze as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/{searchTerm}")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> SearchTv(string searchTerm)
|
||||
{
|
||||
return await TvEngine.Search(searchTerm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets extra show information.
|
||||
/// </summary>
|
||||
/// <param name="tvdbId">The TVDB identifier.</param>
|
||||
/// <remarks>We use TvMaze as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/info/{tvdbId}")]
|
||||
public async Task<SearchTvShowViewModel> GetShowInfo(int tvdbId)
|
||||
{
|
||||
return await TvEngine.GetShowInformation(tvdbId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Popular Tv Shows
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/popular")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
||||
{
|
||||
return await TvEngine.Popular();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns most Anticiplateds tv shows.
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/anticiplated")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> AnticiplatedTv()
|
||||
{
|
||||
return await TvEngine.Anticipated();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns Most watched shows.
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/mostwatched")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
||||
{
|
||||
return await TvEngine.MostWatches();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns trending shows
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/trending")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
|
|
|
@ -20,42 +20,73 @@ namespace Ombi.Controllers
|
|||
|
||||
private ISettingsResolver SettingsResolver { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Ombi settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ombi")]
|
||||
public async Task<OmbiSettings> OmbiSettings()
|
||||
{
|
||||
return await Get<OmbiSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Ombi settings.
|
||||
/// </summary>
|
||||
/// <param name="ombi">The ombi.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("ombi")]
|
||||
public async Task<bool> OmbiSettings([FromBody]OmbiSettings ombi)
|
||||
{
|
||||
return await Save(ombi);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Plex Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("plex")]
|
||||
public async Task<PlexSettings> PlexSettings()
|
||||
{
|
||||
return await Get<PlexSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Plex settings.
|
||||
/// </summary>
|
||||
/// <param name="plex">The plex.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("plex")]
|
||||
public async Task<bool> PlexSettings([FromBody]PlexSettings plex)
|
||||
{
|
||||
return await Save(plex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Emby Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("emby")]
|
||||
public async Task<EmbySettings> EmbySettings()
|
||||
{
|
||||
return await Get<EmbySettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Emby settings.
|
||||
/// </summary>
|
||||
/// <param name="emby">The emby.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("emby")]
|
||||
public async Task<bool> EmbySettings([FromBody]EmbySettings emby)
|
||||
{
|
||||
return await Save(emby);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Landing Page Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("landingpage")]
|
||||
[AllowAnonymous]
|
||||
public async Task<LandingPageSettings> LandingPageSettings()
|
||||
|
@ -63,12 +94,21 @@ namespace Ombi.Controllers
|
|||
return await Get<LandingPageSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Landing Page settings.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("landingpage")]
|
||||
public async Task<bool> LandingPageSettings([FromBody]LandingPageSettings settings)
|
||||
{
|
||||
return await Save(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Customization Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("customization")]
|
||||
[AllowAnonymous]
|
||||
public async Task<CustomizationSettings> CustomizationSettings()
|
||||
|
@ -76,32 +116,53 @@ namespace Ombi.Controllers
|
|||
return await Get<CustomizationSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Customization settings.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("customization")]
|
||||
public async Task<bool> CustomizationSettings([FromBody]CustomizationSettings settings)
|
||||
{
|
||||
return await Save(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Sonarr Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("sonarr")]
|
||||
[AllowAnonymous]
|
||||
public async Task<SonarrSettings> SonarrSettings()
|
||||
{
|
||||
return await Get<SonarrSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Sonarr settings.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("sonarr")]
|
||||
public async Task<bool> SonarrSettings([FromBody]SonarrSettings settings)
|
||||
{
|
||||
return await Save(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Radarr Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("radarr")]
|
||||
[AllowAnonymous]
|
||||
public async Task<RadarrSettings> RadarrSettings()
|
||||
{
|
||||
return await Get<RadarrSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the Radarr settings.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("radarr")]
|
||||
public async Task<bool> RadarrSettings([FromBody]RadarrSettings settings)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,10 @@ namespace Ombi.Controllers
|
|||
|
||||
private ISettingsService<OmbiSettings> Ombi { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of Ombi.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
public HttpStatusCode GetStatus()
|
||||
|
@ -52,6 +56,11 @@ namespace Ombi.Controllers
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if we have run through the wizard
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Wizard")]
|
||||
public async Task<object> WizardStatus()
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\netcoreapp1.1\Swagger.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="wwwroot\**" />
|
||||
</ItemGroup>
|
||||
|
@ -42,6 +46,7 @@
|
|||
<PackageReference Include="Serilog.Sinks.File" Version="3.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
|
||||
<PackageReference Include="Serilog.Sinks.SQLite" Version="3.8.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
|
||||
<PackageReference Include="System.Security.Cryptography.Csp" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Ombi.Auth;
|
||||
using Ombi.Config;
|
||||
using Ombi.DependencyInjection;
|
||||
|
@ -21,6 +22,7 @@ using Ombi.Mapping;
|
|||
using Ombi.Schedule;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
|
||||
namespace Ombi
|
||||
{
|
||||
|
@ -68,6 +70,33 @@ namespace Ombi
|
|||
expression.AddCollectionMappers();
|
||||
});
|
||||
services.RegisterDependencies(); // Ioc and EF
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.DescribeAllEnumsAsStrings();
|
||||
c.SwaggerDoc("v1", new Info
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "Ombi Api",
|
||||
Description = "The API for Ombi, most of these calls require an auth token that you can get from calling POST:\"api/v1/token/\" with the body of: \n {\n\"username\":\"YOURUSERNAME\",\n\"password\":\"YOURPASSWORD\"\n} \n" +
|
||||
"You can then use the returned token in the JWT Token field e.g. \"Bearer Token123xxff\"",
|
||||
Contact = new Contact
|
||||
{
|
||||
Email = "tidusjar@gmail.com",
|
||||
Name = "Jamie Rees",
|
||||
Url = "https://www.ombi.io/"
|
||||
}
|
||||
});
|
||||
c.CustomSchemaIds(x => x.FullName);
|
||||
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
|
||||
var xmlPath = Path.Combine(basePath, "Swagger.xml");
|
||||
c.IncludeXmlComments(xmlPath);
|
||||
|
||||
c.AddSecurityDefinition("Authentication",new ApiKeyScheme());
|
||||
c.OperationFilter<SwaggerOperationFilter>();
|
||||
c.DescribeAllParametersInCamelCase();
|
||||
});
|
||||
|
||||
|
||||
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddScoped<IPrincipal>(sp => sp.GetService<IHttpContextAccessor>().HttpContext.User);
|
||||
|
@ -103,6 +132,12 @@ namespace Ombi
|
|||
|
||||
app.UseHangfireServer();
|
||||
app.UseHangfireDashboard();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
|
||||
c.ShowJsonEditor();
|
||||
});
|
||||
|
||||
|
||||
// Setup the scheduler
|
||||
|
|
32
src/Ombi/SwaggerOperationFilter.cs
Normal file
32
src/Ombi/SwaggerOperationFilter.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace Ombi
|
||||
{
|
||||
public class SwaggerOperationFilter : IOperationFilter
|
||||
{
|
||||
public void Apply(Operation operation, OperationFilterContext context)
|
||||
{
|
||||
var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors;
|
||||
var isAuthorized = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is AuthorizeFilter);
|
||||
var allowAnonymous = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is IAllowAnonymousFilter);
|
||||
if (isAuthorized && !allowAnonymous)
|
||||
{
|
||||
if (operation.Parameters == null)
|
||||
operation.Parameters = new List<IParameter>();
|
||||
operation.Parameters.Add(new NonBodyParameter
|
||||
{
|
||||
Name = "Authorization",
|
||||
In = "header",
|
||||
Description = "JWT token",
|
||||
Required = true,
|
||||
Type = "string",
|
||||
Default = "Bearer "
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue