Update get ressources endpoint by adding types filter
This commit is contained in:
parent
5b56c677ef
commit
3e6439433e
@ -44,14 +44,25 @@ namespace ManagerService.Controllers
|
||||
/// Get a list of all resources (summary)
|
||||
/// </summary>
|
||||
/// <param name="id">id instance</param>
|
||||
/// <param name="types">types of resource</param>
|
||||
[ProducesResponseType(typeof(List<ResourceDTO>), 200)]
|
||||
[ProducesResponseType(typeof(string), 500)]
|
||||
[HttpGet]
|
||||
public ObjectResult Get([FromQuery] string instanceId)
|
||||
public ObjectResult Get([FromQuery] string instanceId, [FromQuery] List<ResourceType> types)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Resource> resources = _resourceService.GetAll(instanceId);
|
||||
if (instanceId == null)
|
||||
throw new ArgumentNullException("InstanceId needed");
|
||||
List<Resource> resources = new List<Resource>();
|
||||
if (types.Count > 0)
|
||||
{
|
||||
resources = _resourceService.GetAllByType(instanceId, types);
|
||||
}
|
||||
else
|
||||
{
|
||||
resources = _resourceService.GetAll(instanceId);
|
||||
}
|
||||
|
||||
List<ResourceDTO> resourceDTOs = new List<ResourceDTO>();
|
||||
foreach(var resource in resources)
|
||||
|
||||
@ -23,9 +23,9 @@ namespace Manager.Services
|
||||
return _Resources.Find(r => r.InstanceId == instanceId).ToList();
|
||||
}
|
||||
|
||||
public Resource GetByType(ResourceType type)
|
||||
public List<Resource> GetAllByType(string instanceId, List<ResourceType> types)
|
||||
{
|
||||
return _Resources.Find<Resource>(r => r.Type == type).FirstOrDefault();
|
||||
return _Resources.Find<Resource>(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList();
|
||||
}
|
||||
|
||||
public Resource GetById(string id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user