diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /lib/api/resource_state_events.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib/api/resource_state_events.rb')
-rw-r--r-- | lib/api/resource_state_events.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/api/resource_state_events.rb b/lib/api/resource_state_events.rb new file mode 100644 index 00000000000..1c1a90c09a3 --- /dev/null +++ b/lib/api/resource_state_events.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module API + class ResourceStateEvents < Grape::API::Instance + include PaginationParams + helpers ::API::Helpers::NotesHelpers + + before { authenticate! } + + [Issue, MergeRequest].each do |eventable_class| + 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 + + get ":id/#{eventable_name.pluralize}/:eventable_iid/resource_state_events" do + 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 + get ":id/#{eventable_name.pluralize}/:eventable_iid/resource_state_events/:event_id" do + 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 |