mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add endpoint to get gpus by machine.
This commit is contained in:
@@ -20,27 +20,27 @@ namespace Marechai.App.Gpus
|
|||||||
{
|
{
|
||||||
/// <summary>Gets an item from the Marechai.App.gpus.item collection</summary>
|
/// <summary>Gets an item from the Marechai.App.gpus.item collection</summary>
|
||||||
/// <param name="position">Unique identifier of the item</param>
|
/// <param name="position">Unique identifier of the item</param>
|
||||||
/// <returns>A <see cref="global::Marechai.App.Gpus.Item.GpusItemRequestBuilder"/></returns>
|
/// <returns>A <see cref="global::Marechai.App.Gpus.Item.GpuItemRequestBuilder"/></returns>
|
||||||
public global::Marechai.App.Gpus.Item.GpusItemRequestBuilder this[int position]
|
public global::Marechai.App.Gpus.Item.GpuItemRequestBuilder this[int position]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
urlTplParams.Add("id", position);
|
urlTplParams.Add("gpu%2Did", position);
|
||||||
return new global::Marechai.App.Gpus.Item.GpusItemRequestBuilder(urlTplParams, RequestAdapter);
|
return new global::Marechai.App.Gpus.Item.GpuItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>Gets an item from the Marechai.App.gpus.item collection</summary>
|
/// <summary>Gets an item from the Marechai.App.gpus.item collection</summary>
|
||||||
/// <param name="position">Unique identifier of the item</param>
|
/// <param name="position">Unique identifier of the item</param>
|
||||||
/// <returns>A <see cref="global::Marechai.App.Gpus.Item.GpusItemRequestBuilder"/></returns>
|
/// <returns>A <see cref="global::Marechai.App.Gpus.Item.GpuItemRequestBuilder"/></returns>
|
||||||
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
|
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
|
||||||
public global::Marechai.App.Gpus.Item.GpusItemRequestBuilder this[string position]
|
public global::Marechai.App.Gpus.Item.GpuItemRequestBuilder this[string position]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("id", position);
|
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("gpu%2Did", position);
|
||||||
return new global::Marechai.App.Gpus.Item.GpusItemRequestBuilder(urlTplParams, RequestAdapter);
|
return new global::Marechai.App.Gpus.Item.GpuItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,27 +17,27 @@ namespace Marechai.App.ResolutionsByGpu.Gpus
|
|||||||
{
|
{
|
||||||
/// <summary>Gets an item from the Marechai.App.resolutionsByGpu.gpus.item collection</summary>
|
/// <summary>Gets an item from the Marechai.App.resolutionsByGpu.gpus.item collection</summary>
|
||||||
/// <param name="position">Unique identifier of the item</param>
|
/// <param name="position">Unique identifier of the item</param>
|
||||||
/// <returns>A <see cref="global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithResolutionItemRequestBuilder"/></returns>
|
/// <returns>A <see cref="global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithGpuItemRequestBuilder"/></returns>
|
||||||
public global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithResolutionItemRequestBuilder this[int position]
|
public global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithGpuItemRequestBuilder this[int position]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
urlTplParams.Add("resolutionId", position);
|
urlTplParams.Add("gpuId", position);
|
||||||
return new global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithResolutionItemRequestBuilder(urlTplParams, RequestAdapter);
|
return new global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithGpuItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>Gets an item from the Marechai.App.resolutionsByGpu.gpus.item collection</summary>
|
/// <summary>Gets an item from the Marechai.App.resolutionsByGpu.gpus.item collection</summary>
|
||||||
/// <param name="position">Unique identifier of the item</param>
|
/// <param name="position">Unique identifier of the item</param>
|
||||||
/// <returns>A <see cref="global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithResolutionItemRequestBuilder"/></returns>
|
/// <returns>A <see cref="global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithGpuItemRequestBuilder"/></returns>
|
||||||
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
|
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
|
||||||
public global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithResolutionItemRequestBuilder this[string position]
|
public global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithGpuItemRequestBuilder this[string position]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("resolutionId", position);
|
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("gpuId", position);
|
||||||
return new global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithResolutionItemRequestBuilder(urlTplParams, RequestAdapter);
|
return new global::Marechai.App.ResolutionsByGpu.Gpus.Item.WithGpuItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -82,6 +82,27 @@ public class GpusController(MarechaiContext context) : ControllerBase
|
|||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
[HttpGet("{gpuId:int}/machines")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
public Task<List<MachineDto>> GetMachinesByGpuAsync(int gpuId) => context.GpusByMachine.Where(g => g.GpuId == gpuId)
|
||||||
|
.Select(g => g.Machine)
|
||||||
|
.OrderBy(m => m.Company.Name)
|
||||||
|
.ThenBy(m => m.Name)
|
||||||
|
.Select(m => new MachineDto
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
Company = m.Company.Name,
|
||||||
|
CompanyId = m.Company.Id,
|
||||||
|
Name = m.Name,
|
||||||
|
Model = m.Model,
|
||||||
|
Introduced = m.Introduced,
|
||||||
|
Type = m.Type,
|
||||||
|
FamilyId = m.FamilyId
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("{id:int}")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
|||||||
Reference in New Issue
Block a user