Skip to content

WIP: feat: add ML filter resource#1970

Draft
edsavage wants to merge 6 commits intoelastic:mainfrom
edsavage:feat/ml-filter
Draft

WIP: feat: add ML filter resource#1970
edsavage wants to merge 6 commits intoelastic:mainfrom
edsavage:feat/ml-filter

Conversation

@edsavage
Copy link
Copy Markdown
Contributor

@edsavage edsavage commented Mar 23, 2026

Summary

  • Add elasticstack_elasticsearch_ml_filter resource for managing ML filters used in anomaly detection job custom_rules

Details

Supports full CRUD with in-place updates via the dedicated Update filter API. description and items (set of strings) can both be updated in-place — items diffs are computed and sent as add_items/remove_items. filter_id requires replacement.

Test plan

  • Unit tests: 8 cases covering model conversions, null/empty handling
  • Acceptance tests: 3 cases (create+update lifecycle, no-items edge case, import)
  • make build passes (including doc generation)

Made with Cursor

Note

Add elasticstack_elasticsearch_ml_filter resource for Elasticsearch ML filters

  • Implements full CRUD lifecycle for ML filters via PUT /_ml/filters/{filter_id}, GET /_ml/filters/{filter_id}, POST /_ml/filters/{filter_id}/_update, and DELETE /_ml/filters/{filter_id}.
  • Update diffs current vs. planned items to compute add_items/remove_items for the update API.
  • Schema validates filter_id with length (1–64) and regex constraints; changing filter_id forces replacement.
  • Registers the new resource in the provider via plugin_framework.go and includes acceptance and unit tests.

Macroscope summarized 5c80f89. (Automatic summaries will resume when PR exits draft mode or review begins).

Add `elasticstack_elasticsearch_ml_filter` for managing Elasticsearch ML
filters used in anomaly detection job custom_rules.

Supports full CRUD with in-place updates via the Update filter API —
description changes and items diffs (add_items/remove_items) are
computed from the Terraform set diff. Import supported via composite ID.

Includes requirements doc, unit tests (8 cases), acceptance tests
(3 cases), and generated documentation.

Made-with: Cursor
Update filter package to match upstream API renames: ApiClient→APIClient,
CompositeIdFromStr→CompositeIDFromStr, ResourceId→ResourceID,
GetEsFWConnectionBlock signature change.

Made-with: Cursor
- Break long lines in schema.go to stay under 200 char limit (lll)
- Rename exported types to avoid stuttering (revive): FilterTFModel→TFModel,
  FilterCreateAPIModel→CreateAPIModel, FilterAPIModel→APIModel,
  FilterUpdateAPIModel→UpdateAPIModel
- 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