debian-mirror-gitlab/lib/api/events.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module API
2021-01-03 14:25:43 +05:30
class Events < ::API::Base
2017-09-10 17:25:29 +05:30
include PaginationParams
2018-11-20 20:47:30 +05:30
include APIGuard
2019-05-18 00:54:41 +05:30
helpers ::API::Helpers::EventsHelpers
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
allow_access_with_scope :read_user, if: -> (request) { request.get? || request.head? }
2017-09-10 17:25:29 +05:30
2023-04-23 21:23:45 +05:30
feature_category :user_profile
2022-07-16 23:28:13 +05:30
urgency :low
2021-01-29 00:20:46 +05:30
2017-09-10 17:25:29 +05:30
resource :events do
desc "List currently authenticated user's events" do
detail 'This feature was introduced in GitLab 9.3.'
success Entities::Event
2023-03-04 22:38:38 +05:30
is_array true
failure [
{ code: 401, message: 'Unauthorized' }
]
2017-09-10 17:25:29 +05:30
end
params do
2023-03-04 22:38:38 +05:30
optional :scope, type: String,
desc: 'Include all events across a users projects',
documentation: { example: 'all' }
2017-09-10 17:25:29 +05:30
use :pagination
use :event_filter_params
use :sort_params
end
2019-02-15 15:39:39 +05:30
2017-09-10 17:25:29 +05:30
get do
authenticate!
2019-02-15 15:39:39 +05:30
events = find_events(current_user)
2017-09-10 17:25:29 +05:30
2019-02-15 15:39:39 +05:30
present_events(events)
2017-09-10 17:25:29 +05:30
end
end
params do
2023-03-04 22:38:38 +05:30
requires :id, type: String, desc: 'The ID or username of the user'
2017-09-10 17:25:29 +05:30
end
resource :users do
desc 'Get the contribution events of a specified user' do
detail 'This feature was introduced in GitLab 8.13.'
success Entities::Event
2023-03-04 22:38:38 +05:30
tags %w[events]
is_array true
failure [
{ code: 404, message: 'Not found' }
]
2017-09-10 17:25:29 +05:30
end
params do
use :pagination
use :event_filter_params
use :sort_params
end
2019-02-15 15:39:39 +05:30
2017-09-10 17:25:29 +05:30
get ':id/events' do
user = find_user(params[:id])
not_found!('User') unless user
2019-02-15 15:39:39 +05:30
events = find_events(user)
2017-09-10 17:25:29 +05:30
present_events(events)
end
end
end
end