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 ...@@ -8,6 +8,8 @@ module API
helpers ::API::Helpers::MembersHelpers helpers ::API::Helpers::MembersHelpers
feature_category :authentication_and_authorization
%w[group project].each do |source_type| %w[group project].each do |source_type|
params do params do
requires :id, type: String, desc: "The #{source_type} ID" requires :id, type: String, desc: "The #{source_type} ID"
......
...@@ -8,6 +8,8 @@ module API ...@@ -8,6 +8,8 @@ module API
before { authenticated_as_admin! } before { authenticated_as_admin! }
feature_category :continuous_integration
namespace 'admin' do namespace 'admin' do
namespace 'ci' do namespace 'ci' do
namespace 'variables' do namespace 'variables' do
......
...@@ -5,6 +5,8 @@ module API ...@@ -5,6 +5,8 @@ module API
class InstanceClusters < ::API::Base class InstanceClusters < ::API::Base
include PaginationParams include PaginationParams
feature_category :kubernetes_management
before do before do
authenticated_as_admin! authenticated_as_admin!
end end
......
...@@ -5,6 +5,8 @@ module API ...@@ -5,6 +5,8 @@ module API
class Sidekiq < ::API::Base class Sidekiq < ::API::Base
before { authenticated_as_admin! } before { authenticated_as_admin! }
feature_category :not_owned
namespace 'admin' do namespace 'admin' do
namespace 'sidekiq' do namespace 'sidekiq' do
namespace 'queues' do namespace 'queues' do
......
...@@ -4,6 +4,8 @@ module API ...@@ -4,6 +4,8 @@ module API
class Appearance < ::API::Base class Appearance < ::API::Base
before { authenticated_as_admin! } before { authenticated_as_admin! }
feature_category :navigation
helpers do helpers do
def current_appearance def current_appearance
@current_appearance ||= (::Appearance.current || ::Appearance.new) @current_appearance ||= (::Appearance.current || ::Appearance.new)
......
...@@ -5,6 +5,8 @@ module API ...@@ -5,6 +5,8 @@ module API
class Applications < ::API::Base class Applications < ::API::Base
before { authenticated_as_admin! } before { authenticated_as_admin! }
feature_category :authentication_and_authorization
resource :applications do resource :applications do
helpers do helpers do
def validate_redirect_uri(value) def validate_redirect_uri(value)
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module API module API
class Avatar < ::API::Base class Avatar < ::API::Base
feature_category :users
resource :avatar do resource :avatar do
desc 'Return avatar url for a user' do desc 'Return avatar url for a user' do
success Entities::Avatar success Entities::Avatar
......
...@@ -6,9 +6,9 @@ module API ...@@ -6,9 +6,9 @@ module API
before { authenticate! } before { authenticate! }
AWARDABLES = [ AWARDABLES = [
{ type: 'issue', find_by: :iid }, { type: 'issue', find_by: :iid, feature_category: :issue_tracking },
{ type: 'merge_request', find_by: :iid }, { type: 'merge_request', find_by: :iid, feature_category: :code_review },
{ type: 'snippet', find_by: :id } { type: 'snippet', find_by: :id, feature_category: :snippets }
].freeze ].freeze
params do params do
...@@ -34,7 +34,7 @@ module API ...@@ -34,7 +34,7 @@ module API
params do params do
use :pagination use :pagination
end end
get endpoint do get endpoint, feature_category: awardable_params[:feature_category] do
if can_read_awardable? if can_read_awardable?
awards = awardable.award_emoji awards = awardable.award_emoji
present paginate(awards), with: Entities::AwardEmoji present paginate(awards), with: Entities::AwardEmoji
...@@ -50,7 +50,7 @@ module API ...@@ -50,7 +50,7 @@ module API
params do params do
requires :award_id, type: Integer, desc: 'The ID of the award' requires :award_id, type: Integer, desc: 'The ID of the award'
end end
get "#{endpoint}/:award_id" do get "#{endpoint}/:award_id", feature_category: awardable_params[:feature_category] do
if can_read_awardable? if can_read_awardable?
present awardable.award_emoji.find(params[:award_id]), with: Entities::AwardEmoji present awardable.award_emoji.find(params[:award_id]), with: Entities::AwardEmoji
else else
...@@ -65,7 +65,7 @@ module API ...@@ -65,7 +65,7 @@ module API
params do params do
requires :name, type: String, desc: 'The name of a award_emoji (without colons)' requires :name, type: String, desc: 'The name of a award_emoji (without colons)'
end end
post endpoint do post endpoint, feature_category: awardable_params[:feature_category] do
not_found!('Award Emoji') unless can_read_awardable? && can_award_awardable? not_found!('Award Emoji') unless can_read_awardable? && can_award_awardable?
service = AwardEmojis::AddService.new(awardable, params[:name], current_user).execute service = AwardEmojis::AddService.new(awardable, params[:name], current_user).execute
...@@ -84,7 +84,7 @@ module API ...@@ -84,7 +84,7 @@ module API
params do params do
requires :award_id, type: Integer, desc: 'The ID of an award emoji' requires :award_id, type: Integer, desc: 'The ID of an award emoji'
end 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]) award = awardable.award_emoji.find(params[:award_id])
unauthorized! unless award.user == current_user || current_user.admin? unauthorized! unless award.user == current_user || current_user.admin?
......
...@@ -17,8 +17,14 @@ RSpec.describe 'Every API endpoint' do ...@@ -17,8 +17,14 @@ RSpec.describe 'Every API endpoint' do
let_it_be(:routes_without_category) do let_it_be(:routes_without_category) do
api_endpoints.map do |(klass, path)| api_endpoints.map do |(klass, path)|
next if klass.try(:feature_category_for_action, 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 # 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}" "#{klass}##{path}"
end.compact.uniq 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