Skip to content

Commit

Permalink
update since date format
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco committed Oct 7, 2024
1 parent 59426ec commit d93c91b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions invenio_cern_sync/authz/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_identities(self, fields=IDENTITY_FIELDS, since=None):
:param fields (list): List of fields to include in the response.
Defaults to IDENTITY_FIELDS.
:param since (string, YYYY-MM-DD, optional): If provided, filters identities
:param since (string, ISO format, optional): If provided, filters identities
modified since this date (includes the ones created since this date).
:return list: A list of user identities matching the criteria.
"""
Expand All @@ -160,8 +160,9 @@ def get_identities(self, fields=IDENTITY_FIELDS, since=None):
]
query_params += [("field", value) for value in fields]
if since:
assert datetime.strptime(since, "%Y-%m-%d")
query_params.append(("filter", f"modificationTime:gt:{since}T00:00:00Z"))
dt = datetime.fromisoformat(since)
ymd = dt.strftime("%Y-%m-%d")
query_params.append(("filter", f"modificationTime:gt:{ymd}T00:00:00Z"))
query_string = urlencode(query_params)

url_without_offset = f"{self.base_url}/api/v1.0/Identity?{query_string}"
Expand All @@ -172,7 +173,7 @@ def get_groups(self, fields=GROUPS_FIELDS, since=None):
:param fields (list): List of fields to include in the response.
Defaults to GROUPS_FIELDS.
:param since (string, YYYY-MM-DD, optional): If provided, filters groups
:param since (string, ISO format, optional): If provided, filters groups
modified since this date (includes the ones created since this date).
:return list: A list of groups matching the criteria.
"""
Expand All @@ -187,8 +188,9 @@ def get_groups(self, fields=GROUPS_FIELDS, since=None):
]
query_params += [("field", value) for value in fields]
if since:
assert datetime.strptime(since, "%Y-%m-%d")
query_params.append(("filter", f"modificationTime:gt:{since}T00:00:00Z"))
dt = datetime.fromisoformat(since)
ymd = dt.strftime("%Y-%m-%d")
query_params.append(("filter", f"modificationTime:gt:{ymd}T00:00:00Z"))
query_string = urlencode(query_params)

url_without_offset = f"{self.base_url}/api/v1.0/Group?{query_string}"
Expand Down

0 comments on commit d93c91b

Please sign in to comment.