mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
* feat(scheduler): support TagResource, UntagResource, ListTagsForResource
Implements the three remaining EventBridge Scheduler tag APIs by
extending the shared /tags/{arn} dispatcher. Tags apply to schedule
groups only, matching AWS behavior; ARNs pointing at individual
schedules return ValidationException.
A survey of all ~75 AWS services that share the /tags/{arn} path
shows three independent shape axes — body key (`tags` lower vs
`Tags` capital), body structure (map vs list of {Key, Value}), and
untag query parameter name (`tagKeys` vs `TagKeys`) — and most
"capital Tags" services still use lowercase tagKeys query, so these
axes vary independently. TagHandler exposes them as five orthogonal
default methods rather than a coarse-grained enum:
- tagsBodyKey() defaults to "tags"
- tagsBodyIsList() defaults to false (map)
- tagKeysQueryName() defaults to "tagKeys"
- tagResourceUsesPut() defaults to false (POST)
- strictTagValidation() defaults to false (lenient parsing)
The defaults match the most common AWS shape (~73 services use
lowercase tags map + POST + lowercase tagKeys) so handlers like
EKS, Pipes, and AppConfig need no overrides. The dispatcher
returns 405 MethodNotAllowedException for the unused HTTP method
per handler. Strict input validation (missing Tags, wrong-shaped
Tags, missing TagKeys, entries missing Key or Value) is enforced
when strictTagValidation() is true, mirroring the AWS Scheduler
error shape; lenient handlers retain the looser parsing they had
before.
SchedulerTagHandler overrides tagsBodyKey, tagsBodyIsList,
tagKeysQueryName, and strictTagValidation. ApiGatewayTagHandler
overrides tagResourceUsesPut to true. AppConfigIntegrationTest
switches its tagApplication call from PUT to POST to match the
AWS spec for AppConfig (was relying on the dispatcher's prior
leniency on HTTP method).
* fix(tags): normalize empty body and reject non-object payloads
Address Copilot review on floci-io/floci#700.
- doTagResource normalizes null/blank request bodies to "{}" before
passing to ObjectMapper.readTree, mirroring SchedulerController's
parseTags. Previously an empty body raised a Jackson parse error
that strict handlers surfaced as a ValidationException with a raw
Java/Jackson message instead of the structured AWS error shape.
- parseTags adds a strict-only check that the JSON root is an
object. A request body like a JSON array or string used to fall
through to "Value null at 'Tags' ..." which misleads about the
actual problem; it now reports that the payload itself must be a
JSON object.
SchedulerIntegrationTest covers both paths with a 400 assertion.
4.9 KiB
4.9 KiB
EventBridge Scheduler
Protocol: REST JSON
Endpoint: http://localhost:4566/
Supported Actions
| Action | Method | Path | Description |
|---|---|---|---|
CreateScheduleGroup |
POST |
/schedule-groups/{Name} |
Create a schedule group |
GetScheduleGroup |
GET |
/schedule-groups/{Name} |
Get schedule group details |
DeleteScheduleGroup |
DELETE |
/schedule-groups/{Name} |
Delete a schedule group and its schedules |
ListScheduleGroups |
GET |
/schedule-groups |
List schedule groups |
CreateSchedule |
POST |
/schedules/{Name} |
Create a schedule |
GetSchedule |
GET |
/schedules/{Name} |
Get schedule details |
UpdateSchedule |
PUT |
/schedules/{Name} |
Update a schedule |
DeleteSchedule |
DELETE |
/schedules/{Name} |
Delete a schedule |
ListSchedules |
GET |
/schedules |
List schedules |
TagResource |
POST |
/tags/{ResourceArn} |
Add tags to a schedule group |
UntagResource |
DELETE |
/tags/{ResourceArn}?TagKeys=... |
Remove tags from a schedule group |
ListTagsForResource |
GET |
/tags/{ResourceArn} |
List tags on a schedule group |
Schedule Invocation
When floci.services.scheduler.invocation-enabled is true (the default), a
background dispatcher fires schedule targets on time. Supported expressions:
at(YYYY-MM-DDTHH:mm:ss)— one-time fire; honorsScheduleExpressionTimezone(default UTC) andActionAfterCompletion=DELETE.rate(N unit)— repeating fire (minutes,hours,days,weeks).cron(minute hour day-of-month month day-of-week year)— AWS 6-field cron; honorsScheduleExpressionTimezone.
State=DISABLED schedules and schedules outside their StartDate/EndDate
window are skipped. The dispatcher ticks every
floci.services.scheduler.tick-interval-seconds (default 10).
Supported target types: SQS, Lambda, SNS, EventBridge PutEvents.
Not Yet Supported
RetryPolicyandDeadLetterConfigon failed invocations (stored but not honored)FlexibleTimeWindowjitter (fires deterministically at the scheduled time)NextToken-based pagination for List operations
Examples
export AWS_ENDPOINT_URL=http://localhost:4566
# Create a schedule group
aws scheduler create-schedule-group \
--name my-group \
--endpoint-url $AWS_ENDPOINT_URL
# List schedule groups
aws scheduler list-schedule-groups \
--endpoint-url $AWS_ENDPOINT_URL
# Create a schedule in the default group
aws scheduler create-schedule \
--name my-schedule \
--schedule-expression "rate(1 hour)" \
--flexible-time-window '{"Mode":"OFF"}' \
--target '{
"Arn": "arn:aws:lambda:us-east-1:000000000000:function:my-func",
"RoleArn": "arn:aws:iam::000000000000:role/scheduler-role"
}' \
--endpoint-url $AWS_ENDPOINT_URL
# Create a schedule with retry policy and dead-letter queue
aws scheduler create-schedule \
--name my-resilient-schedule \
--schedule-expression "rate(5 minutes)" \
--flexible-time-window '{"Mode":"FLEXIBLE","MaximumWindowInMinutes":10}' \
--target '{
"Arn": "arn:aws:sqs:us-east-1:000000000000:my-queue",
"RoleArn": "arn:aws:iam::000000000000:role/scheduler-role",
"RetryPolicy": {"MaximumEventAgeInSeconds":3600,"MaximumRetryAttempts":5},
"DeadLetterConfig": {"Arn":"arn:aws:sqs:us-east-1:000000000000:my-dlq"}
}' \
--endpoint-url $AWS_ENDPOINT_URL
# Get a schedule
aws scheduler get-schedule \
--name my-schedule \
--endpoint-url $AWS_ENDPOINT_URL
# Update a schedule
aws scheduler update-schedule \
--name my-schedule \
--schedule-expression "rate(30 minutes)" \
--flexible-time-window '{"Mode":"OFF"}' \
--target '{
"Arn": "arn:aws:lambda:us-east-1:000000000000:function:my-func",
"RoleArn": "arn:aws:iam::000000000000:role/scheduler-role"
}' \
--state DISABLED \
--endpoint-url $AWS_ENDPOINT_URL
# Delete a schedule
aws scheduler delete-schedule \
--name my-schedule \
--endpoint-url $AWS_ENDPOINT_URL
# Delete a schedule group (cascades to all schedules in the group)
aws scheduler delete-schedule-group \
--name my-group \
--endpoint-url $AWS_ENDPOINT_URL
# Add tags to a schedule group (tags apply to schedule groups only)
aws scheduler tag-resource \
--resource-arn arn:aws:scheduler:us-east-1:000000000000:schedule-group/my-group \
--tags Key=env,Value=prod Key=owner,Value=Alice \
--endpoint-url $AWS_ENDPOINT_URL
# List tags on a schedule group
aws scheduler list-tags-for-resource \
--resource-arn arn:aws:scheduler:us-east-1:000000000000:schedule-group/my-group \
--endpoint-url $AWS_ENDPOINT_URL
# Remove tags from a schedule group
aws scheduler untag-resource \
--resource-arn arn:aws:scheduler:us-east-1:000000000000:schedule-group/my-group \
--tag-keys env owner \
--endpoint-url $AWS_ENDPOINT_URL
Default Schedule Group
A default schedule group is automatically created on first access. Schedules created without specifying a group are placed in the default group. The default group cannot be deleted.