1007 lines
49 KiB
PHP
1007 lines
49 KiB
PHP
<?php
|
|
|
|
namespace App\OpenApi;
|
|
|
|
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
|
|
use ApiPlatform\OpenApi\OpenApi;
|
|
use ApiPlatform\OpenApi\Model;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
final readonly class OpenApiFactory implements OpenApiFactoryInterface
|
|
{
|
|
|
|
public function __construct(private OpenApiFactoryInterface $decorated)
|
|
{
|
|
}
|
|
|
|
public function __invoke(array $context = []): OpenApi
|
|
{
|
|
$openApi = $this->decorated->__invoke($context);
|
|
|
|
$this->addRefreshToken($openApi);
|
|
$this->addOgAgentEndpoints($openApi);
|
|
$this->addUDsEndpoints($openApi);
|
|
$this->addOgBootStatusEndpoint($openApi);
|
|
$this->addOgRepositoryStatusEndpoint($openApi);
|
|
$this->addInstallOgLiveWebhookEndpoint($openApi);
|
|
|
|
return $openApi;
|
|
}
|
|
|
|
private function addRefreshToken(OpenApi $openApi): void
|
|
{
|
|
$openApi
|
|
->getPaths()
|
|
->addPath( '/auth/refresh', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postRefreshToken'))
|
|
->withTags(['Login check'])
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Refresh token',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'token' => [
|
|
'type' => 'string',
|
|
'readOnly' => true,
|
|
'nullable' => false,
|
|
],
|
|
'refreshToken' => [
|
|
'type' => 'string',
|
|
'readOnly' => true,
|
|
'nullable' => false,
|
|
]
|
|
],
|
|
'required' => ['token', 'refreshToken'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
->withSummary('Create refresh token')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('The refresh token data')
|
|
->withContent( new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'refreshToken' => [
|
|
'type' => 'string',
|
|
'nullable' => false,
|
|
],
|
|
],
|
|
'required' => ['refreshToken'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
));
|
|
}
|
|
|
|
private function addOgAgentEndpoints(OpenApi $openApi): void
|
|
{
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogagent/started', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postAgentStarted'))
|
|
->withTags(['OS agent'])
|
|
->withSummary('Receive notification that an agent has started')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('Notification of agent start')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'mac' => [
|
|
'type' => 'string',
|
|
'example' => '00:01:02:03:04:05',
|
|
],
|
|
'ip' => [
|
|
'type' => 'string',
|
|
'example' => '192.168.2.11',
|
|
],
|
|
'secret' => [
|
|
'type' => 'string',
|
|
'example' => 'nug05l0ipc0lzl578uu5ohm1a074v4t2',
|
|
],
|
|
'ostype' => [
|
|
'type' => 'string',
|
|
'enum' => ['Linux', 'MacOS', 'Windows'],
|
|
],
|
|
'osversion' => [
|
|
'type' => 'string',
|
|
'example' => 'Debian GNU/Linux 12 (bookworm)',
|
|
],
|
|
'agent_version' => [
|
|
'type' => 'string',
|
|
'example' => '1.3.0',
|
|
],
|
|
],
|
|
'required' => ['mac', 'ip', 'secret', 'ostype', 'osversion', 'agent_version'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => ['$ref' => '#/components/schemas/EmptyObj'],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogagent/stopped', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postAgentStopped'))
|
|
->withTags(['OS agent'])
|
|
->withSummary('Receive notification that an agent has stopped')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('Notification of agent stop')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'mac' => [
|
|
'type' => 'string',
|
|
'example' => '00:01:02:03:04:05',
|
|
],
|
|
'ip' => [
|
|
'type' => 'string',
|
|
'example' => '192.168.2.11',
|
|
],
|
|
'ostype' => [
|
|
'type' => 'string',
|
|
'enum' => ['Linux', 'MacOS', 'Windows'],
|
|
],
|
|
'osversion' => [
|
|
'type' => 'string',
|
|
'example' => 'Debian GNU/Linux 12 (bookworm)',
|
|
],
|
|
],
|
|
'required' => ['mac', 'ip', 'ostype', 'osversion'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => ['$ref' => '#/components/schemas/EmptyObj'],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogagent/loggedin', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postAgentLoggedIn'))
|
|
->withTags(['OS agent'])
|
|
->withSummary('Receive notification that a user has logged in')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('Notification of user login')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'ip' => [
|
|
'type' => 'string',
|
|
'example' => '192.168.2.11',
|
|
],
|
|
'user' => [
|
|
'type' => 'string',
|
|
'example' => 'student',
|
|
],
|
|
'language' => [
|
|
'type' => 'string',
|
|
'example' => 'en_GB',
|
|
],
|
|
'session' => [
|
|
'type' => 'string',
|
|
'example' => 'x11',
|
|
],
|
|
'ostype' => [
|
|
'type' => 'string',
|
|
'enum' => ['Linux', 'MacOS', 'Windows'],
|
|
],
|
|
'osversion' => [
|
|
'type' => 'string',
|
|
'example' => 'Debian GNU/Linux 12 (bookworm)',
|
|
],
|
|
],
|
|
'required' => ['ip', 'user', 'language', 'session', 'ostype', 'osversion'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => ['$ref' => '#/components/schemas/EmptyObj'],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogagent/loggedout', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postAgentLoggedOut'))
|
|
->withTags(['OS agent'])
|
|
->withSummary('Receive notification that a user has logged out')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('Notification of user logout')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'ip' => [
|
|
'type' => 'string',
|
|
'example' => '192.168.2.11',
|
|
],
|
|
'user' => [
|
|
'type' => 'string',
|
|
'example' => 'student',
|
|
],
|
|
],
|
|
'required' => ['ip', 'user'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => ['$ref' => '#/components/schemas/EmptyObj'],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogAdmClient/InclusionCliente', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postInclusionCliente'))
|
|
->withTags(['OgLive agent'])
|
|
->withSummary('Add client to the list of known ones')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('Inclusion cliente request')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'iph' => [
|
|
'type' => 'string',
|
|
],
|
|
'ido' => [
|
|
'type' => 'integer',
|
|
],
|
|
'npc' => [
|
|
'type' => 'string',
|
|
],
|
|
'idc' => [
|
|
'type' => 'integer',
|
|
],
|
|
'ida' => [
|
|
'type' => 'integer',
|
|
],
|
|
'cfg' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
'required' => ['iph', 'cfg'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'res' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'ido' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'npc' => [
|
|
'type' => 'string',
|
|
'example' => 'Nombre del cliente',
|
|
],
|
|
'che' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'exe' => [
|
|
'type' => 'integer',
|
|
'example' => 42,
|
|
],
|
|
'ida' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'idc' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
],
|
|
'required' => ['res', 'ido', 'npc', 'che', 'exe', 'ida', 'idc'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogAdmClient/AutoexecCliente', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postAutoexecCliente'))
|
|
->withTags(['OgLive agent'])
|
|
->withSummary('Create and return autoexec file for client')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('AutoexecCliente request')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'iph' => [
|
|
'type' => 'string',
|
|
],
|
|
'ido' => [
|
|
'type' => 'integer',
|
|
],
|
|
'npc' => [
|
|
'type' => 'string',
|
|
],
|
|
'idc' => [
|
|
'type' => 'integer',
|
|
],
|
|
'ida' => [
|
|
'type' => 'integer',
|
|
],
|
|
'exe' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
'required' => ['iph', 'exe'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success, autoexec file created',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'res' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'nfl' => [
|
|
'type' => 'string',
|
|
'example' => '/tmp/Sautoexec-00:01:02:03:04:05',
|
|
],
|
|
],
|
|
'required' => ['res', 'nfl'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_BAD_REQUEST => [
|
|
'description' => 'Missing parameter',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_INTERNAL_SERVER_ERROR => [
|
|
'description' => 'Error creating file',
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogAdmClient/enviaArchivo', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postEnviaArchivo'))
|
|
->withTags(['OgLive agent'])
|
|
->withSummary('Send the contents of a file')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('EnviaArchivo request')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'iph' => [
|
|
'type' => 'string',
|
|
],
|
|
'ido' => [
|
|
'type' => 'integer',
|
|
],
|
|
'npc' => [
|
|
'type' => 'string',
|
|
],
|
|
'idc' => [
|
|
'type' => 'integer',
|
|
],
|
|
'ida' => [
|
|
'type' => 'integer',
|
|
],
|
|
'nfl' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
'required' => ['nfl'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success, file content returned',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'contents' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
'required' => ['contents'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_BAD_REQUEST => [
|
|
'description' => 'Missing parameter',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_NOT_FOUND => [
|
|
'description' => 'File not found',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogAdmClient/ComandosPendientes', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postComandosPendientes'))
|
|
->withTags(['OgLive agent'])
|
|
->withSummary('Retrieve pending commands for a client')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('ComandosPendientes request')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'iph' => [
|
|
'type' => 'string',
|
|
],
|
|
'ido' => [
|
|
'type' => 'integer',
|
|
],
|
|
'npc' => [
|
|
'type' => 'string',
|
|
],
|
|
'idc' => [
|
|
'type' => 'integer',
|
|
],
|
|
'ida' => [
|
|
'type' => 'integer',
|
|
],
|
|
],
|
|
'required' => ['iph', 'ido'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success, pending commands returned',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'nfn' => [
|
|
'type' => 'string',
|
|
'example' => 'NoComandosPtes',
|
|
],
|
|
'comandos' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_BAD_REQUEST => [
|
|
'description' => 'Missing parameter',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_NOT_FOUND => [
|
|
'description' => 'Client not found',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/opengnsys/rest/ogAdmClient/DisponibilidadComandos', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postDisponibilidadComandos'))
|
|
->withTags(['OgLive agent'])
|
|
->withSummary('Check command availability for a client')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('DisponibilidadComandos request')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'iph' => [
|
|
'type' => 'string',
|
|
],
|
|
'ido' => [
|
|
'type' => 'integer',
|
|
],
|
|
'npc' => [
|
|
'type' => 'string',
|
|
],
|
|
'idc' => [
|
|
'type' => 'integer',
|
|
],
|
|
'ida' => [
|
|
'type' => 'integer',
|
|
],
|
|
'tpc' => [
|
|
'type' => 'integer',
|
|
],
|
|
],
|
|
'required' => ['iph', 'tpc'],
|
|
])))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Success, command availability checked',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => ['$ref' => '#/components/schemas/EmptyObj'],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_BAD_REQUEST => [
|
|
'description' => 'Missing parameter',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_NOT_FOUND => [
|
|
'description' => 'Client not found',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
));
|
|
}
|
|
|
|
private function addOgBootStatusEndpoint(OpenApi $openApi): void
|
|
{
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/og-boot/status', (new Model\PathItem())->withGet(
|
|
(new Model\Operation('getStatus'))
|
|
->withTags(['OgBoot'])
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Service status',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'status' => [
|
|
'type' => 'string',
|
|
'example' => 'ok',
|
|
],
|
|
'uptime' => [
|
|
'type' => 'integer',
|
|
'example' => 12345,
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_SERVICE_UNAVAILABLE => [
|
|
'description' => 'Service unavailable',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'error' => [
|
|
'type' => 'string',
|
|
'example' => 'Service is down',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
->withSummary('Get service status')
|
|
));
|
|
}
|
|
|
|
private function addOgRepositoryStatusEndpoint(OpenApi $openApi): void
|
|
{
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/og-repository/status', (new Model\PathItem())->withGet(
|
|
(new Model\Operation('getStatus'))
|
|
->withTags(['OgRepository'])
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Service status',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'status' => [
|
|
'type' => 'string',
|
|
'example' => 'ok',
|
|
],
|
|
'uptime' => [
|
|
'type' => 'integer',
|
|
'example' => 12345,
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_SERVICE_UNAVAILABLE => [
|
|
'description' => 'Service unavailable',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'error' => [
|
|
'type' => 'string',
|
|
'example' => 'Service is down',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
->withSummary('Get service status')
|
|
));
|
|
}
|
|
|
|
private function addUDsEndpoints(OpenApi $openApi): void
|
|
{
|
|
$openApi->getPaths()->addPath('/opengnsys/rest//ous', (new Model\PathItem())->withGet(
|
|
(new Model\Operation('getOUs'))
|
|
->withTags(['UDS'])
|
|
->withSummary('Obtener todas las Unidades Organizacionales')
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Lista de Unidades Organizacionales',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'name' => [
|
|
'type' => 'string',
|
|
'example' => 'Nombre de la Unidad Organizacional',
|
|
],
|
|
'description' => [
|
|
'type' => 'string',
|
|
'example' => 'Descripción de la Unidad Organizacional',
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
])
|
|
));
|
|
|
|
$openApi->getPaths()->addPath('/opengnsys/rest/ous/{centerId}/labs', (new Model\PathItem())->withGet(
|
|
(new Model\Operation('getClassrooms'))
|
|
->withTags(['UDS'])
|
|
->withSummary('Obtener los laboratorios de una Unidad Organizacional específica')
|
|
->withParameters([
|
|
new Model\Parameter(
|
|
'centerId',
|
|
'path',
|
|
'El ID de la Unidad Organizacional',
|
|
true,
|
|
false,
|
|
)
|
|
])
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Lista de Laboratorios',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'name' => [
|
|
'type' => 'string',
|
|
'example' => 'Nombre del Laboratorio',
|
|
],
|
|
'description' => [
|
|
'type' => 'string',
|
|
'example' => 'Descripción del Laboratorio',
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
])
|
|
));
|
|
|
|
$openApi->getPaths()->addPath('/opengnsys/rest/ous/{centerId}/images', (new Model\PathItem())->withGet(
|
|
(new Model\Operation('getImages'))
|
|
->withTags(['UDS'])
|
|
->withSummary('Obtener las imágenes de una Unidad Organizacional específica')
|
|
->withParameters([
|
|
new Model\Parameter(
|
|
'centerId',
|
|
'path',
|
|
'El ID de la Unidad Organizacional',
|
|
true,
|
|
false,
|
|
)
|
|
])
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Lista de Imagenes',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => [
|
|
'type' => 'integer',
|
|
'example' => 1,
|
|
],
|
|
'name' => [
|
|
'type' => 'string',
|
|
'example' => 'Nombre del Laboratorio',
|
|
],
|
|
'description' => [
|
|
'type' => 'string',
|
|
'example' => 'Descripción del Laboratorio',
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
])
|
|
));
|
|
|
|
$openApi->getPaths()->addPath('/opengnsys/rest//info', (new Model\PathItem())->withGet(
|
|
(new Model\Operation('getOpengnsysInfo'))
|
|
->withTags(['UDS'])
|
|
->withSummary('Obtener información general de OpenGnsys')
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Información general de OpenGnsys',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'project' => [
|
|
'type' => 'string',
|
|
'example' => 'OpenGnsys',
|
|
],
|
|
'version' => [
|
|
'type' => 'string',
|
|
'example' => '1.1.1d',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
]
|
|
])
|
|
));
|
|
}
|
|
|
|
private function addInstallOgLiveWebhookEndpoint(OpenApi $openApi): void
|
|
{
|
|
$openApi
|
|
->getPaths()
|
|
->addPath('/og-lives/install/webhook', (new Model\PathItem())->withPost(
|
|
(new Model\Operation('postInstallOgLiveWebhook'))
|
|
->withTags(['OgLive'])
|
|
->withResponses([
|
|
Response::HTTP_OK => [
|
|
'description' => 'Webhook installation successful',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'message' => [
|
|
'type' => 'string',
|
|
'example' => 'Webhook installed successfully',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
Response::HTTP_BAD_REQUEST => [
|
|
'description' => 'Invalid request data',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'error' => [
|
|
'type' => 'string',
|
|
'example' => 'Invalid input data',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
])
|
|
->withSummary('Install a webhook for OgLive')
|
|
->withRequestBody(
|
|
(new Model\RequestBody())
|
|
->withDescription('Data required for installing the webhook')
|
|
->withContent(new \ArrayObject([
|
|
'application/json' => new Model\MediaType(new \ArrayObject([
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'da' => [
|
|
'type' => 'string',
|
|
'description' => 'The URL to set for the webhook',
|
|
'example' => 'https://example.com/webhook',
|
|
],
|
|
],
|
|
'required' => ['url'],
|
|
]))
|
|
]))
|
|
->withRequired(true)
|
|
)
|
|
));
|
|
}
|
|
} |