Add Bird configuration endpoints (GET/POST) and update OpenAPI documentation
This commit is contained in:
@@ -6552,6 +6552,20 @@ paths:
|
||||
responses:
|
||||
'200': {description: Success}
|
||||
|
||||
/bird/config:
|
||||
get:
|
||||
tags: [Config]
|
||||
summary: Get Bird config
|
||||
operationId: getBirdConfig
|
||||
responses:
|
||||
'200': {description: Success}
|
||||
post:
|
||||
tags: [Config]
|
||||
summary: Update Bird config
|
||||
operationId: updateBirdConfig
|
||||
responses:
|
||||
'200': {description: Success}
|
||||
|
||||
/motorapi/config:
|
||||
get:
|
||||
tags: [Config]
|
||||
|
||||
@@ -215,6 +215,46 @@ class moduleConfigRoute
|
||||
]
|
||||
);
|
||||
|
||||
/** Bird config > GET */
|
||||
$this->get('/bird/config', function () {
|
||||
global $response;
|
||||
$this->requirePermission('modules_bird_config');
|
||||
$user = (new authentication())->get_user();
|
||||
if ($user) {
|
||||
(new logs_o())->add('bird_config', 'global', 1, $user->id, 'BIRD_CONFIG', 'Successfully fetched bird config');
|
||||
$response->success(
|
||||
(new \classes\bird())->config->getConfigRequest()
|
||||
);
|
||||
} else {
|
||||
(new logs_o())->add('bird_config', 'global', 1, 0, 'BIRD_CONFIG', 'No user found, or invalid session');
|
||||
$response->error('Invalid session', 400);
|
||||
}
|
||||
},
|
||||
[
|
||||
'modules_bird_config' => 'Get bird config'
|
||||
]
|
||||
);
|
||||
|
||||
/** Bird config > POST */
|
||||
$this->post('/bird/config', function () {
|
||||
global $response;
|
||||
$this->requirePermission('modules_bird_config');
|
||||
$user = (new authentication())->get_user();
|
||||
if ($user) {
|
||||
(new logs_o())->add('bird_config', 'global', 1, $user->id, 'BIRD_CONFIG', 'Successfully updated bird config');
|
||||
$response->success(
|
||||
(new \classes\bird())->config->postConfigRequest()
|
||||
);
|
||||
} else {
|
||||
(new logs_o())->add('bird_config', 'global', 1, 0, 'BIRD_CONFIG', 'No user found, or invalid session');
|
||||
$response->error('Invalid session', 400);
|
||||
}
|
||||
},
|
||||
[
|
||||
'modules_bird_config' => 'Update bird config'
|
||||
]
|
||||
);
|
||||
|
||||
/** MotorAPI config > GET */
|
||||
$this->get('/motorapi/config', function () {
|
||||
global $response;
|
||||
@@ -701,4 +741,4 @@ class moduleConfigRoute
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user