| @@ 205-222 (lines=18) @@ | ||
| 202 | * @Parameter("id", type="integer", required=true, description="The ID of the server to modify.") |
|
| 203 | * }) |
|
| 204 | */ |
|
| 205 | public function build(Request $request, $id) |
|
| 206 | { |
|
| 207 | try { |
|
| 208 | $server = new ServerRepository; |
|
| 209 | $server->changeBuild($id, $request->only([ |
|
| 210 | 'default', 'add_additional', 'remove_additional', |
|
| 211 | 'memory', 'swap', 'io', 'cpu', 'disk', |
|
| 212 | ])); |
|
| 213 | ||
| 214 | return Models\Server::findOrFail($id); |
|
| 215 | } catch (DisplayValidationException $ex) { |
|
| 216 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 217 | } catch (DisplayException $ex) { |
|
| 218 | throw new ResourceException($ex->getMessage()); |
|
| 219 | } catch (\Exception $ex) { |
|
| 220 | throw new ServiceUnavailableHttpException('Unable to update server on system due to an error.'); |
|
| 221 | } |
|
| 222 | } |
|
| 223 | ||
| 224 | /** |
|
| 225 | * Suspend Server. |
|
| @@ 155-173 (lines=19) @@ | ||
| 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->only([ |
|
| 160 | 'username', 'email', 'name_first', |
|
| 161 | 'name_last', 'password', |
|
| 162 | 'root_admin', 'language', |
|
| 163 | ])); |
|
| 164 | ||
| 165 | return Models\User::findOrFail($id); |
|
| 166 | } catch (DisplayValidationException $ex) { |
|
| 167 | throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); |
|
| 168 | } catch (DisplayException $ex) { |
|
| 169 | throw new ResourceException($ex->getMessage()); |
|
| 170 | } catch (\Exception $ex) { |
|
| 171 | throw new ServiceUnavailableHttpException('Unable to update a user on the system due to an error.'); |
|
| 172 | } |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Delete a User. |
|