From 06c8a2da977f6d1437a595d608ec387877998e76 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 16 May 2020 18:34:37 +0300 Subject: [PATCH] Updated health routes --- app/config/scopes.php | 1 + app/controllers/api/health.php | 35 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/config/scopes.php b/app/config/scopes.php index 53b71dd78f..59ad2a0859 100644 --- a/app/config/scopes.php +++ b/app/config/scopes.php @@ -21,4 +21,5 @@ return [ // List of publicly visible scopes // 'webhooks.write', 'locale.read', 'avatars.read', + 'health.read', ];; \ No newline at end of file diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index cc32c4e253..9e9ea09635 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -9,7 +9,7 @@ use Appwrite\ClamAV\Network; $utopia->get('/v1/health') ->desc('Get HTTP') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'get') @@ -22,7 +22,7 @@ $utopia->get('/v1/health') $utopia->get('/v1/health/db') ->desc('Get DB') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getDB') @@ -37,7 +37,7 @@ $utopia->get('/v1/health/db') $utopia->get('/v1/health/cache') ->desc('Get Cache') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getCache') @@ -52,7 +52,7 @@ $utopia->get('/v1/health/cache') $utopia->get('/v1/health/time') ->desc('Get Time') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getTime') @@ -99,7 +99,7 @@ $utopia->get('/v1/health/time') $utopia->get('/v1/health/queue/webhooks') ->desc('Get Webhooks Queue') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueWebhooks') @@ -112,7 +112,7 @@ $utopia->get('/v1/health/queue/webhooks') $utopia->get('/v1/health/queue/tasks') ->desc('Get Tasks Queue') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueTasks') @@ -125,7 +125,7 @@ $utopia->get('/v1/health/queue/tasks') $utopia->get('/v1/health/queue/logs') ->desc('Get Logs Queue') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueLogs') @@ -138,7 +138,7 @@ $utopia->get('/v1/health/queue/logs') $utopia->get('/v1/health/queue/usage') ->desc('Get Usage Queue') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueUsage') @@ -151,7 +151,7 @@ $utopia->get('/v1/health/queue/usage') $utopia->get('/v1/health/queue/certificates') ->desc('Get Certificate Queue') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueCertificates') @@ -162,9 +162,22 @@ $utopia->get('/v1/health/queue/certificates') } ); +$utopia->get('/v1/health/queue/functions') + ->desc('Get Functions Queue') + ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueFunctions') + ->label('sdk.description', '/docs/references/health/get-queue-functions.md') + ->action( + function () use ($response) { + $response->json(['size' => Resque::size('v1-functions')]); + } + ); + $utopia->get('/v1/health/storage/local') ->desc('Get Local Storage') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getStorageLocal') @@ -199,7 +212,7 @@ $utopia->get('/v1/health/storage/local') $utopia->get('/v1/health/anti-virus') ->desc('Get Anti virus') - ->label('scope', 'public') + ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getAntiVirus')