|
|
@ -86,21 +86,23 @@ namespace Jellyfin.Api.Controllers
|
|
|
|
/// Updates named configuration.
|
|
|
|
/// Updates named configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="key">Configuration key.</param>
|
|
|
|
/// <param name="key">Configuration key.</param>
|
|
|
|
|
|
|
|
/// <param name="configuration">Configuration.</param>
|
|
|
|
/// <response code="204">Named configuration updated.</response>
|
|
|
|
/// <response code="204">Named configuration updated.</response>
|
|
|
|
/// <returns>Update status.</returns>
|
|
|
|
/// <returns>Update status.</returns>
|
|
|
|
[HttpPost("Configuration/{key}")]
|
|
|
|
[HttpPost("Configuration/{key}")]
|
|
|
|
[Authorize(Policy = Policies.RequiresElevation)]
|
|
|
|
[Authorize(Policy = Policies.RequiresElevation)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public async Task<ActionResult> UpdateNamedConfiguration([FromRoute, Required] string key)
|
|
|
|
public ActionResult UpdateNamedConfiguration([FromRoute, Required] string key, [FromBody, Required] JsonDocument configuration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var configurationType = _configurationManager.GetConfigurationType(key);
|
|
|
|
var configurationType = _configurationManager.GetConfigurationType(key);
|
|
|
|
var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType, _serializerOptions).ConfigureAwait(false);
|
|
|
|
var deserializedConfiguration = configuration.Deserialize(configurationType, _serializerOptions);
|
|
|
|
if (configuration == null)
|
|
|
|
|
|
|
|
|
|
|
|
if (deserializedConfiguration == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new ArgumentException("Body doesn't contain a valid configuration");
|
|
|
|
throw new ArgumentException("Body doesn't contain a valid configuration");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_configurationManager.SaveConfiguration(key, configuration);
|
|
|
|
_configurationManager.SaveConfiguration(key, deserializedConfiguration);
|
|
|
|
return NoContent();
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|