refs #2462. ogGit, updateImage
parent
3985be7a65
commit
6fc3650062
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Dto\Input\GetGitDataInput;
|
||||
use App\Entity\Client;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class GetGitDataAction extends AbstractOgAgentController
|
||||
{
|
||||
public function __invoke(GetGitDataInput $input): JsonResponse
|
||||
{
|
||||
$data = [
|
||||
'nfn' => 'GetGitData',
|
||||
'dsk' => (string) $input->partition->getEntity()->getDiskNumber(),
|
||||
'par' => (string) $input->partition->getEntity()->getPartitionNumber(),
|
||||
];
|
||||
|
||||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'https://'.$input->client->getEntity()->getIp().':8000/opengnsys/GetGitData',
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
token: $input->client->getEntity()->getToken(),
|
||||
);
|
||||
|
||||
$parsedResponse = [
|
||||
'branch' => $response['branch'] ?? null,
|
||||
'repo' => $response['repo'] ?? null,
|
||||
];
|
||||
|
||||
return new JsonResponse(data: $parsedResponse, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgRepository\Git;
|
||||
|
||||
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
||||
use App\Dto\Input\CreateBranchInput;
|
||||
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;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
#[AsController]
|
||||
class CreateBranchAction extends AbstractOgRepositoryController
|
||||
{
|
||||
public function __invoke(ImageRepository $repository, CreateBranchInput $input): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/git/repositories/'.$input->repository.'/branches', [
|
||||
'json' => [
|
||||
'name' => $input->name,
|
||||
'commit' => $input->commit,
|
||||
]
|
||||
]);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error creating branch');
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class CreateBranchInput
|
||||
{
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['repository:write'])]
|
||||
public ?string $repository = null;
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['repository:write'])]
|
||||
public ?string $commit = null;
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['repository:write'])]
|
||||
public ?string $name = null;
|
||||
}
|
Loading…
Reference in New Issue