Commit f41f22b0 authored by Bob Van Landuyt's avatar Bob Van Landuyt Committed by Sean McGivern

Add feature categories to the remaining endpoints

This adds feature categories to the EE and internal endpoints

The rest of the flippin owl...
parent 263a9980
......@@ -5,6 +5,8 @@ module API
class CodeReviewAnalytics < ::API::Base
include PaginationParams
feature_category :planning_analytics
helpers do
def project
@project ||= find_project!(params[:project_id])
......
......@@ -7,6 +7,8 @@ module API
'This feature is gated by the `:group_activity_analytics`'\
' feature flag, introduced in GitLab 12.9.'
feature_category :planning_analytics
before do
authenticate!
end
......
......@@ -4,6 +4,8 @@ module API
class AuditEvents < ::API::Base
include ::API::PaginationParams
feature_category :audit_events
before do
authenticated_as_admin!
forbidden! unless ::License.feature_available?(:admin_audit_log)
......
......@@ -2,6 +2,8 @@
module API
class Dependencies < ::API::Base
feature_category :dependency_scanning
helpers do
def dependencies_by(params)
pipeline = ::Security::ReportFetchService.new(user_project, ::Ci::JobArtifact.dependency_list_reports).pipeline
......
......@@ -4,6 +4,8 @@ module API
class DependencyProxy < ::API::Base
helpers ::API::Helpers::PackagesHelpers
feature_category :dependency_proxy
helpers do
def obtain_new_purge_cache_lease
Gitlab::ExclusiveLease
......
......@@ -4,6 +4,8 @@ module API
class ElasticsearchIndexedNamespaces < ::API::Base
before { authenticated_as_admin! }
feature_category :global_search
resource :elasticsearch_indexed_namespaces do
desc 'Rollout namespaces to be indexed up to n%' do
detail <<~END
......
......@@ -2,6 +2,8 @@
module API
class EpicIssues < ::API::Base
feature_category :issue_tracking
before do
authenticate!
authorize_epics_feature!
......
......@@ -4,6 +4,8 @@ module API
class EpicLinks < ::API::Base
include ::Gitlab::Utils::StrongMemoize
feature_category :issue_tracking
before do
authenticate!
end
......
......@@ -4,6 +4,8 @@ module API
class Epics < ::API::Base
include PaginationParams
feature_category :issue_tracking
before do
authenticate_non_get!
authorize_epics_feature!
......
......@@ -4,6 +4,8 @@ module API
class Experiments < ::API::Base
before { authorize_read_experiments! }
feature_category :product_analytics
resource :experiments do
desc 'Get a list of all experiments' do
success EE::API::Entities::Experiment
......
......@@ -4,6 +4,7 @@ require 'base64'
module API
class Geo < ::API::Base
feature_category :geo_replication
resource :geo do
helpers do
def sanitized_node_status_params
......
......@@ -6,6 +6,8 @@ module API
include APIGuard
include ::Gitlab::Utils::StrongMemoize
feature_category :geo_replication
before do
authenticate_admin_or_geo_node!
end
......
......@@ -6,6 +6,8 @@ module API
include APIGuard
include ::Gitlab::Utils::StrongMemoize
feature_category :geo_replication
before do
authenticated_as_admin!
not_found!('Geo node not found') unless Gitlab::Geo.current_node
......
......@@ -4,6 +4,8 @@ module API
class GroupHooks < ::API::Base
include ::API::PaginationParams
feature_category :integrations
before { authenticate! }
before { authorize! :admin_group, user_group }
......
......@@ -2,6 +2,8 @@
module API
class GroupPushRule < ::API::Base
feature_category :source_code_management
before { authenticate! }
before { check_group_push_rule_access! }
before { authorize_change_param(user_group, :commit_committer_check, :reject_unsigned_commits) }
......
......@@ -4,6 +4,8 @@ module API
class Iterations < ::API::Base
include PaginationParams
feature_category :issue_tracking
helpers do
params :list_params do
optional :state, type: String, values: %w[opened upcoming started closed all], default: 'all',
......
......@@ -8,6 +8,8 @@ module API
# group.
before { authenticated_with_ldap_admin_access! }
feature_category :authentication_and_authorization
resource :ldap do
helpers do
def get_group_list(provider, search)
......
......@@ -4,6 +4,8 @@ module API
class LdapGroupLinks < ::API::Base
before { authenticate! }
feature_category :authentication_and_authorization
params do
requires :id, type: String, desc: 'The ID of a group'
end
......
......@@ -4,6 +4,8 @@ module API
class License < ::API::Base
before { authenticated_as_admin! }
feature_category :provision
resource :license do
desc 'Get information on the currently active license' do
success EE::API::Entities::GitlabLicenseWithActiveUsers
......
......@@ -4,6 +4,8 @@ module API
class ManagedLicenses < ::API::Base
include PaginationParams
feature_category :license_compliance
before { authenticate! unless route.settings[:skip_authentication] }
helpers do
......
......@@ -4,6 +4,8 @@ module API
class MergeRequestApprovalRules < ::API::Base
before { authenticate_non_get! }
feature_category :code_review
helpers do
def find_merge_request_approval_rule(merge_request, id)
merge_request.approval_rules.find_by_id!(id)
......
......@@ -4,6 +4,8 @@ module API
class MergeTrains < ::API::Base
include PaginationParams
feature_category :continuous_integration
before do
authorize_read_merge_trains!
end
......
......@@ -4,6 +4,8 @@ module API
class ProjectAliases < ::API::Base
include PaginationParams
feature_category :source_code_management
before { check_feature_availability }
before { authenticated_as_admin! }
......
......@@ -6,6 +6,8 @@ module API
helpers ::API::Helpers::ProjectApprovalRulesHelpers
feature_category :code_review
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -6,6 +6,8 @@ module API
helpers ::API::Helpers::ProjectApprovalRulesHelpers
feature_category :code_review
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -2,6 +2,8 @@
module API
class ProjectApprovals < ::API::Base
feature_category :code_review
before { authenticate! }
before { authorize! :update_approvers, user_project }
......
......@@ -4,6 +4,8 @@ require_dependency 'declarative_policy'
module API
class ProjectMirror < ::API::Base
feature_category :continuous_integration
helpers do
def github_webhook_signature
@github_webhook_signature ||= headers['X-Hub-Signature']
......
......@@ -2,6 +2,7 @@
module API
class ProjectPushRule < ::API::Base
feature_category :source_code_management
before { authenticate! }
before { authorize_admin_project }
before { check_project_feature_available!(:push_rules) }
......
......@@ -8,6 +8,8 @@ module API
before { authorize_admin_project }
feature_category :continuous_delivery
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -7,7 +7,7 @@ module API
before { authenticate! }
[Issue].each do |eventable_type|
{ Issue => :issue_tracking }.each do |eventable_type, feature_category|
parent_type = eventable_type.parent_class.to_s.underscore
eventables_str = eventable_type.to_s.underscore.pluralize
......@@ -24,7 +24,7 @@ module API
use :pagination
end
get ":id/#{eventables_str}/:eventable_id/resource_iteration_events" do
get ":id/#{eventables_str}/:eventable_id/resource_iteration_events", feature_category: feature_category do
eventable = find_noteable(eventable_type, params[:eventable_id])
events = eventable.resource_iteration_events.with_api_entity_associations
......@@ -39,7 +39,7 @@ module API
requires :event_id, type: String, desc: 'The ID of a resource iteration event'
requires :eventable_id, types: [Integer, String], desc: 'The ID of the eventable'
end
get ":id/#{eventables_str}/:eventable_id/resource_iteration_events/:event_id" do
get ":id/#{eventables_str}/:eventable_id/resource_iteration_events/:event_id", feature_category: feature_category do
eventable = find_noteable(eventable_type, params[:eventable_id])
event = eventable.resource_iteration_events.find(params[:event_id])
......
......@@ -7,6 +7,8 @@ module API
before { authenticate! }
feature_category :issue_tracking
params do
requires :id, type: String, desc: "The ID of a project"
end
......
......@@ -4,6 +4,8 @@ module API
class Scim < ::API::Base
include ::Gitlab::Utils::StrongMemoize
feature_category :authentication_and_authorization
prefix 'api/scim'
version 'v2'
content_type :json, 'application/scim+json'
......
......@@ -6,6 +6,8 @@ module API
helpers ::API::Helpers::NotesHelpers
helpers ::RendersNotes
feature_category :code_review
params do
requires :id, type: String, desc: "The ID of a Project"
end
......
......@@ -5,6 +5,8 @@ module API
include ::API::Helpers::VulnerabilitiesHooks
include PaginationParams
feature_category :vulnerability_management
helpers ::API::Helpers::VulnerabilitiesHelpers
helpers do
......
......@@ -5,6 +5,8 @@ module API
include ::API::Helpers::VulnerabilitiesHooks
include ::Gitlab::Utils::StrongMemoize
feature_category :vulnerability_management
helpers do
def vulnerability_export
strong_memoize(:vulnerability_export) do
......
......@@ -5,6 +5,8 @@ module API
include PaginationParams
include ::Gitlab::Utils::StrongMemoize
feature_category :vulnerability_management
helpers do
def pipeline
strong_memoize(:pipeline) do
......
......@@ -4,6 +4,8 @@ module API
class VulnerabilityIssueLinks < ::API::Base
include ::API::Helpers::VulnerabilitiesHooks
feature_category :vulnerability_management
helpers ::API::Helpers::VulnerabilitiesHelpers
helpers do
......
......@@ -8,6 +8,8 @@ module EE
prepend EE::API::BoardsResponses # rubocop: disable Cop/InjectEnterpriseEditionModule
feature_category :boards
before do
authenticate!
end
......
......@@ -282,7 +282,7 @@ module API
end
end
route :any, '*path' do
route :any, '*path', feature_category: :not_owned do
error!('404 Not Found', 404)
end
end
......
......@@ -7,6 +7,8 @@ module API
before { authenticate! }
feature_category :container_registry
namespace 'registry' do
params do
requires :id, type: String, desc: 'The ID of a project'
......
......@@ -128,13 +128,13 @@ module API
# changes - changes as "oldrev newrev ref", see Gitlab::ChangesList
# check_ip - optional, only in EE version, may limit access to
# group resources based on its IP restrictions
post "/allowed" do
post "/allowed", feature_category: :source_code_management do
# It was moved to a separate method so that EE can alter its behaviour more
# easily.
check_allowed(params)
end
post "/lfs_authenticate" do
post "/lfs_authenticate", feature_category: :source_code_management do
status 200
unless actor.key_or_user
......@@ -152,7 +152,7 @@ module API
# Get a ssh key using the fingerprint
#
# rubocop: disable CodeReuse/ActiveRecord
get '/authorized_keys' do
get '/authorized_keys', feature_category: :source_code_management do
fingerprint = params.fetch(:fingerprint) do
Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
end
......@@ -165,11 +165,11 @@ module API
#
# Discover user by ssh key, user id or username
#
get '/discover' do
get '/discover', feature_category: :authentication_and_authorization do
present actor.user, with: Entities::UserSafe
end
get '/check' do
get '/check', feature_category: :not_owned do
{
api_version: API.version,
gitlab_version: Gitlab::VERSION,
......@@ -178,7 +178,7 @@ module API
}
end
post '/two_factor_recovery_codes' do
post '/two_factor_recovery_codes', feature_category: :authentication_and_authorization do
status 200
actor.update_last_used_at!
......@@ -207,7 +207,7 @@ module API
{ success: true, recovery_codes: codes }
end
post '/personal_access_token' do
post '/personal_access_token', feature_category: :authentication_and_authorization do
status 200
actor.update_last_used_at!
......@@ -257,7 +257,7 @@ module API
{ success: true, token: access_token.token, scopes: access_token.scopes, expires_at: access_token.expires_at }
end
post '/pre_receive' do
post '/pre_receive', feature_category: :source_code_management do
status 200
reference_counter_increased = Gitlab::ReferenceCounter.new(params[:gl_repository]).increase
......@@ -265,7 +265,7 @@ module API
{ reference_counter_increased: reference_counter_increased }
end
post '/post_receive' do
post '/post_receive', feature_category: :source_code_management do
status 200
response = PostReceiveService.new(actor.user, repository, project, params).execute
......@@ -273,7 +273,7 @@ module API
present response, with: Entities::InternalPostReceive::Response
end
post '/two_factor_config' do
post '/two_factor_config', feature_category: :authentication_and_authorization do
status 200
break { success: false } unless Feature.enabled?(:two_factor_for_cli)
......@@ -295,7 +295,7 @@ module API
end
end
post '/two_factor_otp_check' do
post '/two_factor_otp_check', feature_category: :authentication_and_authorization do
status 200
break { success: false } unless Feature.enabled?(:two_factor_for_cli)
......
......@@ -4,6 +4,8 @@ module API
# Kubernetes Internal API
module Internal
class Kubernetes < ::API::Base
feature_category :kubernetes_management
before do
check_feature_enabled
authenticate_gitlab_kas_request!
......
......@@ -7,6 +7,8 @@ module API
before { authenticate_by_gitlab_shell_token! }
feature_category :source_code_management
helpers do
def find_lfs_object(lfs_oid)
LfsObject.find_by_oid(lfs_oid)
......
......@@ -4,6 +4,8 @@ module API
# Pages Internal API
module Internal
class Pages < ::API::Base
feature_category :pages
before do
authenticate_gitlab_pages_request!
end
......
......@@ -4,6 +4,8 @@ module API
class PersonalAccessTokens < ::API::Base
include ::API::PaginationParams
feature_category :authentication_and_authorization
desc 'Get all Personal Access Tokens' do
detail 'This feature was added in GitLab 13.3'
success Entities::PersonalAccessToken
......
......@@ -22,6 +22,8 @@ module API
include PaginationParams
feature_category :integrations
before do
authorize_jira_user_agent!(request)
authenticate!
......
......@@ -18,46 +18,6 @@ RSpec.describe 'Every API endpoint' 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
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, API::Badges,
::API::Boards, ::API::Branches, ::API::BroadcastMessages, ::API::Ci::Pipelines,
::API::Ci::PipelineSchedules, ::API::Ci::Runners, ::API::Ci::Runner,
::API::Commits, ::API::CommitStatuses, ::API::ContainerRegistryEvent,
::API::DeployKeys, ::API::DeployTokens, ::API::Deployments, ::API::Environments,
::API::ErrorTracking, ::API::Events, ::API::FeatureFlags, ::API::FeatureFlagScopes,
::API::FeatureFlagsUserLists, ::API::Features, ::API::Files, ::API::FreezePeriods,
::API::GroupBoards, ::API::GroupClusters, ::API::GroupExport, ::API::GroupImport,
::API::GroupLabels, ::API::GroupMilestones, ::API::Groups,
::API::GroupContainerRepositories, ::API::GroupVariables,
::API::ImportBitbucketServer, ::API::ImportGithub, ::API::IssueLinks,
::API::Issues, ::API::JobArtifacts, ::API::Jobs, ::API::Keys, ::API::Labels,
::API::Lint, ::API::Markdown, ::API::Members, ::API::MergeRequestDiffs,
::API::MergeRequests, ::API::MergeRequestApprovals, ::API::Metrics::Dashboard::Annotations,
::API::Metrics::UserStarredDashboards, ::API::Namespaces, ::API::Notes,
::API::Discussions, ::API::ResourceLabelEvents, ::API::ResourceMilestoneEvents,
::API::ResourceStateEvents, ::API::NotificationSettings, ::API::ProjectPackages,
::API::GroupPackages, ::API::PackageFiles, ::API::NugetPackages, ::API::PypiPackages,
::API::ComposerPackages, ::API::ConanProjectPackages, ::API::ConanInstancePackages,
::API::DebianGroupPackages, ::API::DebianProjectPackages, ::API::MavenPackages,
::API::NpmPackages, ::API::GenericPackages, ::API::GoProxy, ::API::Pages,
::API::PagesDomains, ::API::ProjectClusters, ::API::ProjectContainerRepositories,
::API::ProjectEvents, ::API::ProjectExport, ::API::ProjectImport, ::API::ProjectHooks,
::API::ProjectMilestones, ::API::ProjectRepositoryStorageMoves, ::API::Projects,
::API::ProjectSnapshots, ::API::ProjectSnippets, ::API::ProjectStatistics,
::API::ProjectTemplates, ::API::Terraform::State, ::API::Terraform::StateVersion,
::API::ProtectedBranches, ::API::ProtectedTags, ::API::Releases, ::API::Release::Links,
::API::RemoteMirrors, ::API::Repositories, ::API::Search, ::API::Services,
::API::Settings, ::API::SidekiqMetrics, ::API::Snippets, ::API::Statistics,
::API::Submodules, ::API::Subscriptions, ::API::Suggestions, ::API::SystemHooks,
::API::Tags, ::API::Templates, ::API::Todos, ::API::Triggers, ::API::Unleash,
::API::UsageData, ::API::UserCounts, ::API::Variables, ::API::Version,
::API::Wikis
]
next unless completed_classes.include?(klass)
"#{klass}##{path}"
end.compact.uniq
end
......
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