feat: team api endpoint
This commit is contained in:
parent
7aa8c765f6
commit
2a03b452d3
64
app/Http/Controllers/Api/Team.php
Normal file
64
app/Http/Controllers/Api/Team.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class Team extends Controller
|
||||||
|
{
|
||||||
|
public function teams(Request $request)
|
||||||
|
{
|
||||||
|
$teamId = get_team_id_from_token();
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
return response()->json(['error' => 'Invalid token.', 'docs' => 'https://coolify.io/docs/api/authentication'], 400);
|
||||||
|
}
|
||||||
|
$teams = auth()->user()->teams;
|
||||||
|
return response()->json($teams);
|
||||||
|
}
|
||||||
|
public function team_by_id(Request $request)
|
||||||
|
{
|
||||||
|
$id = $request->id;
|
||||||
|
$teamId = get_team_id_from_token();
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
return response()->json(['error' => 'Invalid token.', 'docs' => 'https://coolify.io/docs/api/authentication'], 400);
|
||||||
|
}
|
||||||
|
$teams = auth()->user()->teams;
|
||||||
|
$team = $teams->where('id', $id)->first();
|
||||||
|
if (is_null($team)) {
|
||||||
|
return response()->json(['error' => 'Team not found.'], 404);
|
||||||
|
}
|
||||||
|
return response()->json($team);
|
||||||
|
}
|
||||||
|
public function members_by_id(Request $request)
|
||||||
|
{
|
||||||
|
$id = $request->id;
|
||||||
|
$teamId = get_team_id_from_token();
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
return response()->json(['error' => 'Invalid token.', 'docs' => 'https://coolify.io/docs/api/authentication'], 400);
|
||||||
|
}
|
||||||
|
$teams = auth()->user()->teams;
|
||||||
|
$team = $teams->where('id', $id)->first();
|
||||||
|
if (is_null($team)) {
|
||||||
|
return response()->json(['error' => 'Team not found.'], 404);
|
||||||
|
}
|
||||||
|
return response()->json($team->members);
|
||||||
|
}
|
||||||
|
public function current_team(Request $request)
|
||||||
|
{
|
||||||
|
$teamId = get_team_id_from_token();
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
return response()->json(['error' => 'Invalid token.', 'docs' => 'https://coolify.io/docs/api/authentication'], 400);
|
||||||
|
}
|
||||||
|
$team = auth()->user()->currentTeam();
|
||||||
|
return response()->json($team);
|
||||||
|
}
|
||||||
|
public function current_team_members(Request $request) {
|
||||||
|
$teamId = get_team_id_from_token();
|
||||||
|
if (is_null($teamId)) {
|
||||||
|
return response()->json(['error' => 'Invalid token.', 'docs' => 'https://coolify.io/docs/api/authentication'], 400);
|
||||||
|
}
|
||||||
|
$team = auth()->user()->currentTeam();
|
||||||
|
return response()->json($team->members);
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
use App\Http\Controllers\Api\Project;
|
use App\Http\Controllers\Api\Project;
|
||||||
use App\Http\Controllers\Api\Resources;
|
use App\Http\Controllers\Api\Resources;
|
||||||
use App\Http\Controllers\Api\Server;
|
use App\Http\Controllers\Api\Server;
|
||||||
|
use App\Http\Controllers\Api\Team;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@ -35,6 +36,13 @@
|
|||||||
Route::get('/server/{uuid}', [Server::class, 'server_by_uuid']);
|
Route::get('/server/{uuid}', [Server::class, 'server_by_uuid']);
|
||||||
Route::get('/resources', [Resources::class, 'resources']);
|
Route::get('/resources', [Resources::class, 'resources']);
|
||||||
Route::get('/domains', [Domains::class, 'domains']);
|
Route::get('/domains', [Domains::class, 'domains']);
|
||||||
|
Route::get('/teams', [Team::class, 'teams']);
|
||||||
|
Route::get('/team/current', [Team::class, 'current_team']);
|
||||||
|
Route::get('/team/current/members', [Team::class, 'current_team_members']);
|
||||||
|
Route::get('/team/{id}', [Team::class, 'team_by_id']);
|
||||||
|
Route::get('/team/{id}/members', [Team::class, 'members_by_id']);
|
||||||
|
|
||||||
|
|
||||||
//Route::get('/projects', [Project::class, 'projects']);
|
//Route::get('/projects', [Project::class, 'projects']);
|
||||||
//Route::get('/project/{uuid}', [Project::class, 'project_by_uuid']);
|
//Route::get('/project/{uuid}', [Project::class, 'project_by_uuid']);
|
||||||
//Route::get('/project/{uuid}/{environment_name}', [Project::class, 'environment_details']);
|
//Route::get('/project/{uuid}/{environment_name}', [Project::class, 'environment_details']);
|
||||||
|
Loading…
Reference in New Issue
Block a user