Skip to content

feat(graph): add the driveItem versions API - #3479

Draft
dschmidt wants to merge 1 commit into
feat/graph-driveitem-download-urlfrom
feat/driveitem-versions
Draft

feat(graph): add the driveItem versions API#3479
dschmidt wants to merge 1 commit into
feat/graph-driveitem-download-urlfrom
feat/driveitem-versions

Conversation

@dschmidt

@dschmidt dschmidt commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Implements the driveItemVersion operations from opencloud-eu/libre-graph-api#73 in the graph service, under /v1.0/drives/{drive-id}/items/{item-id}/versions:

  • GET .../versions lists the versions of a file, newest first. The storage does not guarantee an order, so the handler sorts by mtime and key.
  • GET .../versions/{version-id} returns one version. current describes the file itself, as in MS Graph.
  • GET .../versions/{version-id}/content answers with a 302 to a signed, short-lived URL of the WebDAV meta endpoint (/dav/meta/{id}/v/{key}), the same endpoint the web UI downloads versions from. current redirects to the file itself.
  • POST .../versions/{version-id}/restoreVersion returns 204, or 423 when the file is locked.

All four stat the item first and answer 404 for folders, like MS Graph. @microsoft.graph.downloadUrl on versions is opt-in via $select, mirroring the driveItem behaviour. lastModifiedBy stays empty, the storage does not record who created a version.

Stacked on #3248, which provides the URL signer and the /content redirect for driveItems.

The two driveItemVersion models are vendored from the regenerated Go client of the spec PR for now. Once opencloud-eu/libre-graph-api#73 is merged, that commit gets replaced by a regular libre-graph-api-go bump.

@codacy-production

codacy-production Bot commented Sep 7, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 87 complexity

Metric Results
Complexity 87

View in Codacy

🟢 Coverage 74.14% diff coverage · +0.13% coverage variation

Metric Results
Coverage variation +0.13% coverage variation (-1.00%)
Diff coverage 74.14% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5807eea) 88461 20882 23.61%
Head commit (be8cd46) 88692 (+231) 21056 (+174) 23.74% (+0.13%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3479) 232 172 74.14%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dschmidt
dschmidt force-pushed the feat/driveitem-versions branch from 80f3400 to 38975ad Compare September 7, 2026 09:38
@dschmidt
dschmidt force-pushed the feat/driveitem-versions branch from 38975ad to a685d5f Compare September 7, 2026 09:39
@dschmidt
dschmidt force-pushed the feat/driveitem-versions branch from a685d5f to b6acc1c Compare September 7, 2026 10:05
Implements the MS Graph driveItemVersion operations on files:

- GET  .../items/{id}/versions lists the versions, newest first
- GET  .../versions/{version-id} returns one version, "current" describes the file itself
- GET  .../versions/{version-id}/content redirects to a signed download url for the version
- POST .../versions/{version-id}/restoreVersion makes the version the current content

The operations map onto ListFileVersions and RestoreFileVersion of the
gateway. Version downloads point at the WebDAV meta endpoint, signed the
same way as the driveItem download url. The download url is only added
when requested via $select.

The driveItemVersion models are vendored from the regenerated client of
opencloud-eu/libre-graph-api#73 until that spec change is merged and the
dependency can be bumped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant