2020-07-16 17:10:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class ResourceStateEvents < ::API::Base
|
2020-07-16 17:10:05 -04:00
|
|
|
include PaginationParams
|
|
|
|
helpers ::API::Helpers::NotesHelpers
|
|
|
|
|
|
|
|
before { authenticate! }
|
|
|
|
|
2020-10-30 11:08:59 -04:00
|
|
|
{
|
2021-10-27 11:13:41 -04:00
|
|
|
Issue => :team_planning,
|
2020-10-30 11:08:59 -04:00
|
|
|
MergeRequest => :code_review
|
|
|
|
}.each do |eventable_class, feature_category|
|
2020-07-16 17:10:05 -04:00
|
|
|
eventable_name = eventable_class.to_s.underscore
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: "The ID of a project"
|
|
|
|
end
|
|
|
|
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
|
|
|
desc "Get a list of #{eventable_class.to_s.downcase} resource state events" do
|
|
|
|
success Entities::ResourceStateEvent
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :eventable_iid, types: Integer, desc: "The IID of the #{eventable_name}"
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
|
2020-10-30 11:08:59 -04:00
|
|
|
get ":id/#{eventable_name.pluralize}/:eventable_iid/resource_state_events", feature_category: feature_category do
|
2020-07-16 17:10:05 -04:00
|
|
|
eventable = find_noteable(eventable_class, params[:eventable_iid])
|
|
|
|
|
|
|
|
events = ResourceStateEventFinder.new(current_user, eventable).execute
|
|
|
|
|
|
|
|
present paginate(events), with: Entities::ResourceStateEvent
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Get a single #{eventable_class.to_s.downcase} resource state event" do
|
|
|
|
success Entities::ResourceStateEvent
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :eventable_iid, types: Integer, desc: "The IID of the #{eventable_name}"
|
|
|
|
requires :event_id, type: Integer, desc: 'The ID of a resource state event'
|
|
|
|
end
|
2020-10-30 11:08:59 -04:00
|
|
|
get ":id/#{eventable_name.pluralize}/:eventable_iid/resource_state_events/:event_id", feature_category: feature_category do
|
2020-07-16 17:10:05 -04:00
|
|
|
eventable = find_noteable(eventable_class, params[:eventable_iid])
|
|
|
|
|
|
|
|
event = ResourceStateEventFinder.new(current_user, eventable).find(params[:event_id])
|
|
|
|
|
|
|
|
present event, with: Entities::ResourceStateEvent
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|