diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index dbe7f0c..903a425 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -44,14 +44,25 @@ namespace ManagerService.Controllers /// Get a list of all resources (summary) /// /// id instance + /// types of resource [ProducesResponseType(typeof(List), 200)] [ProducesResponseType(typeof(string), 500)] [HttpGet] - public ObjectResult Get([FromQuery] string instanceId) + public ObjectResult Get([FromQuery] string instanceId, [FromQuery] List types) { try { - List resources = _resourceService.GetAll(instanceId); + if (instanceId == null) + throw new ArgumentNullException("InstanceId needed"); + List resources = new List(); + if (types.Count > 0) + { + resources = _resourceService.GetAllByType(instanceId, types); + } + else + { + resources = _resourceService.GetAll(instanceId); + } List resourceDTOs = new List(); foreach(var resource in resources) diff --git a/ManagerService/Services/ResourceDatabaseService.cs b/ManagerService/Services/ResourceDatabaseService.cs index e1f062e..7264a35 100644 --- a/ManagerService/Services/ResourceDatabaseService.cs +++ b/ManagerService/Services/ResourceDatabaseService.cs @@ -23,9 +23,9 @@ namespace Manager.Services return _Resources.Find(r => r.InstanceId == instanceId).ToList(); } - public Resource GetByType(ResourceType type) + public List GetAllByType(string instanceId, List types) { - return _Resources.Find(r => r.Type == type).FirstOrDefault(); + return _Resources.Find(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList(); } public Resource GetById(string id)