api.php 6.83 KB
Newer Older
1
2
<?php

3
use Illuminate\Support\Facades\Route;
4
5
6
use App\Http\Controllers\Api\MeController;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\DoorsController;
Jacob Priddy's avatar
Jacob Priddy committed
7
use App\Http\Controllers\Api\UsersController;
8
use App\Http\Controllers\Api\GroupsController;
Jacob Priddy's avatar
Jacob Priddy committed
9
use App\Http\Controllers\Api\TokensController;
10
11
use App\Http\Controllers\Api\EntriesController;
use App\Http\Controllers\Api\AttemptsController;
Jacob Priddy's avatar
Jacob Priddy committed
12
use App\Http\Controllers\Api\RequestsController;
13
use App\Http\Controllers\Api\OverridesController;
Jacob Priddy's avatar
Jacob Priddy committed
14
use App\Http\Controllers\Api\SchedulesController;
15
16
17
18
19
20
21
22
23
24
25

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
26
Route::post('login', [AuthController::class, 'login'])->name('login');
Jacob Priddy's avatar
Jacob Priddy committed
27

28
Route::post('logout', [AuthController::class, 'samlLogout'])->name('logout');
29

Jacob Priddy's avatar
Jacob Priddy committed
30
Route::group(['middleware' => 'auth:api'], static function () {
31
32
33
    Route::group([
        'prefix' => 'users',
    ], static function () {
34
35
36
37
38
        Route::get('/', [UsersController::class, 'index'])->name('users.index');
        Route::post('/', [UsersController::class, 'store'])->name('users.create');
        Route::get('{userId}', [UsersController::class, 'get'])->name('users.get');
        Route::patch('{userId}', [UsersController::class, 'update'])->name('users.update');
        Route::delete('{userId}', [UsersController::class, 'delete'])->name('users.delete');
Jacob Priddy's avatar
Jacob Priddy committed
39

40
        Route::get('{userId}/groups', [UsersController::class, 'getGroupsForUser']);
41
42
43
44
45
        Route::post('{userId}/group/{groupId}', [UsersController::class, 'addUserToGroup'])
            ->name('users.group.add');
        Route::delete('{userId}/group/{groupId}', [UsersController::class, 'removeUserFromGroup'])
            ->name('users.groups.delete');
        Route::get('{userId}/doors', [UsersController::class, 'doors'])->name('users.doors');
46
    });
47

Jacob Priddy's avatar
Jacob Priddy committed
48
49
50
    Route::group([
        'prefix' => 'groups',
    ], static function () {
51
52
53
54
55
        Route::get('/', [GroupsController::class, 'index'])->name('groups.index');
        Route::post('/', [GroupsController::class, 'store'])->name('groups.create');
        Route::get('{groupId}', [GroupsController::class, 'get'])->name('groups.get');
        Route::put('{groupId}', [GroupsController::class, 'update'])->name('groups.update');
        Route::delete('{groupId}', [GroupsController::class, 'delete'])->name('groups.delete');
56
57

        Route::get('{groupId}/users', [GroupsController::class, 'getUsersForGroup']);
58
        Route::get('{groupId}/doors', [GroupsController::class, 'getDoorsForGroup']);
Jacob Priddy's avatar
Jacob Priddy committed
59
60
    });

Jacob Priddy's avatar
Jacob Priddy committed
61
62
63
    Route::group([
        'prefix' => 'doors',
    ], static function () {
64
65
66
67
68
69
70
        Route::get('/', [DoorsController::class, 'index'])->name('doors.index');
        Route::post('/', [DoorsController::class, 'store'])->name('doors.create');
        Route::get('{doorId}', [DoorsController::class, 'get'])->name('doors.get');
        Route::patch('{doorId}', [DoorsController::class, 'update'])->name('doors.update');
        Route::post('/{doorId}/regenerate-token', [DoorsController::class, 'regenerateToken'])
            ->name('doors.regenerate');
        Route::delete('{doorId}', [DoorsController::class, 'delete'])->name('doors.delete');
71

72
        Route::get('{doorId}/groups', [DoorsController::class, 'getGroupsForDoor'])->name('doors.groups');
73
        Route::post('{doorId}/group/{groupId}', [DoorsController::class, 'addDoorToGroup']);
74
        Route::delete('{doorId}/group/{groupId}', [DoorsController::class, 'removeDoorFromGroup']);
Jacob Priddy's avatar
Jacob Priddy committed
75
76
    });

77
78
79
    Route::group([
        'prefix' => 'schedules',
    ], static function () {
80
81
        Route::get('/', [SchedulesController::class, 'index'])->name('schedules.index');
        Route::post('/', [SchedulesController::class, 'create'])->name('schedules.create');
82
        Route::get('/events', [SchedulesController::class, 'events'])->name('schedules.events');
Jacob Priddy's avatar
Jacob Priddy committed
83
        Route::get('{scheduleId}', [SchedulesController::class, 'get'])->name('schedules.get');
84
        Route::patch('{scheduleId}', [SchedulesController::class, 'update'])->name('schedules.update');
85
86
    });

87
88
89
    Route::group([
        'prefix' => 'tokens',
    ], static function () {
90
91
92
93
94
        Route::get('/', [TokensController::class, 'index'])->name('tokens.index');
        Route::post('/', [TokensController::class, 'store'])->name('tokens.create');
        Route::get('{tokenId}', [TokensController::class, 'get'])->name('tokens.get');
        Route::patch('{tokenId}', [TokensController::class, 'update'])->name('tokens.update');
        Route::post('{tokenId}/expire', [TokensController::class, 'expire'])->name('tokens.expire');
95
96
    });

97
98
99
    Route::group([
        'prefix' => 'entries',
    ], static function () {
100
        Route::get('/', [EntriesController::class, 'index'])->name('entries.index');
101
102
103
104
105
    });

    Route::group([
        'prefix' => 'attempts',
    ], static function () {
106
        Route::get('/', [AttemptsController::class, 'index'])->name('attempts.index');
107
108
    });

Jacob Priddy's avatar
Jacob Priddy committed
109
110
111
    Route::group([
        'prefix' => 'requests',
    ], static function () {
Jacob Priddy's avatar
Jacob Priddy committed
112
        Route::post('{requestId}/resolve', [RequestsController::class, 'resolve'])->name('requests.resolve');
Jacob Priddy's avatar
Jacob Priddy committed
113
114
115
116
        Route::post('{requestId}/reply', [RequestsController::class, 'reply'])->name('requests.reply');
        Route::get('/', [RequestsController::class, 'index'])->name('requests.index');
    });

117
118
119
    Route::group([
        'prefix' => 'overrides',
    ], static function () {
120
121
122
123
        Route::get('/', [OverridesController::class, 'index'])->name('overrides.index');
        Route::post('/', [OverridesController::class, 'create'])->name('overrides.create');
        Route::get('{overrideId}', [OverridesController::class, 'get'])->name('overrides.get');
        Route::patch('{overrideId}', [OverridesController::class, 'update'])->name('overrides.update');
124
125
    });

Jacob Priddy's avatar
Jacob Priddy committed
126
127
128
    Route::group([
        'prefix' => 'me',
    ], static function () {
129
130
        Route::get('/', [MeController::class, 'index'])->name('me.index');
        Route::patch('/', [MeController::class, 'update'])->name('me.update');
Jacob Priddy's avatar
Jacob Priddy committed
131
132
        Route::get('/groups', [MeController::class, 'groups'])->name('me.groups');
        Route::get('/tokens', [MeController::class, 'tokens'])->name('me.tokens');
133
        Route::get('/access', [MeController::class, 'doors'])->name('me.access');
Jacob Priddy's avatar
Jacob Priddy committed
134
        Route::get('/permissions', [MeController::class, 'permissions'])->name('me.perms');
135
        Route::get('/schedule-events', [MeController::class, 'doorSchedules'])->name('me.schedules.events');
Jacob Priddy's avatar
Jacob Priddy committed
136
137
        Route::post('/requests', [MeController::class, 'createAccessRequest'])->name('me.requests.create');
        Route::get('/requests', [MeController::class, 'getAccessRequests'])->name('me.requests');
Jacob Priddy's avatar
Jacob Priddy committed
138
    });
139
});