Merge pull request #3338 from coollabsio/add-missing-api-endpoints-for-service-envs

Add missing api endpoints for service envs
This commit is contained in:
Andras Bacsai
2024-09-06 10:52:04 +02:00
committed by GitHub
2 changed files with 12 additions and 12 deletions

View File

@@ -483,7 +483,6 @@ class ServicesController extends Controller
]);
}
#[OA\Get(
summary: 'List Envs',
description: 'List all envs by service UUID.',
@@ -539,12 +538,11 @@ class ServicesController extends Controller
return invalidTokenResponse();
}
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
if (!$service) {
if (! $service) {
return response()->json(['message' => 'Service not found.'], 404);
}
$envs = $service->environment_variables->sortBy('id');
$envs = $envs->map(function ($env) {
$envs = $service->environment_variables->map(function ($env) {
$env->makeHidden([
'application_id',
'standalone_clickhouse_id',
@@ -560,6 +558,8 @@ class ServicesController extends Controller
return $env;
});
return response()->json($envs);
}
#[OA\Patch(
@@ -642,7 +642,7 @@ class ServicesController extends Controller
}
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
if (!$service) {
if (! $service) {
return response()->json(['message' => 'Service not found.'], 404);
}
@@ -663,7 +663,7 @@ class ServicesController extends Controller
}
$env = $service->environment_variables()->where('key', $request->key)->first();
if (!$env) {
if (! $env) {
return response()->json(['message' => 'Environment variable not found.'], 404);
}
@@ -761,12 +761,12 @@ class ServicesController extends Controller
}
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
if (!$service) {
if (! $service) {
return response()->json(['message' => 'Service not found.'], 404);
}
$bulk_data = $request->get('data');
if (!$bulk_data) {
if (! $bulk_data) {
return response()->json(['message' => 'Bulk data is required.'], 400);
}
@@ -876,7 +876,7 @@ class ServicesController extends Controller
}
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
if (!$service) {
if (! $service) {
return response()->json(['message' => 'Service not found.'], 404);
}
@@ -976,7 +976,7 @@ class ServicesController extends Controller
}
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
if (!$service) {
if (! $service) {
return response()->json(['message' => 'Service not found.'], 404);
}
@@ -984,7 +984,7 @@ class ServicesController extends Controller
->where('service_id', $service->id)
->first();
if (!$env) {
if (! $env) {
return response()->json(['message' => 'Environment variable not found.'], 404);
}

View File

@@ -84,7 +84,7 @@ Route::group([
Route::get('/applications/{uuid}/envs', [ApplicationsController::class, 'envs']);
Route::post('/applications/{uuid}/envs', [ApplicationsController::class, 'create_env'])->middleware([IgnoreReadOnlyApiToken::class]);
Route::patch('/applications/{uuid}/envs/bulk', [ApplicationsController::class, 'create_bulk_envs'])->middleware([IgnoreReadOnlyApiToken::class]);
Route::patch('/applications/{uuid}/envs', [ApplicationsController::class, 'update_env_by_uuid']);
Route::patch('/applications/{uuid}/envs', [ApplicationsController::class, 'update_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
Route::delete('/applications/{uuid}/envs/{env_uuid}', [ApplicationsController::class, 'delete_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
Route::match(['get', 'post'], '/applications/{uuid}/start', [ApplicationsController::class, 'action_deploy'])->middleware([IgnoreReadOnlyApiToken::class]);