| @@ 151-170 (lines=20) @@ | ||
| 148 | * @param int $id |
|
| 149 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
|
| 150 | */ |
|
| 151 | public function delete(Request $request, $id) |
|
| 152 | { |
|
| 153 | $this->authorize('node-delete', $request->apiKey()); |
|
| 154 | ||
| 155 | $repo = new NodeRepository; |
|
| 156 | try { |
|
| 157 | $repo->delete($id); |
|
| 158 | ||
| 159 | return response('', 204); |
|
| 160 | } catch (DisplayException $ex) { |
|
| 161 | return response()->json([ |
|
| 162 | 'error' => $ex->getMessage(), |
|
| 163 | ], 400); |
|
| 164 | } catch (\Exception $ex) { |
|
| 165 | Log::error($ex); |
|
| 166 | return response()->json([ |
|
| 167 | 'error' => 'An unhandled exception occured while attemping to delete this node. Please try again.', |
|
| 168 | ], 500); |
|
| 169 | } |
|
| 170 | } |
|
| 171 | } |
|
| 172 | ||
| @@ 244-263 (lines=20) @@ | ||
| 241 | * @param int $id |
|
| 242 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
|
| 243 | */ |
|
| 244 | public function install(Request $request, $id) |
|
| 245 | { |
|
| 246 | $this->authorize('server-install', $request->apiKey()); |
|
| 247 | ||
| 248 | $repo = new ServerRepository; |
|
| 249 | try { |
|
| 250 | $repo->toggleInstall($id); |
|
| 251 | ||
| 252 | return response('', 204); |
|
| 253 | } catch (DisplayException $ex) { |
|
| 254 | return response()->json([ |
|
| 255 | 'error' => $ex->getMessage(), |
|
| 256 | ], 400); |
|
| 257 | } catch (\Exception $ex) { |
|
| 258 | Log::error($ex); |
|
| 259 | return response()->json([ |
|
| 260 | 'error' => 'An unhandled exception occured while attemping to toggle the install status for this server. Please try again.', |
|
| 261 | ], 500); |
|
| 262 | } |
|
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * Setup a server to have a container rebuild. |
|
| @@ 161-180 (lines=20) @@ | ||
| 158 | * @param int $id |
|
| 159 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
|
| 160 | */ |
|
| 161 | public function delete(Request $request, $id) |
|
| 162 | { |
|
| 163 | $this->authorize('user-delete', $request->apiKey()); |
|
| 164 | ||
| 165 | $repo = new UserRepository; |
|
| 166 | try { |
|
| 167 | $repo->delete($id); |
|
| 168 | ||
| 169 | return response('', 204); |
|
| 170 | } catch (DisplayException $ex) { |
|
| 171 | return response()->json([ |
|
| 172 | 'error' => $ex->getMessage(), |
|
| 173 | ], 400); |
|
| 174 | } catch (\Exception $ex) { |
|
| 175 | Log::error($ex); |
|
| 176 | return response()->json([ |
|
| 177 | 'error' => 'An unhandled exception occured while attemping to delete this user. Please try again.', |
|
| 178 | ], 500); |
|
| 179 | } |
|
| 180 | } |
|
| 181 | } |
|
| 182 | ||