Commit d1b4de92 authored by Roman Ondráček's avatar Roman Ondráček

API: add endpoint for configuration component instance editing

Signed-off-by: Roman Ondráček's avatarRoman Ondráček <ondracek.roman@centrum.cz>
parent d7a9b298
Pipeline #2204 passed with stages
in 4 minutes and 20 seconds
......@@ -80,6 +80,45 @@ class ConfigController extends BaseController {
return $response->writeJsonBody($this->manager->list());
}
/**
* @Path("/{component}")
* @Method("PUT")
* @OpenApi("
* summary: Edits instance configuration by name
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: string
* ")
* @RequestParameters({
* @RequestParameter(name="component", type="string", description="Component name")
* })
* @Responses({
* @Response(code="200", description="Success"),
* @Response(code="404", description="Not found")
* })
* @param ApiRequest $request API request
* @param ApiResponse $response API response
* @return ApiResponse API response
*/
public function editInstance(ApiRequest $request, ApiResponse $response): ApiResponse {
try {
$json = $request->getJsonBody(true);
$component = urldecode($request->getParameter('component'));
$this->manager->setComponent($component);
$fileName = $this->manager->getInstanceFileName($json['instance']);
$this->manager->setFileName($fileName);
$this->manager->save($json);
} catch (NonExistingJsonSchemaException $e) {
return $response->withStatus(404, 'Component not found.');
} catch (JsonException $e) {
return $response->withStatus(500);
}
return $response;
}
/**
* @Path("/{component}/{instance}")
* @Method("GET")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment