Expose root_storage_statistics in REST API for top level groups
requested to merge gitlab-community/gitlab:469254-nwittstruck-implement-root-storage-statistics into master
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
What does this MR do and why?
This MR exposes root_storage_statistics
in REST API for top level groups to achieve feature parity with the GraphQL API.
Currently, the REST API does not allow access to the root_storage_statistics. The GraphQL API supports this, e.g. the following query will include the root storage statistics:
query {
groups(search: "abc") {
nodes {
name
fullPath
subgroupCreationLevel
rootStorageStatistics {
containerRegistrySize
}
}
}
}
This MR adds this behaviour to the REST API for top level groups when statistics
is set to true.
Issue: #469254 (closed)
MR acceptance checklist
MR Checklist ( @nwittstruck)
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
Screenshots or screen recordings
Example JSON
output from GET 'https://gdk.test:3443/api/v4/groups/?statistics=true'
[{
"id": 96,
...
"statistics": {
"storage_size": 3040,
"repository_size": 3040,
"wiki_size": 0,
...
},
"root_storage_statistics": {
"build_artifacts_size": 0,
"container_registry_size": 50,
"container_registry_size_is_estimated": false,
"dependency_proxy_size": 0,
"lfs_objects_size": 0,
"packages_size": 0,
"pipeline_artifacts_size": 0,
"repository_size": 3040,
"snippets_size": 0,
"storage_size": 3040,
"uploads_size": 0,
"wiki_size": 0
}
}
]
How to set up and validate locally
- If you need, you can add
root_storage_statistics
like this withrails c
:
root_storage_statistics = Namespace::RootStorageStatistics.new
group = Group.find(<ID of a top-level-group)
group.root_storage_statistics = root_storage_statistics
group.save
- Request groups:
curl -k --request GET \
--url 'https://gdk.test:3443/api/v4/groups/?statistics=true' \
--header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA' \
Related to #469254 (closed)
Edited by Nicholas Wittstruck