mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-04 10:34:59 +02:00
Parameter binding for API requests
This commit is contained in:
parent
3fbe436138
commit
7166a6c019
@ -51,7 +51,7 @@ protected override AutoTaggingResource GetResourceById(int id)
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<AutoTaggingResource> Create(AutoTaggingResource autoTagResource)
|
||||
public ActionResult<AutoTaggingResource> Create([FromBody] AutoTaggingResource autoTagResource)
|
||||
{
|
||||
var model = autoTagResource.ToModel(_specifications);
|
||||
|
||||
@ -62,7 +62,7 @@ public ActionResult<AutoTaggingResource> Create(AutoTaggingResource autoTagResou
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<AutoTaggingResource> Update(AutoTaggingResource resource)
|
||||
public ActionResult<AutoTaggingResource> Update([FromBody] AutoTaggingResource resource)
|
||||
{
|
||||
var model = resource.ToModel(_specifications);
|
||||
|
||||
|
@ -51,7 +51,7 @@ protected override CommandResource GetResourceById(int id)
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
public ActionResult<CommandResource> StartCommand(CommandResource commandResource)
|
||||
public ActionResult<CommandResource> StartCommand([FromBody] CommandResource commandResource)
|
||||
{
|
||||
var commandType =
|
||||
_knownTypes.GetImplementations(typeof(Command))
|
||||
|
@ -34,7 +34,7 @@ public TResource GetConfig()
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public virtual ActionResult<TResource> SaveConfig(TResource resource)
|
||||
public virtual ActionResult<TResource> SaveConfig([FromBody] TResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
|
@ -122,7 +122,7 @@ public HostConfigResource GetHostConfig()
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<HostConfigResource> SaveHostConfig(HostConfigResource resource)
|
||||
public ActionResult<HostConfigResource> SaveHostConfig([FromBody] HostConfigResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
|
@ -53,7 +53,7 @@ public NamingConfigResource GetNamingConfig()
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<NamingConfigResource> UpdateNamingConfig(NamingConfigResource resource)
|
||||
public ActionResult<NamingConfigResource> UpdateNamingConfig([FromBody] NamingConfigResource resource)
|
||||
{
|
||||
var nameSpec = resource.ToModel();
|
||||
ValidateFormatResult(nameSpec);
|
||||
|
@ -32,7 +32,7 @@ public UiConfigController(IConfigFileProvider configFileProvider, IConfigService
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public override ActionResult<UiConfigResource> SaveConfig(UiConfigResource resource)
|
||||
public override ActionResult<UiConfigResource> SaveConfig([FromBody] UiConfigResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
|
@ -31,7 +31,7 @@ public List<CustomFilterResource> GetCustomFilters()
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFilterResource> AddCustomFilter(CustomFilterResource resource)
|
||||
public ActionResult<CustomFilterResource> AddCustomFilter([FromBody] CustomFilterResource resource)
|
||||
{
|
||||
var customFilter = _customFilterService.Add(resource.ToModel());
|
||||
|
||||
@ -40,7 +40,7 @@ public ActionResult<CustomFilterResource> AddCustomFilter(CustomFilterResource r
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFilterResource> UpdateCustomFilter(CustomFilterResource resource)
|
||||
public ActionResult<CustomFilterResource> UpdateCustomFilter([FromBody] CustomFilterResource resource)
|
||||
{
|
||||
_customFilterService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
@ -49,7 +49,7 @@ protected override CustomFormatResource GetResourceById(int id)
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFormatResource> Create(CustomFormatResource customFormatResource)
|
||||
public ActionResult<CustomFormatResource> Create([FromBody] CustomFormatResource customFormatResource)
|
||||
{
|
||||
var model = customFormatResource.ToModel(_specifications);
|
||||
|
||||
@ -60,7 +60,7 @@ public ActionResult<CustomFormatResource> Create(CustomFormatResource customForm
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFormatResource> Update(CustomFormatResource resource)
|
||||
public ActionResult<CustomFormatResource> Update([FromBody] CustomFormatResource resource)
|
||||
{
|
||||
var model = resource.ToModel(_specifications);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public List<EpisodeFileResource> GetEpisodeFiles(int? seriesId, [FromQuery] List
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<EpisodeFileResource> SetQuality(EpisodeFileResource episodeFileResource)
|
||||
public ActionResult<EpisodeFileResource> SetQuality([FromBody] EpisodeFileResource episodeFileResource)
|
||||
{
|
||||
var episodeFile = _mediaFileService.Get(episodeFileResource.Id);
|
||||
episodeFile.Quality = episodeFileResource.Quality;
|
||||
|
@ -49,7 +49,7 @@ public PagingResource<ImportListExclusionResource> GetImportListExclusionsPaged(
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<ImportListExclusionResource> AddImportListExclusion(ImportListExclusionResource resource)
|
||||
public ActionResult<ImportListExclusionResource> AddImportListExclusion([FromBody] ImportListExclusionResource resource)
|
||||
{
|
||||
var importListExclusion = _importListExclusionService.Add(resource.ToModel());
|
||||
|
||||
@ -58,7 +58,7 @@ public ActionResult<ImportListExclusionResource> AddImportListExclusion(ImportLi
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<ImportListExclusionResource> UpdateImportListExclusion(ImportListExclusionResource resource)
|
||||
public ActionResult<ImportListExclusionResource> UpdateImportListExclusion([FromBody] ImportListExclusionResource resource)
|
||||
{
|
||||
_importListExclusionService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
@ -68,7 +68,7 @@ public ReleaseController(IFetchAndParseRss rssFetcherAndParser,
|
||||
|
||||
[HttpPost]
|
||||
[Consumes("application/json")]
|
||||
public async Task<object> DownloadRelease(ReleaseResource release)
|
||||
public async Task<object> DownloadRelease([FromBody] ReleaseResource release)
|
||||
{
|
||||
var remoteEpisode = _remoteEpisodeCache.Find(GetCacheKey(release));
|
||||
|
||||
|
@ -49,7 +49,7 @@ public ReleasePushController(IMakeDownloadDecision downloadDecisionMaker,
|
||||
|
||||
[HttpPost]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<List<ReleaseResource>> Create(ReleaseResource release)
|
||||
public ActionResult<List<ReleaseResource>> Create([FromBody] ReleaseResource release)
|
||||
{
|
||||
_logger.Info("Release pushed: {0} - {1}", release.Title, release.DownloadUrl ?? release.MagnetUrl);
|
||||
|
||||
|
@ -35,7 +35,7 @@ public DelayProfileController(IDelayProfileService delayProfileService, DelayPro
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<DelayProfileResource> Create(DelayProfileResource resource)
|
||||
public ActionResult<DelayProfileResource> Create([FromBody] DelayProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _delayProfileService.Add(model);
|
||||
@ -56,7 +56,7 @@ public void DeleteProfile(int id)
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<DelayProfileResource> Update(DelayProfileResource resource)
|
||||
public ActionResult<DelayProfileResource> Update([FromBody] DelayProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
_delayProfileService.Update(model);
|
||||
@ -76,7 +76,7 @@ public List<DelayProfileResource> GetAll()
|
||||
}
|
||||
|
||||
[HttpPut("reorder/{id}")]
|
||||
public List<DelayProfileResource> Reorder([FromRoute] int id, int? after)
|
||||
public List<DelayProfileResource> Reorder([FromRoute] int id, [FromQuery] int? after)
|
||||
{
|
||||
ValidateId(id);
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class LanguageProfileController : RestController<LanguageProfileResource>
|
||||
[RestPostById]
|
||||
[Produces("application/json")]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<LanguageProfileResource> Create(LanguageProfileResource resource)
|
||||
public ActionResult<LanguageProfileResource> Create([FromBody] LanguageProfileResource resource)
|
||||
{
|
||||
return Accepted(resource);
|
||||
}
|
||||
@ -28,7 +28,7 @@ public void DeleteProfile(int id)
|
||||
[RestPutById]
|
||||
[Produces("application/json")]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<LanguageProfileResource> Update(LanguageProfileResource resource)
|
||||
public ActionResult<LanguageProfileResource> Update([FromBody] LanguageProfileResource resource)
|
||||
{
|
||||
return Accepted(resource);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public QualityProfileController(IQualityProfileService profileService, ICustomFo
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<QualityProfileResource> Create(QualityProfileResource resource)
|
||||
public ActionResult<QualityProfileResource> Create([FromBody] QualityProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _profileService.Add(model);
|
||||
@ -61,7 +61,7 @@ public void DeleteProfile(int id)
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<QualityProfileResource> Update(QualityProfileResource resource)
|
||||
public ActionResult<QualityProfileResource> Update([FromBody] QualityProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
|
||||
|
@ -36,7 +36,7 @@ public ReleaseProfileController(IReleaseProfileService profileService, IIndexerF
|
||||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<ReleaseProfileResource> Create(ReleaseProfileResource resource)
|
||||
public ActionResult<ReleaseProfileResource> Create([FromBody] ReleaseProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _profileService.Add(model);
|
||||
@ -50,7 +50,7 @@ public void DeleteProfile(int id)
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<ReleaseProfileResource> Update(ReleaseProfileResource resource)
|
||||
public ActionResult<ReleaseProfileResource> Update([FromBody] ReleaseProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
|
||||
|
@ -245,7 +245,7 @@ public IActionResult TestAll()
|
||||
[HttpPost("action/{name}")]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
public IActionResult RequestAction(string name, [FromBody] TProviderResource providerResource)
|
||||
public IActionResult RequestAction([FromRoute] string name, [FromBody] TProviderResource providerResource)
|
||||
{
|
||||
var existingDefinition = providerResource.Id > 0 ? _providerFactory.Find(providerResource.Id) : null;
|
||||
var providerDefinition = GetDefinition(providerResource, existingDefinition, false, false, false);
|
||||
|
@ -23,7 +23,7 @@ public QualityDefinitionController(IQualityDefinitionService qualityDefinitionSe
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<QualityDefinitionResource> Update(QualityDefinitionResource resource)
|
||||
public ActionResult<QualityDefinitionResource> Update([FromBody] QualityDefinitionResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
_qualityDefinitionService.Update(model);
|
||||
|
@ -21,7 +21,7 @@ public QueueActionController(IPendingReleaseService pendingReleaseService,
|
||||
}
|
||||
|
||||
[HttpPost("grab/{id:int}")]
|
||||
public async Task<object> Grab(int id)
|
||||
public async Task<object> Grab([FromRoute] int id)
|
||||
{
|
||||
var pendingRelease = _pendingReleaseService.FindPendingQueueItem(id);
|
||||
|
||||
|
@ -41,7 +41,7 @@ protected override RemotePathMappingResource GetResourceById(int id)
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<RemotePathMappingResource> CreateMapping(RemotePathMappingResource resource)
|
||||
public ActionResult<RemotePathMappingResource> CreateMapping([FromBody] RemotePathMappingResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
|
||||
@ -62,7 +62,7 @@ public void DeleteMapping(int id)
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<RemotePathMappingResource> UpdateMapping(RemotePathMappingResource resource)
|
||||
public ActionResult<RemotePathMappingResource> UpdateMapping([FromBody] RemotePathMappingResource resource)
|
||||
{
|
||||
var mapping = resource.ToModel();
|
||||
|
||||
|
@ -50,7 +50,7 @@ protected override RootFolderResource GetResourceById(int id)
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<RootFolderResource> CreateRootFolder(RootFolderResource rootFolderResource)
|
||||
public ActionResult<RootFolderResource> CreateRootFolder([FromBody] RootFolderResource rootFolderResource)
|
||||
{
|
||||
var model = rootFolderResource.ToModel();
|
||||
|
||||
|
@ -19,7 +19,7 @@ public SeasonPassController(ISeriesService seriesService, IEpisodeMonitoredServi
|
||||
|
||||
[HttpPost]
|
||||
[Consumes("application/json")]
|
||||
public IActionResult UpdateAll(SeasonPassResource resource)
|
||||
public IActionResult UpdateAll([FromBody] SeasonPassResource resource)
|
||||
{
|
||||
var seriesToUpdate = _seriesService.GetSeries(resource.Series.Select(s => s.Id));
|
||||
|
||||
|
@ -156,7 +156,7 @@ private SeriesResource GetSeriesResourceById(int id, bool includeSeasonImages =
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<SeriesResource> AddSeries(SeriesResource seriesResource)
|
||||
public ActionResult<SeriesResource> AddSeries([FromBody] SeriesResource seriesResource)
|
||||
{
|
||||
var series = _addSeriesService.AddSeries(seriesResource.ToModel());
|
||||
|
||||
@ -165,7 +165,7 @@ public ActionResult<SeriesResource> AddSeries(SeriesResource seriesResource)
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<SeriesResource> UpdateSeries(SeriesResource seriesResource, bool moveFiles = false)
|
||||
public ActionResult<SeriesResource> UpdateSeries([FromBody] SeriesResource seriesResource, [FromQuery] bool moveFiles = false)
|
||||
{
|
||||
var series = _seriesService.GetSeries(seriesResource.Id);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public void DeleteBackup(int id)
|
||||
}
|
||||
|
||||
[HttpPost("restore/{id:int}")]
|
||||
public object Restore(int id)
|
||||
public object Restore([FromRoute] int id)
|
||||
{
|
||||
var backup = GetBackup(id);
|
||||
|
||||
|
@ -36,14 +36,14 @@ public List<TagResource> GetAll()
|
||||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<TagResource> Create(TagResource resource)
|
||||
public ActionResult<TagResource> Create([FromBody] TagResource resource)
|
||||
{
|
||||
return Created(_tagService.Add(resource.ToModel()).Id);
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<TagResource> Update(TagResource resource)
|
||||
public ActionResult<TagResource> Update([FromBody] TagResource resource)
|
||||
{
|
||||
_tagService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
Loading…
Reference in New Issue
Block a user