Browse Source

Automation api Endpoint

remastering
Václav Španinger 1 year ago
parent
commit
38b29a2a4a
2 changed files with 25 additions and 0 deletions
  1. +3
    -0
      app/Routes.php
  2. +22
    -0
      app/api/AutomationsApi.php

+ 3
- 0
app/Routes.php View File

@ -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');

+ 22
- 0
app/api/AutomationsApi.php View File

@ -0,0 +1,22 @@
<?php
class AutomationsApi extends ApiController
{
public function default()
{
//$this->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);
}
}

Loading…
Cancel
Save