mirror of
https://github.com/floci-io/floci.git
synced 2026-12-03 02:07:58 -05:00
feat(appconfig): implement UpdateApplication (#7209)
* feat(appconfig): implement UpdateApplication * fix: address AppConfig update review findings * fix: incorporate AppConfig maintainer feedback --------- Co-authored-by: Ovidiu (Ovi) <462561+ovidiubute@users.noreply.github.com>
This commit is contained in:
1 parent
42bc856258
commit
1b87483483
6 files changed
+155
-2
No files matched your search
@@ -17,6 +17,7 @@ import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.HeaderParam;
|
||||
import jakarta.ws.rs.PATCH;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
@@ -64,6 +65,14 @@ public class AppConfigController {
|
||||
return Response.ok(service.getApplication(id)).build();
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("/applications/{id}")
|
||||
public Response updateApplication(@PathParam("id") String id, String body) throws IOException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> request = objectMapper.readValue(body, Map.class);
|
||||
return Response.ok(service.updateApplication(id, request)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/applications")
|
||||
public Response listApplications() {
|
||||
|
||||
@@ -122,11 +122,25 @@ public class AppConfigService {
|
||||
applicationStore.get(applicationId).ifPresent(application -> applicationStore.delete(applicationId));
|
||||
}
|
||||
|
||||
/** Updates only the application fields present in an UpdateApplication request. */
|
||||
public synchronized Application updateApplication(String applicationIdentifier, Map<String, Object> request) {
|
||||
if (request.containsKey("Name") && !(request.get("Name") instanceof String)) {
|
||||
throw new AwsException("BadRequestException", "Name must be a string", 400);
|
||||
}
|
||||
if (request.containsKey("Description") && !(request.get("Description") instanceof String)) {
|
||||
throw new AwsException("BadRequestException", "Description must be a string", 400);
|
||||
}
|
||||
Application app = resolveApplication(applicationIdentifier);
|
||||
String name = request.containsKey("Name") ? (String) request.get("Name") : app.getName();
|
||||
String description = request.containsKey("Description")
|
||||
? (String) request.get("Description") : app.getDescription();
|
||||
return updateApplication(app.getId(), name, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name and description of the application whose ID is {@code applicationId}, as a
|
||||
* CloudFormation update of {@code AWS::AppConfig::Application} does: both are written, so a null
|
||||
* description clears it. Floci serves no UpdateApplication route; the CloudFormation provisioner
|
||||
* is the only caller.
|
||||
* description clears it.
|
||||
*/
|
||||
public synchronized Application updateApplication(String applicationId, String name, String description) {
|
||||
Application app = copy(requireApplicationById(applicationId));
|
||||
|
||||
Reference in new issue
Block a user