1, 'apikey' => bin2hex(random_bytes(16)) ]; return new JsonResponse($data, Response::HTTP_OK); } #[Route('/opengnsys/rest//ous', methods: ['GET'])] public function getOUs(Request $request): JsonResponse { $organizationalUnits = $this->entityManager ->getRepository(OrganizationalUnit::class) ->findBy(['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT], ['name' => 'ASC']); $data = []; foreach ($organizationalUnits as $center) { $data[] = [ 'id' => $center->getId(), 'name' => $center->getName(), 'description' => $center->getDescription(), ]; } return new JsonResponse($data, Response::HTTP_OK); } #[Route('/opengnsys/rest/ous/{centerId}/labs', name: 'get_classrooms', methods: ['GET'])] #[Route('/opengnsys/rest//ous/{centerId}/labs', methods: ['GET'])] public function getClassrooms(int $centerId): JsonResponse { $classrooms = $this->entityManager ->getRepository(OrganizationalUnit::class) ->findBy([ 'type' => OrganizationalUnitTypes::CLASSROOM, 'parent' => $centerId ], ['name' => 'ASC']); $data = []; foreach ($classrooms as $classroom) { $data[] = [ 'id' => $classroom->getId(), 'name' => $classroom->getName(), 'description' => $classroom->getDescription(), ]; } return new JsonResponse($data, Response::HTTP_OK); } #[Route('/opengnsys/rest/ous/{centerId}/images', name: 'getImages', methods: ['GET'])] public function getImages(int $centerId): JsonResponse { $parent = $this->entityManager ->getRepository(OrganizationalUnit::class) ->find($centerId); $images = $this->entityManager ->getRepository(Image::class) ->findBy([ 'organizationalUnit' => $parent, ], ['name' => 'ASC']); $data = []; foreach ($images as $image) { $data[] = [ 'id' => $image->getId(), 'name' => $image->getName(), ]; } return new JsonResponse($data, Response::HTTP_OK); } #[Route('/opengnsys/rest//info', methods: ['GET'])] public function getOpengnsysInfo(Request $request): JsonResponse { $data = [ "project" => "OpenGnsys", "version" => "1.1.1d", "codename" => "Espeto", "definition" => "http://www.andalucia.com/gastronomy/espeto.htm", "release" => "", "ogagent" => "1.1.2", "services" => [ "server", "repository" ], "oglive" => [ "distribution" => "focal", "kernel" => "5.13.0-27-beta", "architecture" => "amd64", "revision" => "r20210706", "directory" => "ogLive-5.13.0-r20210706", "iso" => "ogLive-focal-5.13.0-27-beta-amd64-r20210706.5b4bf5f.iso" ] ]; return new JsonResponse($data, Response::HTTP_OK); } }