Commit cb9a7736 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bvl-api-feature_categories-5' into 'master'

Add feature categories, Part 5

See merge request gitlab-org/gitlab!46478
parents c711c6fb 19eaaf71
......@@ -6,6 +6,8 @@ module API
before { authorize_read_git_snapshot! }
feature_category :source_code_management
resource :projects do
desc 'Download a (possibly inconsistent) snapshot of a repository' do
detail 'This feature was introduced in GitLab 10.7'
......
......@@ -6,6 +6,8 @@ module API
before { check_snippets_enabled }
feature_category :snippets
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -2,6 +2,8 @@
module API
class ProjectStatistics < ::API::Base
feature_category :source_code_management
before do
authenticate!
authorize! :daily_statistics, user_project
......
......@@ -12,6 +12,8 @@ module API
before { authenticate_non_get! }
feature_category :templates
params do
requires :id, type: String, desc: 'The ID of a project'
requires :type, type: String, values: TEMPLATE_TYPES, desc: 'The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|metrics_dashboard_ymls|issues|merge_requests) of the template'
......
......@@ -8,6 +8,8 @@ module API
before { authorize_admin_project }
feature_category :source_code_management
helpers Helpers::ProtectedBranchesHelpers
params do
......
......@@ -8,6 +8,8 @@ module API
before { authorize_admin_project }
feature_category :source_code_management
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -10,6 +10,8 @@ module API
before { authorize! :read_release, user_project }
feature_category :release_orchestration
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -9,6 +9,8 @@ module API
before { authorize_read_releases! }
feature_category :release_orchestration
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -4,6 +4,8 @@ module API
class RemoteMirrors < ::API::Base
include PaginationParams
feature_category :source_code_management
before do
unauthorized! unless can?(current_user, :admin_remote_mirror, user_project)
end
......
......@@ -12,6 +12,8 @@ module API
before { authorize! :download_code, user_project }
feature_category :source_code_management
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -6,6 +6,8 @@ module API
before { authenticate! }
feature_category :global_search
helpers do
SCOPE_ENTITY = {
merge_requests: Entities::MergeRequestBasic,
......
# frozen_string_literal: true
module API
class Services < ::API::Base
feature_category :integrations
services = Helpers::ServicesHelpers.services
service_classes = Helpers::ServicesHelpers.service_classes
......
......@@ -4,6 +4,8 @@ module API
class Settings < ::API::Base
before { authenticated_as_admin! }
feature_category :not_owned
helpers Helpers::SettingsHelpers
helpers do
......
......@@ -6,6 +6,8 @@ module API
class SidekiqMetrics < ::API::Base
before { authenticated_as_admin! }
feature_category :not_owned
helpers do
def queue_metrics
Sidekiq::Queue.all.each_with_object({}) do |queue, hash|
......
......@@ -5,6 +5,8 @@ module API
class Snippets < ::API::Base
include PaginationParams
feature_category :snippets
resource :snippets do
helpers Helpers::SnippetsHelpers
helpers do
......
......@@ -4,6 +4,8 @@ module API
class Statistics < ::API::Base
before { authenticated_as_admin! }
feature_category :instance_statistics
COUNTED_ITEMS = [Project, User, Group, ForkNetworkMember, ForkNetwork, Issue,
MergeRequest, Note, Snippet, Key, Milestone].freeze
......
......@@ -4,6 +4,8 @@ module API
class Submodules < ::API::Base
before { authenticate! }
feature_category :source_code_management
helpers do
def commit_params(attrs)
{
......
......@@ -11,25 +11,29 @@ module API
type: 'merge_requests',
entity: Entities::MergeRequest,
source: Project,
finder: ->(id) { find_merge_request_with_access(id, :update_merge_request) }
finder: ->(id) { find_merge_request_with_access(id, :update_merge_request) },
feature_category: :code_review
},
{
type: 'issues',
entity: Entities::Issue,
source: Project,
finder: ->(id) { find_project_issue(id) }
finder: ->(id) { find_project_issue(id) },
feature_category: :issue_tracking
},
{
type: 'labels',
entity: Entities::ProjectLabel,
source: Project,
finder: ->(id) { find_label(user_project, id) }
finder: ->(id) { find_label(user_project, id) },
feature_category: :issue_tracking
},
{
type: 'labels',
entity: Entities::GroupLabel,
source: Group,
finder: ->(id) { find_label(user_group, id) }
finder: ->(id) { find_label(user_group, id) },
feature_category: :issue_tracking
}
]
......@@ -44,7 +48,7 @@ module API
desc 'Subscribe to a resource' do
success subscribable[:entity]
end
post ":id/#{subscribable[:type]}/:subscribable_id/subscribe" do
post ":id/#{subscribable[:type]}/:subscribable_id/subscribe", subscribable.slice(:feature_category) do
parent = parent_resource(source_type)
resource = instance_exec(params[:subscribable_id], &subscribable[:finder])
......@@ -59,7 +63,7 @@ module API
desc 'Unsubscribe from a resource' do
success subscribable[:entity]
end
post ":id/#{subscribable[:type]}/:subscribable_id/unsubscribe" do
post ":id/#{subscribable[:type]}/:subscribable_id/unsubscribe", subscribable.slice(:feature_category) do
parent = parent_resource(source_type)
resource = instance_exec(params[:subscribable_id], &subscribable[:finder])
......
......@@ -4,6 +4,8 @@ module API
class Suggestions < ::API::Base
before { authenticate! }
feature_category :code_review
resource :suggestions do
desc 'Apply suggestion patch in the Merge Request it was created' do
success Entities::Suggestion
......
......@@ -4,6 +4,8 @@ module API
class SystemHooks < ::API::Base
include PaginationParams
feature_category :integrations
before do
authenticate!
authenticated_as_admin!
......
......@@ -23,7 +23,7 @@ module API
optional :search, type: String, desc: 'Return list of tags matching the search criteria'
use :pagination
end
get ':id/repository/tags' do
get ':id/repository/tags', feature_category: :source_code_management do
tags = ::TagsFinder.new(user_project.repository,
sort: "#{params[:order_by]}_#{params[:sort]}",
search: params[:search]).execute
......@@ -37,7 +37,7 @@ module API
params do
requires :tag_name, type: String, desc: 'The name of the tag'
end
get ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do
get ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :source_code_management do
tag = user_project.repository.find_tag(params[:tag_name])
not_found!('Tag') unless tag
......@@ -54,7 +54,7 @@ module API
optional :message, type: String, desc: 'Specifying a message creates an annotated tag'
optional :release_description, type: String, desc: 'Specifying release notes stored in the GitLab database (deprecated in GitLab 11.7)'
end
post ':id/repository/tags' do
post ':id/repository/tags', :release_orchestration do
authorize_admin_tag
result = ::Tags::CreateService.new(user_project, current_user)
......@@ -86,7 +86,7 @@ module API
params do
requires :tag_name, type: String, desc: 'The name of the tag'
end
delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do
delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :source_code_management do
authorize_admin_tag
tag = user_project.repository.find_tag(params[:tag_name])
......@@ -112,7 +112,7 @@ module API
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
requires :description, type: String, desc: 'Release notes with markdown support'
end
post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :release_orchestration do
authorize_create_release!
##
......@@ -144,7 +144,7 @@ module API
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
requires :description, type: String, desc: 'Release notes with markdown support'
end
put ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
put ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS, feature_category: :release_orchestration do
authorize_update_release!
result = ::Releases::UpdateService
......
......@@ -4,6 +4,8 @@ module API
class Templates < ::API::Base
include PaginationParams
feature_category :templates
GLOBAL_TEMPLATE_TYPES = {
gitignores: {
gitlab_version: 8.8
......
......@@ -7,6 +7,8 @@ module API
class State < ::API::Base
include ::Gitlab::Utils::StrongMemoize
feature_category :infrastructure_as_code
default_format :json
before do
......
......@@ -5,6 +5,8 @@ module API
class StateVersion < ::API::Base
default_format :json
feature_category :infrastructure_as_code
before do
authenticate!
authorize! :read_terraform_state, user_project
......
......@@ -6,6 +6,8 @@ module API
before { authenticate! }
feature_category :issue_tracking
ISSUABLE_TYPES = {
'merge_requests' => ->(iid) { find_merge_request_with_access(iid) },
'issues' => ->(iid) { find_project_issue(iid) }
......
......@@ -6,6 +6,8 @@ module API
HTTP_GITLAB_EVENT_HEADER = "HTTP_#{WebHookService::GITLAB_EVENT_HEADER}".underscore.upcase
feature_category :continuous_integration
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -4,6 +4,8 @@ module API
class Unleash < ::API::Base
include PaginationParams
feature_category :feature_flags
namespace :feature_flags do
resource :unleash, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
params do
......
......@@ -4,6 +4,8 @@ module API
class UsageData < ::API::Base
before { authenticate! }
feature_category :collection
namespace 'usage_data' do
before do
not_found! unless Feature.enabled?(:usage_data_api, default_enabled: true)
......
......@@ -2,6 +2,8 @@
module API
class UserCounts < ::API::Base
feature_category :navigation
resource :user_counts do
desc 'Return the user specific counts' do
detail 'Open MR Count'
......
......@@ -7,6 +7,8 @@ module API
before { authenticate! }
before { authorize! :admin_build, user_project }
feature_category :continuous_integration
helpers do
def filter_variable_parameters(params)
# This method exists so that EE can more easily filter out certain
......
......@@ -9,6 +9,8 @@ module API
before { authenticate! }
feature_category :not_owned
METADATA_QUERY = <<~EOF
{
metadata {
......
......@@ -4,6 +4,8 @@ module API
class Wikis < ::API::Base
helpers ::API::Helpers::WikisHelpers
feature_category :wiki
helpers do
attr_reader :container
......
......@@ -45,7 +45,16 @@ RSpec.describe 'Every API endpoint' do
::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::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)
......
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