feat: Adds ruleset rule as standalone object instead of element in list und… #6310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The PR introduces rule under ruleset as standalone object, i.e. the lifecycle of the object is independent of the lifecycle of the ruleset object. This allows for easier customisation of the rule object outside of the ruleset itself.
Co-Author: @stefan-todorov
Key Features
Usage example
Blockers
Currently, if applied secondary time while specifying position, the PATCH operation against:
/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}Throws the following error:
PATCH "https://api.cloudflare.com/client/v4/zones/0872c3ad561815a48219d75f13b4f126/rulesets/fbc8242f68644212a6492398ab5b3dd7/rules/b0b748c1a0bd4a978dae3f005dffca88": 400 Bad Request { "result": null, "success": false, "errors": [ { "code": 20011, "message": "'1' is not a valid value for index because the rule is already in that position", "source": { "pointer": "/position/index" } } ], "messages": []This prevents us from covering with tests, but it is also usage blocker.
We believe there should be an API change rather than workaround in the code. Let's open a discussion about it and see how to move forward