From 38b29a2a4aa53c7930f96904492dacc24844578e Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 16 Feb 2021 14:28:31 +0100 Subject: [PATCH] Automation api Endpoint --- app/Routes.php | 3 +++ app/api/AutomationsApi.php | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 app/api/AutomationsApi.php diff --git a/app/Routes.php b/app/Routes.php index d5e646b..cbc72a0 100644 --- a/app/Routes.php +++ b/app/Routes.php @@ -40,6 +40,9 @@ $router->post('/api/widgets/{widgetId}/run', 'WidgetApi@run'); $router->get('/api/widgets/{widgetId}/detail', 'WidgetApi@detail'); $router->get('/api/widgets/{widgetId}/detail/{period}', 'WidgetApi@detail'); +$router->get('/api/automations', 'AutomationsApi@default'); + + //cron $router->post('/cron/clean', 'CronApi@clean'); diff --git a/app/api/AutomationsApi.php b/app/api/AutomationsApi.php new file mode 100644 index 0000000..1f45ce9 --- /dev/null +++ b/app/api/AutomationsApi.php @@ -0,0 +1,22 @@ +requireAuth(); + $response = []; + $automationData = AutomationManager::getAll(); + + foreach ($automationData as $automationKey => $automation) { + $response[] = [ + "automation_id" => $automation['automation_id'], + "name" => $automation['name'], + "enabled" => $automation['enabled'], + ]; + } + + $this->response($response); + } +}