commit
9a23ef59b1
|
@ -1,4 +1,9 @@
|
|||
# Changelog
|
||||
## [0.23.0] - 2025-09-08
|
||||
### Added
|
||||
- Se ha añadido la funcionalidad/servicio para poder realizar backups a repositorios GIT
|
||||
|
||||
---
|
||||
## [0.22.4] - 2025-09-05
|
||||
### Fixed
|
||||
- Se ha corregido un typo en los ficheros de la carpeta "State/Processor"
|
||||
|
|
|
@ -119,6 +119,15 @@ resources:
|
|||
input: App\Dto\Input\CreateBranchInput
|
||||
uriTemplate: /image-repositories/server/git/{uuid}/create-branch
|
||||
controller: App\Controller\OgRepository\Git\CreateBranchAction
|
||||
|
||||
git_repository_create_backup:
|
||||
shortName: OgRepository Server
|
||||
description: Create a backup in a Git repository
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\CreateBackupInput
|
||||
uriTemplate: /image-repositories/server/git/{uuid}/create-backup
|
||||
controller: App\Controller\OgRepository\Git\CreateBackupAction
|
||||
|
||||
|
||||
properties:
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgRepository\Git;
|
||||
|
||||
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
||||
use App\Dto\Input\CreateBackupInput;
|
||||
use App\Entity\ImageRepository;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
#[AsController]
|
||||
class CreateBackupAction extends AbstractOgRepositoryController
|
||||
{
|
||||
public function __invoke(ImageRepository $repository, CreateBackupInput $input): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/git/repositories/'.$input->repository.'/backup', [
|
||||
'json' => [
|
||||
'ssh_server' => $input->sshServer,
|
||||
'ssh_user' => $input->sshUser,
|
||||
'ssh_port' => $input->sshPort,
|
||||
'filename' => $input->filename,
|
||||
]
|
||||
]);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error creating backup');
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class CreateBackupInput
|
||||
{
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?string $repository = '';
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?string $sshServer = '';
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?string $sshUser = '';
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?string $sshPort = '';
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?string $filename = '';
|
||||
}
|
Loading…
Reference in New Issue