Commit b28322f5b8ed87666ff7d9bb7516dd830f4ef98d
1 parent
509aa759b8
Exists in
master
and in
4 other branches
Added VDM endpoint
Showing 3 changed files with 79 additions and 0 deletions
api/app/Http/Controllers/V1/Partners/VdmController.php
View file @
b28322f
1 | +<?php | |
2 | + | |
3 | +namespace App\Http\Controllers\V1\Partners; | |
4 | + | |
5 | + | |
6 | +use App\Http\Controllers\Controller; | |
7 | +use App\Http\Requests\VdmRequest; | |
8 | +use Carbon\Carbon; | |
9 | +use Illuminate\Support\Facades\DB; | |
10 | +use Illuminate\Support\Facades\Log; | |
11 | +use Salman\Mqtt\Facades\Mqtt; | |
12 | + | |
13 | +class VdmController extends Controller | |
14 | +{ | |
15 | + public function store(VdmRequest $request) | |
16 | + { | |
17 | +// $dbEvents = []; | |
18 | +// $mqttEvents = []; | |
19 | +// foreach ($request->get('event_alarm') as $ev) { | |
20 | +// $dbEvents[] = [ | |
21 | +// 'asset_id' => $request->get('asset_id'), | |
22 | +// 'event_alarm_id' => $ev['event_alarm_id'], | |
23 | +// 'event_alarm_char' => $ev['event_alarm_char'], | |
24 | +// 'name' => isset($ev['name']) ? $ev['name'] : null, | |
25 | +// 'time' => Carbon::createFromTimestamp($request->get('timestamp')), | |
26 | +// ]; | |
27 | +// $mqttEvents[] = [ | |
28 | +// 'asset_id' => $request->get('asset_id'), | |
29 | +// 'event_alarm_id' => $ev['event_alarm_id'], | |
30 | +// 'event_alarm_char' => $ev['event_alarm_char'], | |
31 | +// 'name' => isset($ev['name']) ? $ev['name'] : null, | |
32 | +// 'time' => $request->get('timestamp'), | |
33 | +// ]; | |
34 | +// } | |
35 | +// | |
36 | +// // publish to MQTT Broker | |
37 | +// // Mqtt::ConnectAndPublish('adt/event', json_encode($mqttEvents), $request->user()->id); | |
38 | +// //Mqtt::ConnectAndPublish('adt/event', json_encode($mqttEvents), 1); | |
39 | +// //DB::table('vdm')->insert($dbEvents); | |
40 | + | |
41 | + return response()->json(['success' => 'success'], 200); | |
42 | + } | |
43 | +} |
api/app/Http/Requests/VdmRequest.php
View file @
b28322f
1 | +<?php | |
2 | + | |
3 | +namespace App\Http\Requests; | |
4 | + | |
5 | +use Illuminate\Foundation\Http\FormRequest; | |
6 | + | |
7 | +class VdmRequest extends FormRequest | |
8 | +{ | |
9 | + /** | |
10 | + * Determine if the user is authorized to make this request. | |
11 | + * | |
12 | + * @return bool | |
13 | + */ | |
14 | + public function authorize() | |
15 | + { | |
16 | + return true; | |
17 | + } | |
18 | + | |
19 | + /** | |
20 | + * Get the validation rules that apply to the request. | |
21 | + * | |
22 | + * @return array | |
23 | + */ | |
24 | + public function rules() | |
25 | + { | |
26 | + return [ | |
27 | + 'asset_id' => 'required|string', | |
28 | + 'timestamp' => 'required|numeric', // unix timestamp is numeric | |
29 | + 'cve' => 'required|array', | |
30 | + 'cve.*' => 'string', | |
31 | + 'cwe' => 'required|array', | |
32 | + 'cwe.*' => 'string', | |
33 | + ]; | |
34 | + } | |
35 | +} |
api/routes/api.php
View file @
b28322f
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | |
21 | 21 | Route::post('adt', 'V1\Partners\AdtController@store'); |
22 | 22 | Route::post('xlsiem', 'V1\Partners\XlsiemController@store'); |
23 | + Route::post('vdm', 'V1\Partners\VdmController@store'); | |
23 | 24 | |
24 | 25 | Route::group(['prefix' => 'ceptd'], function () { |
25 | 26 | Route::get('start', 'V1\Components\CeptdController@start'); |