From a760d0dc5250e71bd5d8688ec8477b7193546f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Sun, 8 Dec 2024 14:44:12 +0100 Subject: [PATCH] feat: implement ListResponse and SearchQuery index_0 properties --- doc/changelog.rst | 4 ++++ scim2_models/rfc7644/list_response.py | 14 ++++++++++++++ scim2_models/rfc7644/search_request.py | 14 ++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/doc/changelog.rst b/doc/changelog.rst index 8c983d4..ed6cbcf 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -6,6 +6,10 @@ Changelog Added ^^^^^ - Implement :meth:`Schema.get_attribute `. +- Implement :meth:`ListResponse.start_index_0 ` + and :meth:`ListResponse.start_index_1 ` + and :meth:`SearchRequest.start_index_0 ` + and :meth:`SearchRequest.start_index_1 `. [0.2.10] - 2024-12-02 --------------------- diff --git a/scim2_models/rfc7644/list_response.py b/scim2_models/rfc7644/list_response.py index 099bee8..60a0d08 100644 --- a/scim2_models/rfc7644/list_response.py +++ b/scim2_models/rfc7644/list_response.py @@ -121,3 +121,17 @@ def check_results_number( ) return obj + + @property + def start_index_0(self): + """The 0 indexed start index.""" + return self.start_index - 1 if self.start_index is not None else None + + @property + def stop_index_0(self): + """The 0 indexed stop index.""" + return ( + self.start_index_0 + self.count + if self.start_index_0 is not None and self.count is not None + else None + ) diff --git a/scim2_models/rfc7644/search_request.py b/scim2_models/rfc7644/search_request.py index ed0cb8a..e1c0e91 100644 --- a/scim2_models/rfc7644/search_request.py +++ b/scim2_models/rfc7644/search_request.py @@ -76,3 +76,17 @@ def attributes_validator(self): ) return self + + @property + def start_index_0(self): + """The 0 indexed start index.""" + return self.start_index - 1 if self.start_index is not None else None + + @property + def stop_index_0(self): + """The 0 indexed stop index.""" + return ( + self.start_index_0 + self.count + if self.start_index_0 is not None and self.count is not None + else None + )