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

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

54 lines
1.9 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module API
2021-01-03 14:25:43 +05:30
class ResourceStateEvents < ::API::Base
2020-07-28 23:09:34 +05:30
include PaginationParams
helpers ::API::Helpers::NotesHelpers
before { authenticate! }
2021-01-29 00:20:46 +05:30
{
2021-12-11 22:18:48 +05:30
Issue => :team_planning,
2021-01-29 00:20:46 +05:30
MergeRequest => :code_review
}.each do |eventable_class, feature_category|
2020-07-28 23:09:34 +05:30
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
2022-01-26 12:08:38 +05:30
get ":id/#{eventable_name.pluralize}/:eventable_iid/resource_state_events", feature_category: feature_category, urgency: :low do
2020-07-28 23:09:34 +05:30
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
2021-01-29 00:20:46 +05:30
get ":id/#{eventable_name.pluralize}/:eventable_iid/resource_state_events/:event_id", feature_category: feature_category do
2020-07-28 23:09:34 +05:30
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