| @@ 96-109 (lines=14) @@ | ||
| 93 | * }) |
|
| 94 | * }) |
|
| 95 | */ |
|
| 96 | public function create(Request $request) |
|
| 97 | { |
|
| 98 | try { |
|
| 99 | $node = new NodeRepository; |
|
| 100 | $new = $node->create($request->all()); |
|
| 101 | ||
| 102 | return ['id' => $new]; |
|
| 103 | } catch (DisplayValidationException $ex) { |
|
| 104 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 105 | } catch (DisplayException $ex) { |
|
| 106 | throw new ResourceException($ex->getMessage()); |
|
| 107 | } catch (\Exception $e) { |
|
| 108 | throw new BadRequestHttpException('There was an error while attempting to add this node to the system.'); |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| @@ 72-86 (lines=15) @@ | ||
| 69 | * @Versions({"v1"}) |
|
| 70 | * @Response(201) |
|
| 71 | */ |
|
| 72 | public function create(Request $request) |
|
| 73 | { |
|
| 74 | try { |
|
| 75 | $server = new ServerRepository; |
|
| 76 | $new = $server->create($request->all()); |
|
| 77 | ||
| 78 | return ['id' => $new]; |
|
| 79 | } catch (DisplayValidationException $ex) { |
|
| 80 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 81 | } catch (DisplayException $ex) { |
|
| 82 | throw new ResourceException($ex->getMessage()); |
|
| 83 | } catch (\Exception $ex) { |
|
| 84 | Log::error($ex); |
|
| 85 | throw new BadRequestHttpException('There was an error while attempting to add this server to the system.'); |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| @@ 175-188 (lines=14) @@ | ||
| 172 | * @Parameter("id", type="integer", required=true, description="The ID of the server to modify.") |
|
| 173 | * }) |
|
| 174 | */ |
|
| 175 | public function config(Request $request, $id) |
|
| 176 | { |
|
| 177 | try { |
|
| 178 | $server = new ServerRepository; |
|
| 179 | $server->updateDetails($id, $request->all()); |
|
| 180 | ||
| 181 | return Models\Server::findOrFail($id); |
|
| 182 | } catch (DisplayValidationException $ex) { |
|
| 183 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 184 | } catch (DisplayException $ex) { |
|
| 185 | throw new ResourceException($ex->getMessage()); |
|
| 186 | } catch (\Exception $ex) { |
|
| 187 | throw new ServiceUnavailableHttpException('Unable to update server on system due to an error.'); |
|
| 188 | } |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| @@ 220-233 (lines=14) @@ | ||
| 217 | * @Parameter("id", type="integer", required=true, description="The ID of the server to modify.") |
|
| 218 | * }) |
|
| 219 | */ |
|
| 220 | public function build(Request $request, $id) |
|
| 221 | { |
|
| 222 | try { |
|
| 223 | $server = new ServerRepository; |
|
| 224 | $server->changeBuild($id, $request->all()); |
|
| 225 | ||
| 226 | return Models\Server::findOrFail($id); |
|
| 227 | } catch (DisplayValidationException $ex) { |
|
| 228 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 229 | } catch (DisplayException $ex) { |
|
| 230 | throw new ResourceException($ex->getMessage()); |
|
| 231 | } catch (\Exception $ex) { |
|
| 232 | throw new ServiceUnavailableHttpException('Unable to update server on system due to an error.'); |
|
| 233 | } |
|
| 234 | } |
|
| 235 | ||
| 236 | /** |
|
| @@ 155-168 (lines=14) @@ | ||
| 152 | * @Parameter("id", type="integer", required=true, description="The ID of the user to modify.") |
|
| 153 | * }) |
|
| 154 | */ |
|
| 155 | public function update(Request $request, $id) |
|
| 156 | { |
|
| 157 | try { |
|
| 158 | $user = new UserRepository; |
|
| 159 | $user->update($id, $request->all()); |
|
| 160 | ||
| 161 | return Models\User::findOrFail($id); |
|
| 162 | } catch (DisplayValidationException $ex) { |
|
| 163 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 164 | } catch (DisplayException $ex) { |
|
| 165 | throw new ResourceException($ex->getMessage()); |
|
| 166 | } catch (\Exception $ex) { |
|
| 167 | throw new ServiceUnavailableHttpException('Unable to update a user on the system due to an error.'); |
|
| 168 | } |
|
| 169 | } |
|
| 170 | ||
| 171 | /** |
|