1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 00:53:10 +01:00
invoiceninja/app/Http/Controllers/SystemLogController.php

206 lines
6.3 KiB
PHP
Raw Normal View History

2020-08-24 04:45:53 +02:00
<?php
namespace App\Http\Controllers;
use App\Filters\SystemLogFilters;
use App\Models\SystemLog;
use App\Transformers\SystemLogTransformer;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
2020-10-28 11:10:49 +01:00
use Illuminate\Http\Response;
use stdClass;
2020-08-24 04:45:53 +02:00
2020-08-24 12:28:47 +02:00
class SystemLogController extends BaseController
2020-08-24 04:45:53 +02:00
{
use MakesHash;
protected $entity_type = SystemLog::class;
protected $entity_transformer = SystemLogTransformer::class;
/**
* Show the list of Invoices.
2020-08-24 07:08:49 +02:00
*
2020-10-28 11:10:49 +01:00
* @param SystemLogFilters $filters The filters
2020-08-24 04:45:53 +02:00
*
2020-10-28 11:10:49 +01:00
* @return Response
2020-08-24 07:08:49 +02:00
*
* @OA\Get(
* path="/api/v1/system_logs",
* operationId="getSystemLogs",
* tags={"system_logs"},
* summary="Gets a list of system logs",
* description="Lists system logs, search and filters allow fine grained lists to be generated.
*
* Query parameters can be added to performed more fine grained filtering of the system logs, these are handled by the SystemLogFilters class which defines the methods available",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/include"),
* @OA\Response(
* response=200,
* description="A list of system logs",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* @OA\JsonContent(ref="#/components/schemas/SystemLog"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
* ),
* @OA\Response(
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
2020-08-24 04:45:53 +02:00
*/
public function index(SystemLogFilters $filters)
{
2020-08-24 07:08:49 +02:00
$system_logs = SystemLog::filter($filters);
2020-11-25 15:19:52 +01:00
if (auth()->user()->isAdmin()) {
2020-09-08 12:44:32 +02:00
return $this->listResponse($system_logs);
2020-11-25 15:19:52 +01:00
}
2020-09-08 12:44:32 +02:00
return $this->errorResponse('Insufficient permissions', 403);
2020-08-24 04:45:53 +02:00
}
/**
* Show the form for creating a new resource.
*
2020-10-28 11:10:49 +01:00
* @return Response
2020-08-24 04:45:53 +02:00
*/
public function create()
{
2020-08-24 11:51:19 +02:00
$error = [
'message' => 'Cannot create system log',
2020-10-28 11:10:49 +01:00
'errors' => new stdClass,
2020-08-24 11:51:19 +02:00
];
return response()->json($error, 400);
2020-08-24 04:45:53 +02:00
}
/**
* Store a newly created resource in storage.
*
2020-10-28 11:10:49 +01:00
* @param Request $request
* @return Response
2020-08-24 04:45:53 +02:00
*/
public function store(Request $request)
{
2020-08-24 11:51:19 +02:00
$error = [
'message' => 'Cannot store system log',
2020-10-28 11:10:49 +01:00
'errors' => new stdClass,
2020-08-24 11:51:19 +02:00
];
return response()->json($error, 400);
2020-08-24 04:45:53 +02:00
}
/**
* Display the specified resource.
*
2020-10-28 11:10:49 +01:00
* @param Request $request The request
* @param SystemLog $system_log
* @return Response
2020-08-24 11:51:19 +02:00
*
*
* @OA\Get(
* path="/api/v1/system_logs/{id}",
* operationId="showSystemLogs",
* tags={"system_logs"},
* summary="Shows a system_logs",
* description="Displays a system_logs by id",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/include"),
* @OA\Parameter(
* name="id",
* in="path",
* description="The system_logs Hashed ID",
* example="D2J234DFA",
* required=true,
* @OA\Schema(
* type="string",
* format="string",
* ),
* ),
* @OA\Response(
* response=200,
* description="Returns the system_logs object",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* @OA\JsonContent(ref="#/components/schemas/SystemLog"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
*
* ),
* @OA\Response(
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
2020-08-24 04:45:53 +02:00
*/
2020-08-24 11:51:19 +02:00
public function show(Request $request, SystemLog $system_log)
2020-08-24 04:45:53 +02:00
{
2020-08-24 11:51:19 +02:00
return $this->itemResponse($system_log);
2020-08-24 04:45:53 +02:00
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
2020-10-28 11:10:49 +01:00
* @return Response
2020-08-24 04:45:53 +02:00
*/
public function edit($id)
{
2020-08-24 11:51:19 +02:00
$error = [
'message' => 'Cannot edit system log',
2020-10-28 11:10:49 +01:00
'errors' => new stdClass,
2020-08-24 11:51:19 +02:00
];
return response()->json($error, 400);
2020-08-24 04:45:53 +02:00
}
/**
* Update the specified resource in storage.
*
2020-10-28 11:10:49 +01:00
* @param Request $request
2020-08-24 04:45:53 +02:00
* @param int $id
2020-10-28 11:10:49 +01:00
* @return Response
2020-08-24 04:45:53 +02:00
*/
public function update(Request $request, $id)
{
2020-08-24 11:51:19 +02:00
$error = [
'message' => 'Cannot update system log',
2020-10-28 11:10:49 +01:00
'errors' => new stdClass,
2020-08-24 11:51:19 +02:00
];
return response()->json($error, 400);
2020-08-24 04:45:53 +02:00
}
/**
* Remove the specified resource from storage.
*
* @param int $id
2020-10-28 11:10:49 +01:00
* @return Response
2020-08-24 04:45:53 +02:00
*/
public function destroy($id)
{
2020-08-24 11:51:19 +02:00
$error = [
'message' => 'Cannot destroy system log',
2020-10-28 11:10:49 +01:00
'errors' => new stdClass,
2020-08-24 11:51:19 +02:00
];
return response()->json($error, 400);
2020-08-24 04:45:53 +02:00
}
}