Skip to content

Commit

Permalink
Deprecate API v1 - API v1.1 is now default (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-j-green authored Dec 19, 2024
1 parent 98a09c3 commit 9922e61
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 49 deletions.
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
public class AccountController : Controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize(Roles = "Admin,Gamer,Player")]
public class BackgroundTasksController : Controller
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/BiosController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
public class BiosController : Controller
Expand Down
16 changes: 8 additions & 8 deletions gaseous-server/Controllers/V1.0/CollectionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
public class CollectionsController : Controller
Expand All @@ -29,7 +29,7 @@ public CollectionsController(
_userManager = userManager;
_signInManager = signInManager;
}

/// <summary>
/// Gets all ROM collections
/// </summary>
Expand Down Expand Up @@ -145,7 +145,7 @@ public async Task<ActionResult> GetCollectionRomsPreview(Classes.Collections.Col
}
catch (Exception ex)
{
return NotFound(ex);
return NotFound(ex);
}
}
else
Expand Down Expand Up @@ -212,7 +212,7 @@ public async Task<ActionResult> GetCollectionRomsZip(long CollectionId)
public async Task<ActionResult> NewCollectionAsync(Classes.Collections.CollectionItem Item)
{
var user = await _userManager.GetUserAsync(User);

if (user != null)
{
try
Expand Down Expand Up @@ -246,7 +246,7 @@ public async Task<ActionResult> NewCollectionAsync(Classes.Collections.Collectio
public async Task<ActionResult> EditCollection(long CollectionId, Classes.Collections.CollectionItem Item)
{
var user = await _userManager.GetUserAsync(User);

if (user != null)
{
try
Expand Down Expand Up @@ -277,10 +277,10 @@ public async Task<ActionResult> EditCollection(long CollectionId, Classes.Collec
[Route("{CollectionId}/AlwaysInclude")]
[ProducesResponseType(typeof(Classes.Collections.CollectionItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> EditCollectionAlwaysInclude(long CollectionId, [FromQuery]bool Rebuild, [FromBody]Collections.CollectionItem.AlwaysIncludeItem Inclusion)
public async Task<ActionResult> EditCollectionAlwaysInclude(long CollectionId, [FromQuery] bool Rebuild, [FromBody] Collections.CollectionItem.AlwaysIncludeItem Inclusion)
{
var user = await _userManager.GetUserAsync(User);

if (user != null)
{
try
Expand Down Expand Up @@ -326,7 +326,7 @@ public async Task<ActionResult> EditCollectionAlwaysInclude(long CollectionId, [
public async Task<ActionResult> DeleteCollection(long CollectionId)
{
var user = await _userManager.GetUserAsync(User);

if (user != null)
{
try
Expand Down
6 changes: 3 additions & 3 deletions gaseous-server/Controllers/V1.0/FilterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
namespace gaseous_server.Controllers
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
[ApiController]
public class FilterController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;

public FilterController(
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager)
Expand All @@ -40,7 +40,7 @@ public FilterController(
public async Task<IActionResult> FilterAsync()
{
var user = await _userManager.GetUserAsync(User);

return Ok(Filters.Filter(user.SecurityProfile.AgeRestrictionPolicy.MaximumAgeRestriction, user.SecurityProfile.AgeRestrictionPolicy.IncludeUnrated));
}
}
Expand Down
44 changes: 24 additions & 20 deletions gaseous-server/Controllers/V1.0/GamesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
namespace gaseous_server.Controllers
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
[ApiController]
public class GamesController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;

public GamesController(
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager
Expand All @@ -53,7 +53,7 @@ public async Task<ActionResult> Game(
int minrating = -1,
int maxrating = -1,
bool sortdescending = false)
{
{

return Ok(GetGames(name, platform, genre, gamemode, playerperspective, theme, minrating, maxrating, "Adult", true, true, sortdescending));
}
Expand Down Expand Up @@ -473,14 +473,15 @@ public async Task<ActionResult> GameCoverImage(long GameId, long ArtworkId, Comm
try
{
IGDB.Models.Artwork artworkObject = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), true);

if (artworkObject != null) {

if (artworkObject != null)
{
//string coverFilePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork", size.ToString(), artworkObject.ImageId + ".jpg");

string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Artwork");

Communications comms = new Communications();
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, artworkObject.ImageId, size, new List<Communications.IGDBAPI_ImageSize>{ Communications.IGDBAPI_ImageSize.original });
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, artworkObject.ImageId, size, new List<Communications.IGDBAPI_ImageSize> { Communications.IGDBAPI_ImageSize.original });

string coverFilePath = ImgFetch.Result;

Expand Down Expand Up @@ -578,13 +579,14 @@ public async Task<ActionResult> GameCoverImage(long GameId, Communications.IGDBA
{
IGDB.Models.Cover cover = Classes.Metadata.Covers.GetCover(gameObject.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Covers");

Communications comms = new Communications();
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, cover.ImageId, size, new List<Communications.IGDBAPI_ImageSize>{ Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original });
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, cover.ImageId, size, new List<Communications.IGDBAPI_ImageSize> { Communications.IGDBAPI_ImageSize.cover_big, Communications.IGDBAPI_ImageSize.original });

string coverFilePath = ImgFetch.Result;

if (System.IO.File.Exists(coverFilePath)) {
if (System.IO.File.Exists(coverFilePath))
{
string filename = cover.ImageId + ".jpg";
string filepath = coverFilePath;
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
Expand Down Expand Up @@ -627,7 +629,7 @@ public async Task<ActionResult> GameGetFavouriteAsync(long GameId)
if (gameObject != null)
{
var user = await _userManager.GetUserAsync(User);

if (user != null)
{
Favourites favourites = new Favourites();
Expand Down Expand Up @@ -664,7 +666,7 @@ public async Task<ActionResult> GameSetFavouriteAsync(long GameId, bool favourit
if (gameObject != null)
{
var user = await _userManager.GetUserAsync(User);

if (user != null)
{
Favourites favourites = new Favourites();
Expand Down Expand Up @@ -796,7 +798,8 @@ public async Task<ActionResult> GameInvolvedCompanies(long GameId, long CompanyI
companyData.Add("company", company);

return Ok(companyData);
} else
}
else
{
return NotFound();
}
Expand Down Expand Up @@ -895,7 +898,7 @@ public async Task<ActionResult> GameReleaseDates(long GameId)
foreach (long icId in gameObject.ReleaseDates.Ids)
{
ReleaseDate releaseDate = Classes.Metadata.ReleaseDates.GetReleaseDates(icId);

rdObjects.Add(releaseDate);
}
}
Expand Down Expand Up @@ -923,7 +926,7 @@ public async Task<ActionResult> GameReleaseDates(long GameId)
public async Task<ActionResult> GameRomAsync(long GameId, int pageNumber = 0, int pageSize = 0, long PlatformId = -1, string NameSearch = "")
{
var user = await _userManager.GetUserAsync(User);

try
{
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
Expand Down Expand Up @@ -1113,7 +1116,7 @@ public async Task<ActionResult> GameRomFile(long GameId, long RomId, string File
public async Task<ActionResult> GameRomGroupAsync(long GameId, long RomGroupId)
{
var user = await _userManager.GetUserAsync(User);

try
{
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
Expand Down Expand Up @@ -1144,7 +1147,7 @@ public async Task<ActionResult> GameRomGroupAsync(long GameId, long RomGroupId)
public async Task<ActionResult> GetGameRomGroupAsync(long GameId)
{
var user = await _userManager.GetUserAsync(User);

try
{
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
Expand Down Expand Up @@ -1204,7 +1207,7 @@ public async Task<ActionResult> NewGameRomGroup(long GameId, long PlatformId, [F
public async Task<ActionResult> GameRomGroupMembersAsync(long GameId, long RomGroupId, [FromBody] List<long> RomIds)
{
var user = await _userManager.GetUserAsync(User);

try
{
Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
Expand Down Expand Up @@ -1386,9 +1389,10 @@ public async Task<ActionResult> GameScreenshot(long GameId)
public async Task<ActionResult> GameScreenshot(long GameId, long ScreenshotId)
{
try
{
{
IGDB.Models.Game gameObject = Classes.Metadata.Games.GetGame(GameId, false, false, false);
if (gameObject != null) {
if (gameObject != null)
{
IGDB.Models.Screenshot screenshotObject = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), false);
if (screenshotObject != null)
{
Expand Down Expand Up @@ -1428,7 +1432,7 @@ public async Task<ActionResult> GameScreenshotImage(long GameId, long Screenshot
string basePath = Path.Combine(Config.LibraryConfiguration.LibraryMetadataDirectory_Game(gameObject), "Screenshots");

Communications comms = new Communications();
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, screenshotObject.ImageId, Size, new List<Communications.IGDBAPI_ImageSize>{ Communications.IGDBAPI_ImageSize.original });
Task<string> ImgFetch = comms.GetSpecificImageFromServer(basePath, screenshotObject.ImageId, Size, new List<Communications.IGDBAPI_ImageSize> { Communications.IGDBAPI_ImageSize.original });

string coverFilePath = ImgFetch.Result;

Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/LibraryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize(Roles = "Admin")]
public class LibraryController : Controller
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/LogsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize(Roles = "Admin")]
public class LogsController : Controller
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/PlatformMapsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace gaseous_server.Controllers
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[ApiController]
[Authorize]
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/PlatformsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace gaseous_server.Controllers
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
[ApiController]
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/RomsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace gaseous_server.Controllers
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
[ApiController]
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
public class SearchController : Controller
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/SignaturesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
public class SignaturesController : Controller
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.0/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace gaseous_server.Controllers
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[Authorize]
public class SystemController : Controller
Expand Down
2 changes: 1 addition & 1 deletion gaseous-server/Controllers/V1.1/StateManagerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace gaseous_server.Controllers.v1_1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[ApiController]
public class StateManagerController : ControllerBase
Expand Down
4 changes: 2 additions & 2 deletions gaseous-server/Controllers/V1.1/StatisticsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace gaseous_server.Controllers.v1_1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("1.1")]
[ApiController]
public class StatisticsController: ControllerBase
public class StatisticsController : ControllerBase
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
Expand Down
Loading

0 comments on commit 9922e61

Please sign in to comment.