Commit bd92cc1e authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add feature categories to all API classes with A

What it says in the title
parent e071343a
......@@ -8,6 +8,8 @@ module API
helpers ::API::Helpers::MembersHelpers
feature_category :authentication_and_authorization
%w[group project].each do |source_type|
params do
requires :id, type: String, desc: "The #{source_type} ID"
......
......@@ -8,6 +8,8 @@ module API
before { authenticated_as_admin! }
feature_category :continuous_integration
namespace 'admin' do
namespace 'ci' do
namespace 'variables' do
......
......@@ -5,6 +5,8 @@ module API
class InstanceClusters < ::API::Base
include PaginationParams
feature_category :kubernetes_management
before do
authenticated_as_admin!
end
......
......@@ -5,6 +5,8 @@ module API
class Sidekiq < ::API::Base
before { authenticated_as_admin! }
feature_category :not_owned
namespace 'admin' do
namespace 'sidekiq' do
namespace 'queues' do
......
......@@ -4,6 +4,8 @@ module API
class Appearance < ::API::Base
before { authenticated_as_admin! }
feature_category :navigation
helpers do
def current_appearance
@current_appearance ||= (::Appearance.current || ::Appearance.new)
......
......@@ -5,6 +5,8 @@ module API
class Applications < ::API::Base
before { authenticated_as_admin! }
feature_category :authentication_and_authorization
resource :applications do
helpers do
def validate_redirect_uri(value)
......
......@@ -2,6 +2,8 @@
module API
class Avatar < ::API::Base
feature_category :users
resource :avatar do
desc 'Return avatar url for a user' do
success Entities::Avatar
......
......@@ -6,9 +6,9 @@ module API
before { authenticate! }
AWARDABLES = [
{ type: 'issue', find_by: :iid },
{ type: 'merge_request', find_by: :iid },
{ type: 'snippet', find_by: :id }
{ type: 'issue', find_by: :iid, feature_category: :issue_tracking },
{ type: 'merge_request', find_by: :iid, feature_category: :code_review },
{ type: 'snippet', find_by: :id, feature_category: :snippets }
].freeze
params do
......@@ -34,7 +34,7 @@ module API
params do
use :pagination
end
get endpoint do
get endpoint, feature_category: awardable_params[:feature_category] do
if can_read_awardable?
awards = awardable.award_emoji
present paginate(awards), with: Entities::AwardEmoji
......@@ -50,7 +50,7 @@ module API
params do
requires :award_id, type: Integer, desc: 'The ID of the award'
end
get "#{endpoint}/:award_id" do
get "#{endpoint}/:award_id", feature_category: awardable_params[:feature_category] do
if can_read_awardable?
present awardable.award_emoji.find(params[:award_id]), with: Entities::AwardEmoji
else
......@@ -65,7 +65,7 @@ module API
params do
requires :name, type: String, desc: 'The name of a award_emoji (without colons)'
end
post endpoint do
post endpoint, feature_category: awardable_params[:feature_category] do
not_found!('Award Emoji') unless can_read_awardable? && can_award_awardable?
service = AwardEmojis::AddService.new(awardable, params[:name], current_user).execute
......@@ -84,7 +84,7 @@ module API
params do
requires :award_id, type: Integer, desc: 'The ID of an award emoji'
end
delete "#{endpoint}/:award_id" do
delete "#{endpoint}/:award_id", feature_category: awardable_params[:feature_category] do
award = awardable.award_emoji.find(params[:award_id])
unauthorized! unless award.user == current_user || current_user.admin?
......
......@@ -17,8 +17,14 @@ RSpec.describe 'Every API endpoint' do
let_it_be(:routes_without_category) do
api_endpoints.map do |(klass, path)|
next if klass.try(:feature_category_for_action, path)
# We'll add the rest in https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/463
next unless klass == ::API::Users || klass == ::API::Issues
completed_classes = [
::API::Users, ::API::Issues, ::API::AccessRequests, ::API::Admin::Ci::Variables,
::API::Admin::InstanceClusters, ::API::Admin::Sidekiq, ::API::Appearance,
::API::Applications, ::API::Avatar, ::API::AwardEmoji
]
next unless completed_classes.include?(klass)
"#{klass}##{path}"
end.compact.uniq
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment