diff options
Diffstat (limited to 'qa/qa/resource/project.rb')
-rw-r--r-- | qa/qa/resource/project.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index 59964c5833d..825041cbead 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -224,6 +224,10 @@ module QA "#{api_get_path}/releases" end + def api_housekeeping_path + "/projects/#{id}/housekeeping" + end + def api_post_body post_body = { name: name, @@ -447,6 +451,31 @@ module QA end end + # Calls the API endpoint that triggers the backend service that performs repository housekeeping (garbage + # collection and similar tasks). + def perform_housekeeping + Runtime::Logger.debug("Calling API endpoint #{api_housekeeping_path}") + + response = post(request_url(api_housekeeping_path), nil) + + unless response.code == HTTP_STATUS_CREATED + raise ResourceQueryError, + "Could not perform housekeeping. Request returned (#{response.code}): `#{response.body}`." + end + end + + # Gets project statistics. + # + # @return [Hash] the project usage data including repository size. + def statistics + response = get(request_url("#{api_get_path}?statistics=true")) + data = parse_body(response) + + raise "Could not get project usage statistics" unless data.key?(:statistics) + + data[:statistics] + end + protected # Return subset of fields for comparing projects |