use super::*;
impl LambdaService {
pub(crate) fn resolve_action(req: &AwsRequest) -> Option<(&'static str, Option<String>)> {
let segs = &req.path_segments;
if segs.is_empty() {
return None;
}
let prefix = segs[0].as_str();
if segs.get(1).map(|s| s.as_str()) == Some("account-settings") && req.method == Method::GET
{
return Some(("GetAccountSettings", None));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("invoke-async")
&& req.method == Method::POST
{
return Some(("InvokeAsync", segs.get(2).map(|s| s.to_string())));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("response-streaming-invocations")
&& req.method == Method::POST
{
return Some((
"InvokeWithResponseStream",
segs.get(2).map(|s| s.to_string()),
));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("concurrency")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::PUT => Some(("PutFunctionConcurrency", res)),
Method::GET => Some(("GetFunctionConcurrency", res)),
Method::DELETE => Some(("DeleteFunctionConcurrency", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("provisioned-concurrency")
{
let res = segs.get(2).map(|s| s.to_string());
if req.method == Method::GET
&& req.query_params.get("List").map(|v| v.as_str()) == Some("ALL")
{
return Some(("ListProvisionedConcurrencyConfigs", res));
}
return match req.method {
Method::PUT => Some(("PutProvisionedConcurrencyConfig", res)),
Method::GET => Some(("GetProvisionedConcurrencyConfig", res)),
Method::DELETE => Some(("DeleteProvisionedConcurrencyConfig", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("provisioned-concurrency-configs")
&& req.method == Method::GET
{
return Some((
"ListProvisionedConcurrencyConfigs",
segs.get(2).map(|s| s.to_string()),
));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("event-invoke-config")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::POST => Some(("PutFunctionEventInvokeConfig", res)),
Method::PUT => Some(("UpdateFunctionEventInvokeConfig", res)),
Method::GET => Some(("GetFunctionEventInvokeConfig", res)),
Method::DELETE => Some(("DeleteFunctionEventInvokeConfig", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& (segs.get(3).map(|s| s.as_str()) == Some("event-invoke-config-list")
|| (segs.get(3).map(|s| s.as_str()) == Some("event-invoke-config")
&& segs.get(4).map(|s| s.as_str()) == Some("list")))
&& req.method == Method::GET
{
return Some((
"ListFunctionEventInvokeConfigs",
segs.get(2).map(|s| s.to_string()),
));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("recursion-config")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::PUT => Some(("PutFunctionRecursionConfig", res)),
Method::GET => Some(("GetFunctionRecursionConfig", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("runtime-management-config")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::PUT => Some(("PutRuntimeManagementConfig", res)),
Method::GET => Some(("GetRuntimeManagementConfig", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("code-signing-config")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::PUT => Some(("PutFunctionCodeSigningConfig", res)),
Method::GET => Some(("GetFunctionCodeSigningConfig", res)),
Method::DELETE => Some(("DeleteFunctionCodeSigningConfig", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("code-signing-configs") {
let res = segs.get(2).map(|s| s.to_string());
return match (
req.method.clone(),
segs.len(),
segs.get(3).map(|s| s.as_str()),
) {
(Method::POST, 2, _) => Some(("CreateCodeSigningConfig", None)),
(Method::GET, 2, _) => Some(("ListCodeSigningConfigs", None)),
(Method::GET, 3, _) => Some(("GetCodeSigningConfig", res)),
(Method::PUT, 3, _) => Some(("UpdateCodeSigningConfig", res)),
(Method::DELETE, 3, _) => Some(("DeleteCodeSigningConfig", res)),
(Method::GET, 4, Some("functions")) => {
Some(("ListFunctionsByCodeSigningConfig", res))
}
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("tags") && segs.len() >= 3 {
let res = segs[2..].join("/");
return match req.method {
Method::POST => Some(("TagResource", Some(res))),
Method::DELETE => Some(("UntagResource", Some(res))),
Method::GET => Some(("ListTags", Some(res))),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("url")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::POST => Some(("CreateFunctionUrlConfig", res)),
Method::GET => Some(("GetFunctionUrlConfig", res)),
Method::PUT => Some(("UpdateFunctionUrlConfig", res)),
Method::DELETE => Some(("DeleteFunctionUrlConfig", res)),
_ => None,
};
}
if segs.get(1).map(|s| s.as_str()) == Some("function-urls")
&& segs.len() == 2
&& req.method == Method::GET
{
return Some(("ListFunctionUrlConfigs", None));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("urls")
&& req.method == Method::GET
{
return Some(("ListFunctionUrlConfigs", segs.get(2).map(|s| s.to_string())));
}
if segs.get(1).map(|s| s.as_str()) == Some("functions")
&& segs.get(3).map(|s| s.as_str()) == Some("function-scaling-config")
{
let res = segs.get(2).map(|s| s.to_string());
return match req.method {
Method::PUT => Some(("PutFunctionScalingConfig", res)),
Method::GET => Some(("GetFunctionScalingConfig", res)),
_ => None,
};
}
if prefix == "2018-10-31" && segs.get(1).map(|s| s.as_str()) == Some("layers") {
let layer = segs.get(2).map(|s| s.to_string());
let third = segs.get(3).map(|s| s.as_str());
let version = segs.get(4).map(|s| s.to_string());
return match (&req.method, segs.len(), third, version.is_some()) {
(&Method::GET, 2, _, _) => Some(("ListLayers", None)),
(&Method::POST, 4, Some("versions"), false) => Some(("PublishLayerVersion", layer)),
(&Method::GET, 4, Some("versions"), false) => {
if req.raw_path.ends_with("/versions/") {
Some(("GetLayerVersion", layer))
} else {
Some(("ListLayerVersions", layer))
}
}
(&Method::GET, 5, Some("versions"), true) => Some(("GetLayerVersion", version)),
(&Method::DELETE, 5, Some("versions"), true) => {
Some(("DeleteLayerVersion", version))
}
(&Method::DELETE, 4, Some("versions"), false)
if req.raw_path.ends_with("/versions/") =>
{
Some(("DeleteLayerVersion", layer))
}
(&Method::GET, 6, Some("versions"), true)
if segs.get(5).map(|s| s.as_str()) == Some("policy") =>
{
Some(("GetLayerVersionPolicy", version))
}
(&Method::POST, 6, Some("versions"), true)
if segs.get(5).map(|s| s.as_str()) == Some("policy") =>
{
Some(("AddLayerVersionPermission", version))
}
(&Method::DELETE, 7, Some("versions"), true)
if segs.get(5).map(|s| s.as_str()) == Some("policy") =>
{
Some(("RemoveLayerVersionPermission", version))
}
_ => None,
};
}
if prefix == "2018-10-31"
&& segs.get(1).map(|s| s.as_str()) == Some("layers-by-arn")
&& req.method == Method::GET
{
return Some(("GetLayerVersionByArn", None));
}
if prefix == "2025-11-30" && segs.get(1).map(|s| s.as_str()) == Some("capacity-providers") {
let name = segs.get(2).map(|s| s.to_string());
if segs.len() == 2 && req.raw_path.ends_with("/capacity-providers/") {
return match req.method {
Method::GET => Some(("GetCapacityProvider", Some(String::new()))),
Method::PUT => Some(("UpdateCapacityProvider", Some(String::new()))),
Method::DELETE => Some(("DeleteCapacityProvider", Some(String::new()))),
_ => None,
};
}
if req
.raw_path
.contains("/capacity-providers//function-versions")
&& req.method == Method::GET
{
return Some((
"ListFunctionVersionsByCapacityProvider",
Some(String::new()),
));
}
return match (
req.method.clone(),
segs.len(),
segs.get(3).map(|s| s.as_str()),
) {
(Method::POST, 2, _) => Some(("CreateCapacityProvider", None)),
(Method::GET, 2, _) => Some(("ListCapacityProviders", None)),
(Method::GET, 3, _) => Some(("GetCapacityProvider", name)),
(Method::PUT, 3, _) => Some(("UpdateCapacityProvider", name)),
(Method::DELETE, 3, _) => Some(("DeleteCapacityProvider", name)),
(Method::GET, 4, Some("function-versions")) => {
Some(("ListFunctionVersionsByCapacityProvider", name))
}
_ => None,
};
}
if prefix == "2025-12-01" {
let collection = segs.get(1).map(|s| s.as_str());
let arn = segs.get(2).map(|s| s.to_string());
let action = segs.get(3).map(|s| s.as_str());
if req.raw_path.contains("/durable-executions//") {
if req.raw_path.ends_with("/checkpoint") && req.method == Method::POST {
return Some(("CheckpointDurableExecution", Some(String::new())));
}
if req.raw_path.ends_with("/stop") && req.method == Method::POST {
return Some(("StopDurableExecution", Some(String::new())));
}
if req.raw_path.ends_with("/history") && req.method == Method::GET {
return Some(("GetDurableExecutionHistory", Some(String::new())));
}
if req.raw_path.ends_with("/state") && req.method == Method::GET {
return Some(("GetDurableExecutionState", Some(String::new())));
}
}
if req.raw_path.ends_with("/durable-executions/") && req.method == Method::GET {
return Some(("GetDurableExecution", Some(String::new())));
}
if req.raw_path.contains("/durable-execution-callbacks//") {
if req.raw_path.ends_with("/succeed") && req.method == Method::POST {
return Some(("SendDurableExecutionCallbackSuccess", Some(String::new())));
}
if req.raw_path.ends_with("/fail") && req.method == Method::POST {
return Some(("SendDurableExecutionCallbackFailure", Some(String::new())));
}
if req.raw_path.ends_with("/heartbeat") && req.method == Method::POST {
return Some(("SendDurableExecutionCallbackHeartbeat", Some(String::new())));
}
}
if req.raw_path.contains("/functions//durable-executions") && req.method == Method::GET
{
return Some(("ListDurableExecutionsByFunction", Some(String::new())));
}
match (req.method.clone(), collection, segs.len(), action) {
(Method::GET, Some("durable-executions"), 3, _) => {
return Some(("GetDurableExecution", arn));
}
(Method::GET, Some("durable-executions"), 4, Some("history")) => {
return Some(("GetDurableExecutionHistory", arn));
}
(Method::GET, Some("durable-executions"), 4, Some("state")) => {
return Some(("GetDurableExecutionState", arn));
}
(Method::POST, Some("durable-executions"), 4, Some("checkpoint")) => {
return Some(("CheckpointDurableExecution", arn));
}
(Method::POST, Some("durable-executions"), 4, Some("stop")) => {
return Some(("StopDurableExecution", arn));
}
(Method::POST, Some("durable-execution-callbacks"), 4, Some("succeed")) => {
return Some(("SendDurableExecutionCallbackSuccess", arn));
}
(Method::POST, Some("durable-execution-callbacks"), 4, Some("fail")) => {
return Some(("SendDurableExecutionCallbackFailure", arn));
}
(Method::POST, Some("durable-execution-callbacks"), 4, Some("heartbeat")) => {
return Some(("SendDurableExecutionCallbackHeartbeat", arn));
}
(Method::GET, Some("functions"), 4, Some("durable-executions")) => {
return Some(("ListDurableExecutionsByFunction", arn));
}
_ => {}
}
}
if prefix != "2015-03-31" {
return None;
}
let collection = segs.get(1).map(|s| s.as_str());
let resource = segs.get(2).map(|s| s.to_string());
let third = segs.get(3).map(|s| s.as_str());
let fourth = segs.get(4).map(|s| s.as_str());
let action = match (&req.method, segs.len(), collection, third) {
(&Method::POST, 2, Some("functions"), _) => "CreateFunction",
(&Method::GET, 2, Some("functions"), _) => "ListFunctions",
(&Method::GET, 3, Some("functions"), _) => "GetFunction",
(&Method::DELETE, 3, Some("functions"), _) => "DeleteFunction",
(&Method::POST, 4, Some("functions"), Some("invocations")) => "Invoke",
(&Method::POST, 4, Some("functions"), Some("invoke-async")) => "InvokeAsync",
(&Method::POST, 4, Some("functions"), Some("response-streaming-invocations")) => {
"InvokeWithResponseStream"
}
(&Method::POST, 4, Some("functions"), Some("versions")) => "PublishVersion",
(&Method::GET, 4, Some("functions"), Some("versions")) => "ListVersionsByFunction",
(&Method::POST, 4, Some("functions"), Some("policy")) => "AddPermission",
(&Method::GET, 4, Some("functions"), Some("policy")) => "GetPolicy",
(&Method::DELETE, 5, Some("functions"), Some("policy")) => "RemovePermission",
(&Method::POST, 4, Some("functions"), Some("aliases")) => "CreateAlias",
(&Method::GET, 4, Some("functions"), Some("aliases")) => {
if req.raw_path.ends_with("/aliases/") {
"GetAlias"
} else {
"ListAliases"
}
}
(&Method::GET, 5, Some("functions"), Some("aliases")) => "GetAlias",
(&Method::PUT, 5, Some("functions"), Some("aliases")) => "UpdateAlias",
(&Method::DELETE, 5, Some("functions"), Some("aliases")) => "DeleteAlias",
(&Method::GET, 4, Some("functions"), Some("configuration")) => {
"GetFunctionConfiguration"
}
(&Method::PUT, 4, Some("functions"), Some("configuration")) => {
"UpdateFunctionConfiguration"
}
(&Method::PUT, 4, Some("functions"), Some("code")) => "UpdateFunctionCode",
(&Method::PUT, 4, Some("functions"), Some("concurrency")) => "PutFunctionConcurrency",
(&Method::GET, 4, Some("functions"), Some("concurrency")) => "GetFunctionConcurrency",
(&Method::DELETE, 4, Some("functions"), Some("concurrency")) => {
"DeleteFunctionConcurrency"
}
(&Method::PUT, 4, Some("functions"), Some("provisioned-concurrency")) => {
"PutProvisionedConcurrencyConfig"
}
(&Method::GET, 4, Some("functions"), Some("provisioned-concurrency")) => {
"GetProvisionedConcurrencyConfig"
}
(&Method::DELETE, 4, Some("functions"), Some("provisioned-concurrency")) => {
"DeleteProvisionedConcurrencyConfig"
}
(&Method::GET, 4, Some("functions"), Some("provisioned-concurrency-configs")) => {
"ListProvisionedConcurrencyConfigs"
}
(&Method::PUT, 4, Some("functions"), Some("event-invoke-config")) => {
"UpdateFunctionEventInvokeConfig"
}
(&Method::POST, 4, Some("functions"), Some("event-invoke-config")) => {
"PutFunctionEventInvokeConfig"
}
(&Method::GET, 4, Some("functions"), Some("event-invoke-config")) => {
"GetFunctionEventInvokeConfig"
}
(&Method::DELETE, 4, Some("functions"), Some("event-invoke-config")) => {
"DeleteFunctionEventInvokeConfig"
}
(&Method::GET, 4, Some("functions"), Some("event-invoke-config-list")) => {
"ListFunctionEventInvokeConfigs"
}
(&Method::PUT, 4, Some("functions"), Some("code-signing-config")) => {
"PutFunctionCodeSigningConfig"
}
(&Method::GET, 4, Some("functions"), Some("code-signing-config")) => {
"GetFunctionCodeSigningConfig"
}
(&Method::DELETE, 4, Some("functions"), Some("code-signing-config")) => {
"DeleteFunctionCodeSigningConfig"
}
(&Method::PUT, 4, Some("functions"), Some("runtime-management-config")) => {
"PutRuntimeManagementConfig"
}
(&Method::GET, 4, Some("functions"), Some("runtime-management-config")) => {
"GetRuntimeManagementConfig"
}
(&Method::PUT, 4, Some("functions"), Some("function-scaling-config")) => {
"PutFunctionScalingConfig"
}
(&Method::GET, 4, Some("functions"), Some("function-scaling-config")) => {
"GetFunctionScalingConfig"
}
(&Method::PUT, 4, Some("functions"), Some("recursion-config")) => {
"PutFunctionRecursionConfig"
}
(&Method::GET, 4, Some("functions"), Some("recursion-config")) => {
"GetFunctionRecursionConfig"
}
(&Method::POST, 2, Some("event-source-mappings"), _) => "CreateEventSourceMapping",
(&Method::GET, 2, Some("event-source-mappings"), _) => "ListEventSourceMappings",
(&Method::GET, 3, Some("event-source-mappings"), _) => "GetEventSourceMapping",
(&Method::PUT, 3, Some("event-source-mappings"), _) => "UpdateEventSourceMapping",
(&Method::DELETE, 3, Some("event-source-mappings"), _) => "DeleteEventSourceMapping",
(&Method::POST, 3, Some("tags"), _) => "TagResource",
(&Method::DELETE, 3, Some("tags"), _) => "UntagResource",
(&Method::GET, 3, Some("tags"), _) => "ListTags",
_ => return None,
};
let _ = fourth;
Some((action, resource))
}
}