Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/usage_data.rb')
-rw-r--r--lib/api/usage_data.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/usage_data.rb b/lib/api/usage_data.rb
index 0d1c6cb2281..67bf2725988 100644
--- a/lib/api/usage_data.rb
+++ b/lib/api/usage_data.rb
@@ -2,6 +2,8 @@
module API
class UsageData < ::API::Base
+ include APIGuard
+
before { authenticate_non_get! }
feature_category :service_ping
@@ -12,6 +14,33 @@ module API
forbidden!('Invalid CSRF token is provided') unless verified_request?
end
+ resource :service_ping do
+ allow_access_with_scope :read_service_ping
+
+ before do
+ authenticated_as_admin!
+ end
+
+ desc 'Get the latest ServicePing payload' do
+ detail 'Introduces in Gitlab 16.9. Requires Personal Access Token with read_service_ping scope.'
+ success code: 200
+ failure [
+ { code: 401, message: '401 Unauthorized' },
+ { code: 403, message: 'Forbidden' },
+ { code: 404, message: 'Not found' }
+ ]
+ tags %w[usage_data]
+ produces ['application/json']
+ end
+
+ get do
+ content_type 'application/json'
+
+ Rails.cache.fetch(Gitlab::Usage::ServicePingReport::CACHE_KEY) ||
+ ::RawUsageData.for_current_reporting_cycle.first&.payload || {}
+ end
+ end
+
desc 'Track usage data event' do
detail 'This feature was introduced in GitLab 13.4.'
success code: 200