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

56 lines
1.2 KiB
Ruby
Raw 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
2020-07-28 23:09:34 +05:30
class Events < Grape::API::Instance
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
2019-05-18 00:54:41 +05:30
allow_access_with_scope :read_user, if: -> (request) { request.get? }
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
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 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
requires :id, type: String, desc: 'The ID or Username of the user'
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
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