Skip to content

WIP: feat: add ML calendar and calendar event resources#1969

Draft
edsavage wants to merge 10 commits intoelastic:mainfrom
edsavage:feat/ml-calendar
Draft

WIP: feat: add ML calendar and calendar event resources#1969
edsavage wants to merge 10 commits intoelastic:mainfrom
edsavage:feat/ml-calendar

Conversation

@edsavage
Copy link
Copy Markdown

@edsavage edsavage commented Mar 23, 2026

Summary

  • Add elasticstack_elasticsearch_ml_calendar resource for managing ML calendars and job associations
  • Add elasticstack_elasticsearch_ml_calendar_event resource for managing individual scheduled events with RFC3339 times
  • Both resources support import, follow Plugin Framework patterns, and include full test suites

Details

Calendar resource: Creates/deletes via PUT/DELETE calendar API. Updates job associations in-place by diffing job_ids and calling individual PutCalendarJob/DeleteCalendarJob endpoints. description requires replacement (PUT is create-only).

Calendar event resource: Creates via POST calendar events API, deletes via DELETE. No update API exists — all attributes use RequiresReplace. Server-generated event_id is discovered by diffing events before/after creation.

Test plan

  • Unit tests: 16 cases covering model conversions, null/empty handling, composite ID parsing
  • Acceptance tests: 5 cases (CRUD lifecycle, no-jobs, import for both resources)
  • make build passes (including doc generation)

Made with Cursor

Note

Add elasticstack_elasticsearch_ml_calendar and elasticstack_elasticsearch_ml_calendar_event Terraform resources

  • Adds two new Terraform resources for managing Elasticsearch ML anomaly detection calendars and their associated scheduled events.
  • The calendar resource supports create, read, update (job association reconciliation), delete, and import; the calendar event resource supports create, read, delete, and import (update requires replacement).
  • Calendar events are identified by a composite ID of <cluster_uuid>/<calendar_id>/<event_id>; event IDs are assigned by Elasticsearch and discovered by diffing pre/post-create event lists.
  • Time fields (start_time, end_time) use RFC3339 strings in Terraform state and are converted to/from epoch milliseconds for the API.
  • Both resources are registered in provider/plugin_framework.go and include acceptance tests and generated docs.
📊 Macroscope summarized 5a294b1. 29 files reviewed, 5 issues evaluated, 0 issues filtered, 1 comment posted (Automatic summaries will resume when PR exits draft mode or review begins).

🗂️ Filtered Issues

Add two new Terraform resources for managing Elasticsearch ML calendars:

- `elasticstack_elasticsearch_ml_calendar` — manages calendar lifecycle
  and job associations via individual PutCalendarJob/DeleteCalendarJob
  endpoints for in-place job_ids updates.
- `elasticstack_elasticsearch_ml_calendar_event` — manages individual
  scheduled events with RFC3339 time handling and server-generated
  event IDs. All attributes require replacement (no update API).

Both resources support import and follow the existing Plugin Framework
patterns. Includes requirements doc, unit tests (16 cases), acceptance
tests (5 cases), and generated documentation.

Made-with: Cursor
Update calendar and calendar_event packages to match upstream API
renames: ApiClient→APIClient, CompositeIdFromStr→CompositeIDFromStr,
ResourceId→ResourceID, GetEsFWConnectionBlock signature change.

Made-with: Cursor
Replace defer with immediate Close() calls inside the job add/remove
loops to avoid keeping all response bodies open until function return.

Made-with: Cursor
- Break long lines in schema descriptions to stay under 200 char limit (lll)
- Rename exported types to avoid stuttering (revive): CalendarTFModel→TFModel,
  CalendarCreateAPIModel→CreateAPIModel, CalendarAPIModel→APIModel
- Fix gofmt alignment after renames

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant