Skip to content

Commit a760d0d

Browse files
committed
feat: implement ListResponse and SearchQuery index_0 properties
1 parent 1ea045f commit a760d0d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Changelog
66
Added
77
^^^^^
88
- Implement :meth:`Schema.get_attribute <scim2_models.Schema.get_attribute>`.
9+
- Implement :meth:`ListResponse.start_index_0 <scim2_models.ListResponse.start_index_0>`
10+
and :meth:`ListResponse.start_index_1 <scim2_models.ListResponse.start_index_1>`
11+
and :meth:`SearchRequest.start_index_0 <scim2_models.SearchRequest.start_index_0>`
12+
and :meth:`SearchRequest.start_index_1 <scim2_models.SearchRequest.start_index_1>`.
913

1014
[0.2.10] - 2024-12-02
1115
---------------------

scim2_models/rfc7644/list_response.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,17 @@ def check_results_number(
121121
)
122122

123123
return obj
124+
125+
@property
126+
def start_index_0(self):
127+
"""The 0 indexed start index."""
128+
return self.start_index - 1 if self.start_index is not None else None
129+
130+
@property
131+
def stop_index_0(self):
132+
"""The 0 indexed stop index."""
133+
return (
134+
self.start_index_0 + self.count
135+
if self.start_index_0 is not None and self.count is not None
136+
else None
137+
)

scim2_models/rfc7644/search_request.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,17 @@ def attributes_validator(self):
7676
)
7777

7878
return self
79+
80+
@property
81+
def start_index_0(self):
82+
"""The 0 indexed start index."""
83+
return self.start_index - 1 if self.start_index is not None else None
84+
85+
@property
86+
def stop_index_0(self):
87+
"""The 0 indexed stop index."""
88+
return (
89+
self.start_index_0 + self.count
90+
if self.start_index_0 is not None and self.count is not None
91+
else None
92+
)

0 commit comments

Comments
 (0)