|
|
@ -37,12 +37,24 @@ namespace NzbDrone.Api.REST
|
|
|
|
protected RestModule(string modulePath)
|
|
|
|
protected RestModule(string modulePath)
|
|
|
|
: base(modulePath)
|
|
|
|
: base(modulePath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
ValidateModule();
|
|
|
|
|
|
|
|
|
|
|
|
PostValidator = new ResourceValidator<TResource>();
|
|
|
|
PostValidator = new ResourceValidator<TResource>();
|
|
|
|
PutValidator = new ResourceValidator<TResource>();
|
|
|
|
PutValidator = new ResourceValidator<TResource>();
|
|
|
|
SharedValidator = new ResourceValidator<TResource>();
|
|
|
|
SharedValidator = new ResourceValidator<TResource>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ValidateModule()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (GetResourceById != null) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CreateResource != null || UpdateResource != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new InvalidOperationException("GetResourceById route must be defined before defining Create/Update routes.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected Action<int> DeleteResource
|
|
|
|
protected Action<int> DeleteResource
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private get { return _deleteResource; }
|
|
|
|
private get { return _deleteResource; }
|
|
|
@ -137,7 +149,6 @@ namespace NzbDrone.Api.REST
|
|
|
|
private get { return _createResource; }
|
|
|
|
private get { return _createResource; }
|
|
|
|
set
|
|
|
|
set
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EnsureGetByIdRoute();
|
|
|
|
|
|
|
|
_createResource = value;
|
|
|
|
_createResource = value;
|
|
|
|
Post[ROOT_ROUTE] = options =>
|
|
|
|
Post[ROOT_ROUTE] = options =>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -148,15 +159,6 @@ namespace NzbDrone.Api.REST
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EnsureGetByIdRoute()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (GetResourceById == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new InvalidOperationException(
|
|
|
|
|
|
|
|
"GetResourceById route must be defined before defining Create/Update routes.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Action<TResource> UpdateResource
|
|
|
|
protected Action<TResource> UpdateResource
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private get { return _updateResource; }
|
|
|
|
private get { return _updateResource; }
|
|
|
|