Merge pull request #3319 from Ullmie02/api-204

Use Http status code 204 instead of 200
pull/3340/head
dkanada 4 years ago committed by GitHub
commit e2b2f74b47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -53,15 +53,15 @@ namespace Jellyfin.Api.Controllers
/// Updates application configuration. /// Updates application configuration.
/// </summary> /// </summary>
/// <param name="configuration">Configuration.</param> /// <param name="configuration">Configuration.</param>
/// <response code="200">Configuration updated.</response> /// <response code="204">Configuration updated.</response>
/// <returns>Update status.</returns> /// <returns>Update status.</returns>
[HttpPost("Configuration")] [HttpPost("Configuration")]
[Authorize(Policy = Policies.RequiresElevation)] [Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult UpdateConfiguration([FromBody, BindRequired] ServerConfiguration configuration) public ActionResult UpdateConfiguration([FromBody, BindRequired] ServerConfiguration configuration)
{ {
_configurationManager.ReplaceConfiguration(configuration); _configurationManager.ReplaceConfiguration(configuration);
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -81,17 +81,17 @@ namespace Jellyfin.Api.Controllers
/// Updates named configuration. /// Updates named configuration.
/// </summary> /// </summary>
/// <param name="key">Configuration key.</param> /// <param name="key">Configuration key.</param>
/// <response code="200">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.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<ActionResult> UpdateNamedConfiguration([FromRoute] string key) public async Task<ActionResult> UpdateNamedConfiguration([FromRoute] string key)
{ {
var configurationType = _configurationManager.GetConfigurationType(key); var configurationType = _configurationManager.GetConfigurationType(key);
var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType).ConfigureAwait(false); var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType).ConfigureAwait(false);
_configurationManager.SaveConfiguration(key, configuration); _configurationManager.SaveConfiguration(key, configuration);
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -111,15 +111,15 @@ namespace Jellyfin.Api.Controllers
/// Updates the path to the media encoder. /// Updates the path to the media encoder.
/// </summary> /// </summary>
/// <param name="mediaEncoderPath">Media encoder path form body.</param> /// <param name="mediaEncoderPath">Media encoder path form body.</param>
/// <response code="200">Media encoder path updated.</response> /// <response code="204">Media encoder path updated.</response>
/// <returns>Status.</returns> /// <returns>Status.</returns>
[HttpPost("MediaEncoder/Path")] [HttpPost("MediaEncoder/Path")]
[Authorize(Policy = Policies.FirstTimeSetupOrElevated)] [Authorize(Policy = Policies.FirstTimeSetupOrElevated)]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult UpdateMediaEncoderPath([FromForm, BindRequired] MediaEncoderPathDto mediaEncoderPath) public ActionResult UpdateMediaEncoderPath([FromForm, BindRequired] MediaEncoderPathDto mediaEncoderPath)
{ {
_mediaEncoder.UpdateEncoderPath(mediaEncoderPath.Path, mediaEncoderPath.PathType); _mediaEncoder.UpdateEncoderPath(mediaEncoderPath.Path, mediaEncoderPath.PathType);
return Ok(); return NoContent();
} }
} }
} }

@ -105,12 +105,12 @@ namespace Jellyfin.Api.Controllers
/// </summary> /// </summary>
/// <param name="id">Device Id.</param> /// <param name="id">Device Id.</param>
/// <param name="deviceOptions">Device Options.</param> /// <param name="deviceOptions">Device Options.</param>
/// <response code="200">Device options updated.</response> /// <response code="204">Device options updated.</response>
/// <response code="404">Device not found.</response> /// <response code="404">Device not found.</response>
/// <returns>An <see cref="OkResult"/> on success, or a <see cref="NotFoundResult"/> if the device could not be found.</returns> /// <returns>A <see cref="NoContentResult"/> on success, or a <see cref="NotFoundResult"/> if the device could not be found.</returns>
[HttpPost("Options")] [HttpPost("Options")]
[Authorize(Policy = Policies.RequiresElevation)] [Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult UpdateDeviceOptions( public ActionResult UpdateDeviceOptions(
[FromQuery, BindRequired] string id, [FromQuery, BindRequired] string id,
@ -123,18 +123,18 @@ namespace Jellyfin.Api.Controllers
} }
_deviceManager.UpdateDeviceOptions(id, deviceOptions); _deviceManager.UpdateDeviceOptions(id, deviceOptions);
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
/// Deletes a device. /// Deletes a device.
/// </summary> /// </summary>
/// <param name="id">Device Id.</param> /// <param name="id">Device Id.</param>
/// <response code="200">Device deleted.</response> /// <response code="204">Device deleted.</response>
/// <response code="404">Device not found.</response> /// <response code="404">Device not found.</response>
/// <returns>An <see cref="OkResult"/> on success, or a <see cref="NotFoundResult"/> if the device could not be found.</returns> /// <returns>A <see cref="NoContentResult"/> on success, or a <see cref="NotFoundResult"/> if the device could not be found.</returns>
[HttpDelete] [HttpDelete]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult DeleteDevice([FromQuery, BindRequired] string id) public ActionResult DeleteDevice([FromQuery, BindRequired] string id)
{ {
var existingDevice = _deviceManager.GetDevice(id); var existingDevice = _deviceManager.GetDevice(id);
@ -150,7 +150,7 @@ namespace Jellyfin.Api.Controllers
_sessionManager.Logout(session); _sessionManager.Logout(session);
} }
return Ok(); return NoContent();
} }
} }
} }

@ -99,10 +99,10 @@ namespace Jellyfin.Api.Controllers
/// <param name="description">The description of the notification.</param> /// <param name="description">The description of the notification.</param>
/// <param name="url">The URL of the notification.</param> /// <param name="url">The URL of the notification.</param>
/// <param name="level">The level of the notification.</param> /// <param name="level">The level of the notification.</param>
/// <response code="200">Notification sent.</response> /// <response code="204">Notification sent.</response>
/// <returns>An <cref see="OkResult"/>.</returns> /// <returns>A <cref see="NoContentResult"/>.</returns>
[HttpPost("Admin")] [HttpPost("Admin")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult CreateAdminNotification( public ActionResult CreateAdminNotification(
[FromQuery] string name, [FromQuery] string name,
[FromQuery] string description, [FromQuery] string description,
@ -121,7 +121,7 @@ namespace Jellyfin.Api.Controllers
_notificationManager.SendNotification(notification, CancellationToken.None); _notificationManager.SendNotification(notification, CancellationToken.None);
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -129,15 +129,15 @@ namespace Jellyfin.Api.Controllers
/// </summary> /// </summary>
/// <param name="userId">The userID.</param> /// <param name="userId">The userID.</param>
/// <param name="ids">A comma-separated list of the IDs of notifications which should be set as read.</param> /// <param name="ids">A comma-separated list of the IDs of notifications which should be set as read.</param>
/// <response code="200">Notifications set as read.</response> /// <response code="204">Notifications set as read.</response>
/// <returns>An <cref see="OkResult"/>.</returns> /// <returns>A <cref see="NoContentResult"/>.</returns>
[HttpPost("{UserID}/Read")] [HttpPost("{UserID}/Read")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult SetRead( public ActionResult SetRead(
[FromRoute] string userId, [FromRoute] string userId,
[FromQuery] string ids) [FromQuery] string ids)
{ {
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -145,15 +145,15 @@ namespace Jellyfin.Api.Controllers
/// </summary> /// </summary>
/// <param name="userId">The userID.</param> /// <param name="userId">The userID.</param>
/// <param name="ids">A comma-separated list of the IDs of notifications which should be set as unread.</param> /// <param name="ids">A comma-separated list of the IDs of notifications which should be set as unread.</param>
/// <response code="200">Notifications set as unread.</response> /// <response code="204">Notifications set as unread.</response>
/// <returns>An <cref see="OkResult"/>.</returns> /// <returns>A <cref see="NoContentResult"/>.</returns>
[HttpPost("{UserID}/Unread")] [HttpPost("{UserID}/Unread")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult SetUnread( public ActionResult SetUnread(
[FromRoute] string userId, [FromRoute] string userId,
[FromQuery] string ids) [FromQuery] string ids)
{ {
return Ok(); return NoContent();
} }
} }
} }

@ -72,11 +72,11 @@ namespace Jellyfin.Api.Controllers
/// <param name="name">Package name.</param> /// <param name="name">Package name.</param>
/// <param name="assemblyGuid">GUID of the associated assembly.</param> /// <param name="assemblyGuid">GUID of the associated assembly.</param>
/// <param name="version">Optional version. Defaults to latest version.</param> /// <param name="version">Optional version. Defaults to latest version.</param>
/// <response code="200">Package found.</response> /// <response code="204">Package found.</response>
/// <response code="404">Package not found.</response> /// <response code="404">Package not found.</response>
/// <returns>An <see cref="OkResult"/> on success, or a <see cref="NotFoundResult"/> if the package could not be found.</returns> /// <returns>A <see cref="NoContentResult"/> on success, or a <see cref="NotFoundResult"/> if the package could not be found.</returns>
[HttpPost("/Installed/{Name}")] [HttpPost("/Installed/{Name}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.RequiresElevation)] [Authorize(Policy = Policies.RequiresElevation)]
public async Task<ActionResult> InstallPackage( public async Task<ActionResult> InstallPackage(
@ -98,23 +98,24 @@ namespace Jellyfin.Api.Controllers
await _installationManager.InstallPackage(package).ConfigureAwait(false); await _installationManager.InstallPackage(package).ConfigureAwait(false);
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
/// Cancels a package installation. /// Cancels a package installation.
/// </summary> /// </summary>
/// <param name="id">Installation Id.</param> /// <param name="id">Installation Id.</param>
/// <response code="200">Installation cancelled.</response> /// <response code="204">Installation cancelled.</response>
/// <returns>An <see cref="OkResult"/> on successfully cancelling a package installation.</returns> /// <returns>A <see cref="NoContentResult"/> on successfully cancelling a package installation.</returns>
[HttpDelete("/Installing/{id}")] [HttpDelete("/Installing/{id}")]
[Authorize(Policy = Policies.RequiresElevation)] [Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public IActionResult CancelPackageInstallation( public IActionResult CancelPackageInstallation(
[FromRoute] [Required] string id) [FromRoute] [Required] string id)
{ {
_installationManager.CancelInstallation(new Guid(id)); _installationManager.CancelInstallation(new Guid(id));
return Ok(); return NoContent();
} }
} }
} }

@ -33,16 +33,16 @@ namespace Jellyfin.Api.Controllers
/// <summary> /// <summary>
/// Completes the startup wizard. /// Completes the startup wizard.
/// </summary> /// </summary>
/// <response code="200">Startup wizard completed.</response> /// <response code="204">Startup wizard completed.</response>
/// <returns>An <see cref="OkResult"/> indicating success.</returns> /// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
[HttpPost("Complete")] [HttpPost("Complete")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult CompleteWizard() public ActionResult CompleteWizard()
{ {
_config.Configuration.IsStartupWizardCompleted = true; _config.Configuration.IsStartupWizardCompleted = true;
_config.SetOptimalValues(); _config.SetOptimalValues();
_config.SaveConfiguration(); _config.SaveConfiguration();
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -70,10 +70,10 @@ namespace Jellyfin.Api.Controllers
/// <param name="uiCulture">The UI language culture.</param> /// <param name="uiCulture">The UI language culture.</param>
/// <param name="metadataCountryCode">The metadata country code.</param> /// <param name="metadataCountryCode">The metadata country code.</param>
/// <param name="preferredMetadataLanguage">The preferred language for metadata.</param> /// <param name="preferredMetadataLanguage">The preferred language for metadata.</param>
/// <response code="200">Configuration saved.</response> /// <response code="204">Configuration saved.</response>
/// <returns>An <see cref="OkResult"/> indicating success.</returns> /// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
[HttpPost("Configuration")] [HttpPost("Configuration")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult UpdateInitialConfiguration( public ActionResult UpdateInitialConfiguration(
[FromForm] string uiCulture, [FromForm] string uiCulture,
[FromForm] string metadataCountryCode, [FromForm] string metadataCountryCode,
@ -83,7 +83,7 @@ namespace Jellyfin.Api.Controllers
_config.Configuration.MetadataCountryCode = metadataCountryCode; _config.Configuration.MetadataCountryCode = metadataCountryCode;
_config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage; _config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage;
_config.SaveConfiguration(); _config.SaveConfiguration();
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -91,16 +91,16 @@ namespace Jellyfin.Api.Controllers
/// </summary> /// </summary>
/// <param name="enableRemoteAccess">Enable remote access.</param> /// <param name="enableRemoteAccess">Enable remote access.</param>
/// <param name="enableAutomaticPortMapping">Enable UPnP.</param> /// <param name="enableAutomaticPortMapping">Enable UPnP.</param>
/// <response code="200">Configuration saved.</response> /// <response code="204">Configuration saved.</response>
/// <returns>An <see cref="OkResult"/> indicating success.</returns> /// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
[HttpPost("RemoteAccess")] [HttpPost("RemoteAccess")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) public ActionResult SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping)
{ {
_config.Configuration.EnableRemoteAccess = enableRemoteAccess; _config.Configuration.EnableRemoteAccess = enableRemoteAccess;
_config.Configuration.EnableUPnP = enableAutomaticPortMapping; _config.Configuration.EnableUPnP = enableAutomaticPortMapping;
_config.SaveConfiguration(); _config.SaveConfiguration();
return Ok(); return NoContent();
} }
/// <summary> /// <summary>
@ -121,13 +121,13 @@ namespace Jellyfin.Api.Controllers
/// Sets the user name and password. /// Sets the user name and password.
/// </summary> /// </summary>
/// <param name="startupUserDto">The DTO containing username and password.</param> /// <param name="startupUserDto">The DTO containing username and password.</param>
/// <response code="200">Updated user name and password.</response> /// <response code="204">Updated user name and password.</response>
/// <returns> /// <returns>
/// A <see cref="Task" /> that represents the asynchronous update operation. /// A <see cref="Task" /> that represents the asynchronous update operation.
/// The task result contains an <see cref="OkResult"/> indicating success. /// The task result contains a <see cref="NoContentResult"/> indicating success.
/// </returns> /// </returns>
[HttpPost("User")] [HttpPost("User")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<ActionResult> UpdateUser([FromForm] StartupUserDto startupUserDto) public async Task<ActionResult> UpdateUser([FromForm] StartupUserDto startupUserDto)
{ {
var user = _userManager.Users.First(); var user = _userManager.Users.First();
@ -141,7 +141,7 @@ namespace Jellyfin.Api.Controllers
await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false); await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false);
} }
return Ok(); return NoContent();
} }
} }
} }

Loading…
Cancel
Save