| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <?php
- /**
- * @OA\Tag(
- * name="update",
- * description="Organizr Update"
- * )
- */
- $app->get('/update', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update",
- * summary="Update Organizr install using update script",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->updateOrganizr();
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/download/{branch}', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/download/{branch}",
- * summary="Download Organizr Update Files",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->upgradeInstall($args['branch'], '1');
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/unzip/{branch}', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/unzip/{branch}",
- * summary="Unzip Organizr Update Files",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->upgradeInstall($args['branch'], '2');
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/move/{branch}', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/move/{branch}",
- * summary="Move Organizr Update Files",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->upgradeInstall($args['branch'], '3');
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/cleanup/{branch}', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/cleanup/{branch}",
- * summary="Cleanup Organizr Update Files",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->upgradeInstall($args['branch'], '4');
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/docker', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/docker",
- * summary="Update Organizr install using Docker Container script",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->dockerUpdate();
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/windows', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/windows",
- * summary="Update Organizr install using Windows script",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->windowsUpdate();
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/linux', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/linux",
- * summary="Update Organizr install using Linux script",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->linuxUpdate();
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/migrate/{version}', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/migrate/{version}",
- * summary="Run Organizr Version Mirgation for specific version",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->upgradeToVersion($args['version']);
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/update/reset/{feature}', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * security={{ "api_key":{} }},
- * tags={"update"},
- * path="/api/v2/update/reset/{feature}",
- * summary="Reset an Organizr feature back to default values",
- * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
- * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
- * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->resetUpdateFeature($args['feature']);
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
|