Json Parsing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -236,8 +237,26 @@ public class MonitoringController : Controller
|
||||
return BadRequest(new { error = "Invalid Payload", details = errors });
|
||||
}
|
||||
|
||||
// Json zu was brauchbarem machen
|
||||
string containersJson = await dto.Containers.ReadAsStringAsync();
|
||||
List<Container> newContainers = JsonSerializer.Deserialize<List<Container>>(containersJson)?? new List<Container>();;
|
||||
|
||||
foreach (Container c in newContainers)
|
||||
{
|
||||
c.ServerId = dto.Server_id;
|
||||
// Debug Logs
|
||||
// TODO entfernen wenn fertig getestet
|
||||
Console.WriteLine("---------");
|
||||
Console.WriteLine("ServerId: " + c.ServerId);
|
||||
Console.WriteLine("ContainerId: " + c.ContainerId);
|
||||
Console.WriteLine("Name: " + c.Name);
|
||||
Console.WriteLine("Image: " + c.Image);
|
||||
Console.WriteLine("---------");
|
||||
|
||||
}
|
||||
|
||||
// Container Objekte erstellen
|
||||
List<Container> newContainers = ParseServiceDiscoveryInput(dto.Server_id, dto.Containers);
|
||||
//List<Container> newContainers = ParseServiceDiscoveryInput(dto.Server_id, containers);
|
||||
|
||||
// Liste aller Container, die bereits der übergebenen ServerId zugewiesen sind
|
||||
List<Container> existingContainers = _context.Containers
|
||||
@@ -391,7 +410,7 @@ public class MonitoringController : Controller
|
||||
return metric_input;
|
||||
}
|
||||
|
||||
private List<Container> ParseServiceDiscoveryInput(int server_id, JsonContent containers)
|
||||
private List<Container> ParseServiceDiscoveryInput(int server_id, List<Container> containers)
|
||||
{
|
||||
List<Container> containerList = new List<Container>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user