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

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

66 lines
2.6 KiB
Ruby
Raw Permalink Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module API
2021-01-03 14:25:43 +05:30
class ResourceMilestoneEvents < ::API::Base
2020-06-23 00:09:42 +05:30
include PaginationParams
helpers ::API::Helpers::NotesHelpers
2023-01-13 00:05:48 +05:30
resource_milestone_events_tags = %w[resource_milestone_events]
2020-06-23 00:09:42 +05:30
before { authenticate! }
2021-01-29 00:20:46 +05:30
{
2021-12-11 22:18:48 +05:30
Issue => :team_planning,
2023-03-17 16:20:25 +05:30
MergeRequest => :code_review_workflow
2021-01-29 00:20:46 +05:30
}.each do |eventable_type, feature_category|
2020-06-23 00:09:42 +05:30
parent_type = eventable_type.parent_class.to_s.underscore
eventables_str = eventable_type.to_s.underscore.pluralize
params do
2023-01-13 00:05:48 +05:30
requires :id, types: [String, Integer], desc: "The ID or URL-encoded path of the #{parent_type}"
2020-06-23 00:09:42 +05:30
end
resource parent_type.pluralize.to_sym, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
2023-01-13 00:05:48 +05:30
desc "List project #{eventable_type.underscore.humanize} milestone events" do
detail "Gets a list of all milestone events for a single #{eventable_type.underscore.humanize}"
2020-06-23 00:09:42 +05:30
success Entities::ResourceMilestoneEvent
2023-01-13 00:05:48 +05:30
is_array true
tags resource_milestone_events_tags
2020-06-23 00:09:42 +05:30
end
params do
requires :eventable_id, types: [Integer, String], desc: 'The ID of the eventable'
use :pagination
end
2022-01-26 12:08:38 +05:30
get ":id/#{eventables_str}/:eventable_id/resource_milestone_events", feature_category: feature_category, urgency: :low do
2020-06-23 00:09:42 +05:30
eventable = find_noteable(eventable_type, params[:eventable_id])
2020-07-28 23:09:34 +05:30
events = ResourceMilestoneEventFinder.new(current_user, eventable).execute
2020-06-23 00:09:42 +05:30
present paginate(events), with: Entities::ResourceMilestoneEvent
end
2023-01-13 00:05:48 +05:30
desc "Get single #{eventable_type.underscore.humanize} milestone event" do
detail "Returns a single milestone event for a specific project #{eventable_type.underscore.humanize}"
2020-06-23 00:09:42 +05:30
success Entities::ResourceMilestoneEvent
2023-01-13 00:05:48 +05:30
failure [
{ code: 404, message: 'Not found' }
]
tags resource_milestone_events_tags
2020-06-23 00:09:42 +05:30
end
params do
requires :event_id, type: String, desc: 'The ID of a resource milestone event'
requires :eventable_id, types: [Integer, String], desc: 'The ID of the eventable'
end
2021-01-29 00:20:46 +05:30
get ":id/#{eventables_str}/:eventable_id/resource_milestone_events/:event_id", feature_category: feature_category do
2020-06-23 00:09:42 +05:30
eventable = find_noteable(eventable_type, params[:eventable_id])
event = eventable.resource_milestone_events.find(params[:event_id])
not_found!('ResourceMilestoneEvent') unless can?(current_user, :read_milestone, event.milestone_parent)
present event, with: Entities::ResourceMilestoneEvent
end
end
end
end
end