Skip to content

Expose root_storage_statistics in REST API for top level groups

  • 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)

🛠 with at Siemens

MR acceptance checklist

MR Checklist ( @nwittstruck)

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

  1. If you need, you can add root_storage_statistics like this with rails 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
  1. 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

Merge request reports

Loading