mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(lambda): add support for UpdateFunctionConfiguration AWS API (#472)
This commit is contained in:
1 parent
9a9be34cba
commit
5f07c77237
3 files changed
+111
-2
No files matched your search
@@ -123,6 +123,26 @@ public class LambdaController {
|
||||
return Response.ok(buildFunctionConfiguration(fn)).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── UpdateFunctionConfiguration ────────────────────────────
|
||||
|
||||
@PUT
|
||||
@Path("/functions/{functionName}/configuration")
|
||||
public Response updateFunctionConfiguration(@Context HttpHeaders headers,
|
||||
@PathParam("functionName") String functionName,
|
||||
String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> request = objectMapper.readValue(body, Map.class);
|
||||
LambdaFunction fn = lambdaService.updateFunctionConfiguration(region, functionName, request);
|
||||
return Response.ok(buildFunctionConfiguration(fn)).build();
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new AwsException("InvalidParameterValueException", e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── UpdateFunctionCode ────────────────────────────
|
||||
|
||||
@PUT
|
||||
|
||||
@@ -323,6 +323,48 @@ public class LambdaService {
|
||||
return fn;
|
||||
}
|
||||
|
||||
public LambdaFunction updateFunctionConfiguration(String region, String functionName, Map<String, Object> request) {
|
||||
LambdaFunction fn = getFunction(region, functionName);
|
||||
|
||||
if (request.containsKey("Description")) {
|
||||
fn.setDescription((String) request.get("Description"));
|
||||
}
|
||||
if (request.containsKey("Handler")) {
|
||||
fn.setHandler((String) request.get("Handler"));
|
||||
}
|
||||
if (request.containsKey("MemorySize")) {
|
||||
fn.setMemorySize(((Number) request.get("MemorySize")).intValue());
|
||||
}
|
||||
if (request.containsKey("Role")) {
|
||||
fn.setRole((String) request.get("Role"));
|
||||
}
|
||||
if (request.containsKey("Runtime")) {
|
||||
fn.setRuntime((String) request.get("Runtime"));
|
||||
}
|
||||
if (request.containsKey("Timeout")) {
|
||||
fn.setTimeout(((Number) request.get("Timeout")).intValue());
|
||||
}
|
||||
if (request.containsKey("Environment")) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> envBlock = (Map<String, Object>) request.get("Environment");
|
||||
if (envBlock != null && envBlock.containsKey("Variables")) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> vars = (Map<String, String>) envBlock.get("Variables");
|
||||
fn.setEnvironment(vars != null ? vars : new java.util.HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
fn.setLastModified(System.currentTimeMillis());
|
||||
fn.setRevisionId(UUID.randomUUID().toString());
|
||||
|
||||
// Drain warm containers so the next invocation picks up the new configuration
|
||||
warmPool.drainFunction(functionName);
|
||||
|
||||
functionStore.save(region, fn);
|
||||
LOG.infov("Updated configuration for function: {0}", functionName);
|
||||
return fn;
|
||||
}
|
||||
|
||||
public void deleteFunction(String region, String functionName) {
|
||||
LambdaFunction fn = getFunction(region, functionName); // throws 404 if not found
|
||||
functionName = fn.getFunctionName();
|
||||
|
||||
Reference in new issue
Block a user