refs #734 Adds template of repository and branch endpoints
parent
cfc2415f4c
commit
b5f6ce18e1
|
@ -30,7 +30,7 @@ class OgGitController
|
|||
$this->curlRequestService = $curlRequestService;
|
||||
$this->logger = $logger;
|
||||
$this->httpClient = $httpClient;
|
||||
$this->params = $params; // Accedemos a las variables de entorno a través de ParameterBagInterface
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,9 +61,157 @@ public function getStatus(): Response
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/oggit/v1/repositories", methods={"GET"})
|
||||
* @OA\Get(
|
||||
* path="/oggit/v1/repositories",
|
||||
* summary="Obtener un listado de todos los repositorios alojados en el servidor OG",
|
||||
* tags={"Repositories"},
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Lista de repositorios obtenida con éxito",
|
||||
* @OA\JsonContent(
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* type="object",
|
||||
* @OA\Property(property="id", type="string", description="ID del repositorio"),
|
||||
* @OA\Property(property="name", type="string", description="Nombre del repositorio"),
|
||||
* @OA\Property(property="createdAt", type="string", format="date-time", description="Fecha de creación del repositorio"),
|
||||
* @OA\Property(property="lastModified", type="string", format="date-time", description="Última modificación del repositorio")
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=500,
|
||||
* description="Error interno del servidor"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function getRepositories(): JsonResponse
|
||||
{
|
||||
// Lógica para obtener los repositorios (por ahora, devolvemos un mensaje de prueba)
|
||||
return new JsonResponse([
|
||||
[
|
||||
'id' => '1',
|
||||
'name' => 'Repositorio 1',
|
||||
'createdAt' => '2024-09-12T10:00:00Z',
|
||||
'lastModified' => '2024-09-12T12:00:00Z'
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'name' => 'Repositorio 2',
|
||||
'createdAt' => '2024-09-11T08:30:00Z',
|
||||
'lastModified' => '2024-09-12T09:00:00Z'
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/oggit/v1/repositories/{id}", methods={"DELETE"})
|
||||
* @OA\Delete(
|
||||
* path="/oggit/v1/repositories/{id}",
|
||||
* tags={"Repositories"},
|
||||
* summary="Eliminar un repositorio",
|
||||
* @OA\Parameter(
|
||||
* name="id",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* description="ID del repositorio a eliminar",
|
||||
* @OA\Schema(type="string")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=204,
|
||||
* description="Repositorio eliminado exitosamente"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=404,
|
||||
* description="Repositorio no encontrado"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=500,
|
||||
* description="Error en el servidor"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function deleteRepository($id): JsonResponse
|
||||
{
|
||||
return new JsonResponse([
|
||||
'message' => "Llamando a la función deleteRepository para eliminar el repositorio con ID $id."
|
||||
], 204);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/oggit/v1/repositories/{id}/branches", methods={"GET"})
|
||||
* @OA\Get(
|
||||
* path="/oggit/v1/repositories/{id}/branches",
|
||||
* summary="Obtener las ramas de un repositorio",
|
||||
* tags={"Branches"},
|
||||
* @OA\Parameter(
|
||||
* name="id",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* description="ID del repositorio",
|
||||
* @OA\Schema(type="string")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Operación exitosa",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="message", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function getBranches($id): JsonResponse
|
||||
{
|
||||
return new JsonResponse([
|
||||
'message' => "Llamando a la función getBranches con estos parámetros: id = $id"
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/oggit/v1/repositories/{repoId}/branches/{branchId}", methods={"DELETE"})
|
||||
* @OA\Delete(
|
||||
* path="/oggit/v1/repositories/{repoId}/branches/{branchId}",
|
||||
* summary="Eliminar una rama de un repositorio",
|
||||
* tags={"Branches"},
|
||||
* @OA\Parameter(
|
||||
* name="repoId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* description="ID del repositorio",
|
||||
* @OA\Schema(type="string")
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="branchId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* description="ID de la rama a eliminar",
|
||||
* @OA\Schema(type="string")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=204,
|
||||
* description="Rama eliminada exitosamente"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=404,
|
||||
* description="Repositorio o rama no encontrada"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=500,
|
||||
* description="Error en el servidor"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function deleteBranch($repoId, $branchId): JsonResponse
|
||||
{
|
||||
return new JsonResponse([
|
||||
'message' => "Llamando a la función deleteBranch para eliminar la rama con ID $branchId del repositorio con ID $repoId."
|
||||
], 204);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue