mirror of
https://github.com/Sonarr/Sonarr
synced 2026-04-19 19:51:59 +02:00
Add v5 Language endpoints
This commit is contained in:
parent
d8698d1c28
commit
236978a9b1
2 changed files with 47 additions and 0 deletions
35
src/Sonarr.Api.V5/Localization/LanguageController.cs
Normal file
35
src/Sonarr.Api.V5/Localization/LanguageController.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Languages;
|
||||
using Sonarr.Http;
|
||||
using Sonarr.Http.REST;
|
||||
|
||||
namespace Sonarr.Api.V5.Localization;
|
||||
|
||||
[V5ApiController]
|
||||
public class LanguageController : RestController<LanguageResource>
|
||||
{
|
||||
protected override LanguageResource GetResourceById(int id)
|
||||
{
|
||||
var language = (Language)id;
|
||||
|
||||
return new LanguageResource
|
||||
{
|
||||
Id = (int)language,
|
||||
Name = language.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<LanguageResource> GetAll()
|
||||
{
|
||||
var languageResources = Language.All.Select(l => new LanguageResource
|
||||
{
|
||||
Id = (int)l,
|
||||
Name = l.ToString()
|
||||
})
|
||||
.OrderBy(l => l.Id > 0).ThenBy(l => l.Name)
|
||||
.ToList();
|
||||
|
||||
return languageResources;
|
||||
}
|
||||
}
|
||||
12
src/Sonarr.Api.V5/Localization/LanguageResource.cs
Normal file
12
src/Sonarr.Api.V5/Localization/LanguageResource.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System.Text.Json.Serialization;
|
||||
using Sonarr.Http.REST;
|
||||
|
||||
namespace Sonarr.Api.V5.Localization;
|
||||
|
||||
public class LanguageResource : RestResource
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||
public new int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? NameLower => Name?.ToLowerInvariant();
|
||||
}
|
||||
Loading…
Reference in a new issue