scim_server/operation_handler/builders/
query.rs

1//! Query builder utilities for ScimQuery
2//!
3//! This module provides convenient builder methods for constructing
4//! ScimQuery instances with various filtering and pagination options.
5
6use crate::operation_handler::core::ScimQuery;
7use serde_json::Value;
8
9impl ScimQuery {
10    /// Create a new empty query.
11    pub fn new() -> Self {
12        Self {
13            count: None,
14            start_index: None,
15            filter: None,
16            attributes: None,
17            excluded_attributes: None,
18            search_attribute: None,
19            search_value: None,
20        }
21    }
22
23    /// Set pagination parameters.
24    pub fn with_pagination(mut self, start_index: usize, count: usize) -> Self {
25        self.start_index = Some(start_index);
26        self.count = Some(count);
27        self
28    }
29
30    /// Set filter expression.
31    pub fn with_filter(mut self, filter: impl Into<String>) -> Self {
32        self.filter = Some(filter.into());
33        self
34    }
35
36    /// Set search parameters.
37    pub fn with_search(mut self, attribute: impl Into<String>, value: Value) -> Self {
38        self.search_attribute = Some(attribute.into());
39        self.search_value = Some(value);
40        self
41    }
42
43    /// Set attributes to include.
44    pub fn with_attributes(mut self, attributes: Vec<String>) -> Self {
45        self.attributes = Some(attributes);
46        self
47    }
48
49    /// Set attributes to exclude.
50    pub fn with_excluded_attributes(mut self, excluded_attributes: Vec<String>) -> Self {
51        self.excluded_attributes = Some(excluded_attributes);
52        self
53    }
54}
55
56impl Default for ScimQuery {
57    fn default() -> Self {
58        Self::new()
59    }
60}