Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions fulcra_api/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,19 @@ def user_info(fulcra_api: FulcraAPI):
@click.command(
"data-updates", short_help="Return data/file updates that occurred during a period"
)
@click.option(
"--user-id",
type=str,
default=None,
is_eager=True,
help="Fulcra user ID to query data updates for (requires an active datashare from that user).",
)
@time_range
@pass_fulcra_api
@requires_auth
def data_updates(fulcra_api: FulcraAPI, start_time: datetime, end_time: datetime):
def data_updates(
fulcra_api: FulcraAPI, start_time: datetime, end_time: datetime, user_id: str | None
):
"""Return a summary of the data that was updated across TIME_RANGE.

TIME_RANGE: Two start & end date arguments in ISO8601 format or a single interval argument relative to the current time ("1 week", "2 days", "3h", etc.)
Expand All @@ -819,7 +828,9 @@ def data_updates(fulcra_api: FulcraAPI, start_time: datetime, end_time: datetime
the number of records processed for each) and any uploaded files that changed.
"""
try:
resp = fulcra_api.data_updates(start_time, end_time)
resp = fulcra_api.data_updates(
start_time=start_time, end_time=end_time, fulcra_userid=user_id
)
except HTTPError as exc:
raise click.ClickException(exc) from exc

Expand Down
11 changes: 7 additions & 4 deletions fulcra_api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,7 @@ def get_id_token_claims(self) -> dict:
Returns:
A dict containing all JWT claims from the ID token.
"""
if (
self.fulcra_credentials is None
or self.fulcra_credentials.id_token is None
):
if self.fulcra_credentials is None or self.fulcra_credentials.id_token is None:
raise Exception(
"Authorization must occur before retrieving ID token claims."
)
Expand Down Expand Up @@ -1401,6 +1398,7 @@ def data_updates(
self,
start_time: str | datetime.datetime,
end_time: str | datetime.datetime,
fulcra_userid: str | None,
) -> dict:
"""
Retrieve a summary of the data that was updated during the specified
Expand All @@ -1413,6 +1411,7 @@ def data_updates(
Params:
start_time: The start of the time range (inclusive), as an ISO 8601 string or `datetime` object.
end_time: The end of the range (exclusive), as an ISO 8601 string or `datetime` object.
fulcra_userid: Optional Fulcra user ID to get updates for

Returns:
A dict with two keys:
Expand All @@ -1434,6 +1433,10 @@ def data_updates(
"start_time": start_time,
"end_time": end_time,
}

if fulcra_userid is not None:
params["fulcra_userid"] = fulcra_userid

resp = self.fulcra_api("/data/v1/updates", query=params)
return json.loads(resp)

Expand Down