Skip to content

Commit 518ba35

Browse files
authored
Merge pull request coollabsio#3338 from coollabsio/add-missing-api-endpoints-for-service-envs
Add missing api endpoints for service envs
2 parents 676cee9 + ec7b185 commit 518ba35

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

app/Http/Controllers/Api/ServicesController.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ public function delete_by_uuid(Request $request)
483483
]);
484484
}
485485

486-
487486
#[OA\Get(
488487
summary: 'List Envs',
489488
description: 'List all envs by service UUID.',
@@ -539,12 +538,11 @@ public function envs(Request $request)
539538
return invalidTokenResponse();
540539
}
541540
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
542-
if (!$service) {
541+
if (! $service) {
543542
return response()->json(['message' => 'Service not found.'], 404);
544543
}
545-
$envs = $service->environment_variables->sortBy('id');
546544

547-
$envs = $envs->map(function ($env) {
545+
$envs = $service->environment_variables->map(function ($env) {
548546
$env->makeHidden([
549547
'application_id',
550548
'standalone_clickhouse_id',
@@ -560,6 +558,8 @@ public function envs(Request $request)
560558

561559
return $env;
562560
});
561+
562+
return response()->json($envs);
563563
}
564564

565565
#[OA\Patch(
@@ -642,7 +642,7 @@ public function update_env_by_uuid(Request $request)
642642
}
643643

644644
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
645-
if (!$service) {
645+
if (! $service) {
646646
return response()->json(['message' => 'Service not found.'], 404);
647647
}
648648

@@ -663,7 +663,7 @@ public function update_env_by_uuid(Request $request)
663663
}
664664

665665
$env = $service->environment_variables()->where('key', $request->key)->first();
666-
if (!$env) {
666+
if (! $env) {
667667
return response()->json(['message' => 'Environment variable not found.'], 404);
668668
}
669669

@@ -761,12 +761,12 @@ public function create_bulk_envs(Request $request)
761761
}
762762

763763
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
764-
if (!$service) {
764+
if (! $service) {
765765
return response()->json(['message' => 'Service not found.'], 404);
766766
}
767767

768768
$bulk_data = $request->get('data');
769-
if (!$bulk_data) {
769+
if (! $bulk_data) {
770770
return response()->json(['message' => 'Bulk data is required.'], 400);
771771
}
772772

@@ -876,7 +876,7 @@ public function create_env(Request $request)
876876
}
877877

878878
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
879-
if (!$service) {
879+
if (! $service) {
880880
return response()->json(['message' => 'Service not found.'], 404);
881881
}
882882

@@ -976,15 +976,15 @@ public function delete_env_by_uuid(Request $request)
976976
}
977977

978978
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
979-
if (!$service) {
979+
if (! $service) {
980980
return response()->json(['message' => 'Service not found.'], 404);
981981
}
982982

983983
$env = EnvironmentVariable::where('uuid', $request->env_uuid)
984984
->where('service_id', $service->id)
985985
->first();
986986

987-
if (!$env) {
987+
if (! $env) {
988988
return response()->json(['message' => 'Environment variable not found.'], 404);
989989
}
990990

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
Route::get('/applications/{uuid}/envs', [ApplicationsController::class, 'envs']);
8585
Route::post('/applications/{uuid}/envs', [ApplicationsController::class, 'create_env'])->middleware([IgnoreReadOnlyApiToken::class]);
8686
Route::patch('/applications/{uuid}/envs/bulk', [ApplicationsController::class, 'create_bulk_envs'])->middleware([IgnoreReadOnlyApiToken::class]);
87-
Route::patch('/applications/{uuid}/envs', [ApplicationsController::class, 'update_env_by_uuid']);
87+
Route::patch('/applications/{uuid}/envs', [ApplicationsController::class, 'update_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
8888
Route::delete('/applications/{uuid}/envs/{env_uuid}', [ApplicationsController::class, 'delete_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]);
8989

9090
Route::match(['get', 'post'], '/applications/{uuid}/start', [ApplicationsController::class, 'action_deploy'])->middleware([IgnoreReadOnlyApiToken::class]);

0 commit comments

Comments
 (0)