Skip to content

Endpoint to get all rules #502

@bracyw

Description

@bracyw

Description

Return all rules in the system with subscriber lists and subscription status for requesting client. Enables efficient rule re-use by making all rules discoverable to all clients, allowing them to subscribe to existing rules instead of creating duplicates.

Acceptance Criteria

  • Returns all rules in system
  • Includes list of all subscribers for each rule
  • If requesting_client_id provided: includes accurate is_subscribed bool
  • If requesting_client_id blank/empty: is_subscribed false for all rules
  • Includes requesting_client_id in response (empty string if not provided)
  • Client_id from URL path parameter (URL encoded, optional)
  • Time: O(R) where R = total rules

Proposed Solution

GET /rules/{requesting_client_id}  (client_id can be empty string)
Response: RulesResponse

where RulesResponse = {
    requesting_client_id: String,
    rules: Vec<ClientRule>
}

where ClientRule = { 
    #[serde(flatten)]
    rule: Rule, 
    subscribers: Vec<ClientId>,
    is_subscribed: bool
}

Add RulesResponse and ClientRule structs to rule_structs.rs. Modify get_all_rules() to accept optional client_id and return RulesResponse. Get rid of the Auth header and instead use the client_id from the path, handle empty string case. Test using Postman, add tests to rule_structs_test.rs.

Mocks

No response

Metadata

Metadata

Assignees

Labels

mediumA more complex taskscylla-serverDevelopment Focused in the Backend

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions