Commit 906cb8a1 authored by Douwe Maan's avatar Douwe Maan

Merge branch '4812-extract-ee-specific-api-entities' into 'master'

Resolve "Extract API entities EE extensions to a separate `ee/lib/ee/api/entities.rb` file"

Closes #4812

See merge request gitlab-org/gitlab-ee!4386
parents b721780b 47c69fd7
API::API.logger Rails.logger ::API::API.logger Rails.logger
mount API::API => '/' mount ::API::API => '/'
...@@ -59,7 +59,7 @@ module EE ...@@ -59,7 +59,7 @@ module EE
def render_approvals_json def render_approvals_json
respond_to do |format| respond_to do |format|
format.json do format.json do
entity = ::API::Entities::MergeRequestApprovals.new(merge_request, current_user: current_user) entity = EE::API::Entities::MergeRequestApprovals.new(merge_request, current_user: current_user)
render json: entity render json: entity
end end
end end
......
class GeoNodeStatusSerializer < BaseSerializer class GeoNodeStatusSerializer < BaseSerializer
entity API::Entities::GeoNodeStatus entity EE::API::Entities::GeoNodeStatus
end end
...@@ -54,7 +54,7 @@ module API ...@@ -54,7 +54,7 @@ module API
# The issues list in the correct order in body will be returned as part of #4250 # The issues list in the correct order in body will be returned as part of #4250
if result if result
present epic.issues(current_user), present epic.issues(current_user),
with: Entities::EpicIssue, with: EE::API::Entities::EpicIssue,
current_user: current_user current_user: current_user
else else
render_api_error!({ error: "Issue could not be moved!" }, 400) render_api_error!({ error: "Issue could not be moved!" }, 400)
...@@ -62,7 +62,7 @@ module API ...@@ -62,7 +62,7 @@ module API
end end
desc 'Get issues assigned to the epic' do desc 'Get issues assigned to the epic' do
success Entities::EpicIssue success EE::API::Entities::EpicIssue
end end
params do params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic' requires :epic_iid, type: Integer, desc: 'The iid of the epic'
...@@ -71,12 +71,12 @@ module API ...@@ -71,12 +71,12 @@ module API
authorize_can_read! authorize_can_read!
present epic.issues(current_user), present epic.issues(current_user),
with: Entities::EpicIssue, with: EE::API::Entities::EpicIssue,
current_user: current_user current_user: current_user
end end
desc 'Assign an issue to the epic' do desc 'Assign an issue to the epic' do
success Entities::EpicIssueLink success EE::API::Entities::EpicIssueLink
end end
params do params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic' requires :epic_iid, type: Integer, desc: 'The iid of the epic'
...@@ -93,14 +93,14 @@ module API ...@@ -93,14 +93,14 @@ module API
if result[:status] == :success if result[:status] == :success
epic_issue_link = EpicIssue.find_by!(epic: epic, issue: issue) epic_issue_link = EpicIssue.find_by!(epic: epic, issue: issue)
present epic_issue_link, with: Entities::EpicIssueLink present epic_issue_link, with: EE::API::Entities::EpicIssueLink
else else
render_api_error!(result[:message], result[:http_status]) render_api_error!(result[:message], result[:http_status])
end end
end end
desc 'Remove an issue from the epic' do desc 'Remove an issue from the epic' do
success Entities::EpicIssueLink success EE::API::Entities::EpicIssueLink
end end
params do params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic' requires :epic_iid, type: Integer, desc: 'The iid of the epic'
...@@ -112,7 +112,7 @@ module API ...@@ -112,7 +112,7 @@ module API
result = ::EpicIssues::DestroyService.new(link, current_user).execute result = ::EpicIssues::DestroyService.new(link, current_user).execute
if result[:status] == :success if result[:status] == :success
present link, with: Entities::EpicIssueLink present link, with: EE::API::Entities::EpicIssueLink
else else
render_api_error!(result[:message], result[:http_status]) render_api_error!(result[:message], result[:http_status])
end end
......
...@@ -46,7 +46,7 @@ module API ...@@ -46,7 +46,7 @@ module API
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
desc 'Get epics for the group' do desc 'Get epics for the group' do
success Entities::Epic success EE::API::Entities::Epic
end end
params do params do
optional :order_by, type: String, values: %w[created_at updated_at], default: 'created_at', optional :order_by, type: String, values: %w[created_at updated_at], default: 'created_at',
...@@ -58,11 +58,11 @@ module API ...@@ -58,11 +58,11 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names' optional :labels, type: String, desc: 'Comma-separated list of label names'
end end
get ':id/-/epics' do get ':id/-/epics' do
present find_epics(group_id: user_group.id), with: Entities::Epic present find_epics(group_id: user_group.id), with: EE::API::Entities::Epic
end end
desc 'Get details of an epic' do desc 'Get details of an epic' do
success Entities::Epic success EE::API::Entities::Epic
end end
params do params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic' requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
...@@ -70,11 +70,11 @@ module API ...@@ -70,11 +70,11 @@ module API
get ':id/-/epics/:epic_iid' do get ':id/-/epics/:epic_iid' do
authorize_can_read! authorize_can_read!
present epic, with: Entities::Epic present epic, with: EE::API::Entities::Epic
end end
desc 'Create a new epic' do desc 'Create a new epic' do
success Entities::Epic success EE::API::Entities::Epic
end end
params do params do
requires :title, type: String, desc: 'The title of an epic' requires :title, type: String, desc: 'The title of an epic'
...@@ -88,14 +88,14 @@ module API ...@@ -88,14 +88,14 @@ module API
epic = ::Epics::CreateService.new(user_group, current_user, declared_params(include_missing: false)).execute epic = ::Epics::CreateService.new(user_group, current_user, declared_params(include_missing: false)).execute
if epic.valid? if epic.valid?
present epic, with: Entities::Epic present epic, with: EE::API::Entities::Epic
else else
render_validation_error!(epic) render_validation_error!(epic)
end end
end end
desc 'Update an epic' do desc 'Update an epic' do
success Entities::Epic success EE::API::Entities::Epic
end end
params do params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic' requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
...@@ -114,14 +114,14 @@ module API ...@@ -114,14 +114,14 @@ module API
result = ::Epics::UpdateService.new(user_group, current_user, update_params).execute(epic) result = ::Epics::UpdateService.new(user_group, current_user, update_params).execute(epic)
if result.valid? if result.valid?
present result, with: Entities::Epic present result, with: EE::API::Entities::Epic
else else
render_validation_error!(result) render_validation_error!(result)
end end
end end
desc 'Destroy an epic' do desc 'Destroy an epic' do
success Entities::Epic success EE::API::Entities::Epic
end end
params do params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic' requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
......
...@@ -36,7 +36,7 @@ module API ...@@ -36,7 +36,7 @@ module API
authenticate_by_gitlab_geo_node_token! authenticate_by_gitlab_geo_node_token!
status = ::GeoNodeStatus.current_node_status status = ::GeoNodeStatus.current_node_status
present status, with: Entities::GeoNodeStatus present status, with: EE::API::Entities::GeoNodeStatus
end end
end end
......
...@@ -12,13 +12,13 @@ module API ...@@ -12,13 +12,13 @@ module API
# Example request: # Example request:
# GET /geo_nodes # GET /geo_nodes
desc 'Retrieves the available Geo nodes' do desc 'Retrieves the available Geo nodes' do
success Entities::GeoNode success EE::API::Entities::GeoNode
end end
get do get do
nodes = GeoNode.all nodes = GeoNode.all
present paginate(nodes), with: Entities::GeoNode present paginate(nodes), with: EE::API::Entities::GeoNode
end end
# Get all Geo node statuses # Get all Geo node statuses
...@@ -26,12 +26,12 @@ module API ...@@ -26,12 +26,12 @@ module API
# Example request: # Example request:
# GET /geo_nodes/status # GET /geo_nodes/status
desc 'Get status for all Geo nodes' do desc 'Get status for all Geo nodes' do
success Entities::GeoNodeStatus success EE::API::Entities::GeoNodeStatus
end end
get '/status' do get '/status' do
status = GeoNodeStatus.all status = GeoNodeStatus.all
present paginate(status), with: Entities::GeoNodeStatus present paginate(status), with: EE::API::Entities::GeoNodeStatus
end end
# Get project registry failures for the current Geo node # Get project registry failures for the current Geo node
...@@ -78,12 +78,12 @@ module API ...@@ -78,12 +78,12 @@ module API
# Example request: # Example request:
# GET /geo_nodes/:id # GET /geo_nodes/:id
desc 'Get a single GeoNode' do desc 'Get a single GeoNode' do
success Entities::GeoNode success EE::API::Entities::GeoNode
end end
get do get do
not_found!('GeoNode') unless geo_node not_found!('GeoNode') unless geo_node
present geo_node, with: Entities::GeoNode present geo_node, with: EE::API::Entities::GeoNode
end end
# Get Geo metrics for a single node # Get Geo metrics for a single node
...@@ -91,14 +91,14 @@ module API ...@@ -91,14 +91,14 @@ module API
# Example request: # Example request:
# GET /geo_nodes/:id/status # GET /geo_nodes/:id/status
desc 'Get metrics for a single Geo node' do desc 'Get metrics for a single Geo node' do
success Entities::GeoNodeStatus success EE::API::Entities::GeoNodeStatus
end end
get 'status' do get 'status' do
not_found!('GeoNode') unless geo_node not_found!('GeoNode') unless geo_node
not_found!('Status for Geo node not found') unless geo_node_status not_found!('Status for Geo node not found') unless geo_node_status
present geo_node_status, with: Entities::GeoNodeStatus present geo_node_status, with: EE::API::Entities::GeoNodeStatus
end end
# Repair authentication of the Geo node # Repair authentication of the Geo node
...@@ -106,14 +106,14 @@ module API ...@@ -106,14 +106,14 @@ module API
# Example request: # Example request:
# POST /geo_nodes/:id/repair # POST /geo_nodes/:id/repair
desc 'Repair authentication of the Geo node' do desc 'Repair authentication of the Geo node' do
success Entities::GeoNodeStatus success EE::API::Entities::GeoNodeStatus
end end
post 'repair' do post 'repair' do
not_found!('GeoNode') unless geo_node not_found!('GeoNode') unless geo_node
if !geo_node.missing_oauth_application? || geo_node.repair if !geo_node.missing_oauth_application? || geo_node.repair
status 200 status 200
present geo_node_status, with: Entities::GeoNodeStatus present geo_node_status, with: EE::API::Entities::GeoNodeStatus
else else
render_validation_error!(geo_node) render_validation_error!(geo_node)
end end
...@@ -124,7 +124,7 @@ module API ...@@ -124,7 +124,7 @@ module API
# Example request: # Example request:
# PUT /geo_nodes/:id # PUT /geo_nodes/:id
desc 'Edit an existing Geo secondary node' do desc 'Edit an existing Geo secondary node' do
success Entities::GeoNode success EE::API::Entities::GeoNode
end end
params do params do
optional :enabled, type: Boolean, desc: 'Flag indicating if the Geo node is enabled' optional :enabled, type: Boolean, desc: 'Flag indicating if the Geo node is enabled'
...@@ -140,7 +140,7 @@ module API ...@@ -140,7 +140,7 @@ module API
if geo_node.primary? if geo_node.primary?
forbidden!('Primary node cannot be edited') forbidden!('Primary node cannot be edited')
elsif geo_node.update_attributes(update_params) elsif geo_node.update_attributes(update_params)
present geo_node, with: Entities::GeoNode present geo_node, with: EE::API::Entities::GeoNode
else else
render_validation_error!(geo_node) render_validation_error!(geo_node)
end end
......
...@@ -10,20 +10,20 @@ module API ...@@ -10,20 +10,20 @@ module API
end end
resource :projects, requirements: { id: %r{[^/]+} } do resource :projects, requirements: { id: %r{[^/]+} } do
desc 'Get related issues' do desc 'Get related issues' do
success Entities::RelatedIssue success EE::API::Entities::RelatedIssue
end end
get ':id/issues/:issue_iid/links' do get ':id/issues/:issue_iid/links' do
source_issue = find_project_issue(params[:issue_iid]) source_issue = find_project_issue(params[:issue_iid])
related_issues = source_issue.related_issues(current_user) related_issues = source_issue.related_issues(current_user)
present related_issues, present related_issues,
with: Entities::RelatedIssue, with: EE::API::Entities::RelatedIssue,
current_user: current_user, current_user: current_user,
project: user_project project: user_project
end end
desc 'Relate issues' do desc 'Relate issues' do
success Entities::IssueLink success EE::API::Entities::IssueLink
end end
params do params do
requires :target_project_id, type: String, desc: 'The ID of the target project' requires :target_project_id, type: String, desc: 'The ID of the target project'
...@@ -43,14 +43,14 @@ module API ...@@ -43,14 +43,14 @@ module API
if result[:status] == :success if result[:status] == :success
issue_link = IssueLink.find_by!(source: source_issue, target: target_issue) issue_link = IssueLink.find_by!(source: source_issue, target: target_issue)
present issue_link, with: Entities::IssueLink present issue_link, with: EE::API::Entities::IssueLink
else else
render_api_error!(result[:message], result[:http_status]) render_api_error!(result[:message], result[:http_status])
end end
end end
desc 'Remove issues relation' do desc 'Remove issues relation' do
success Entities::IssueLink success EE::API::Entities::IssueLink
end end
params do params do
requires :issue_link_id, type: Integer, desc: 'The ID of an issue link' requires :issue_link_id, type: Integer, desc: 'The ID of an issue link'
...@@ -66,7 +66,7 @@ module API ...@@ -66,7 +66,7 @@ module API
.execute .execute
if result[:status] == :success if result[:status] == :success
present issue_link, with: Entities::IssueLink present issue_link, with: EE::API::Entities::IssueLink
else else
render_api_error!(result[:message], result[:http_status]) render_api_error!(result[:message], result[:http_status])
end end
......
...@@ -15,7 +15,7 @@ module API ...@@ -15,7 +15,7 @@ module API
end end
desc 'Get a LDAP groups list. Limit size to 20 of them.' do desc 'Get a LDAP groups list. Limit size to 20 of them.' do
success Entities::LdapGroup success EE::API::Entities::LdapGroup
end end
params do params do
use :search_params use :search_params
...@@ -23,18 +23,18 @@ module API ...@@ -23,18 +23,18 @@ module API
get 'groups' do get 'groups' do
provider = Gitlab::Auth::LDAP::Config.available_servers.first['provider_name'] provider = Gitlab::Auth::LDAP::Config.available_servers.first['provider_name']
groups = get_group_list(provider, params[:search]) groups = get_group_list(provider, params[:search])
present groups, with: Entities::LdapGroup present groups, with: EE::API::Entities::LdapGroup
end end
desc 'Get a LDAP groups list by the requested provider. Limit size to 20 of them.' do desc 'Get a LDAP groups list by the requested provider. Limit size to 20 of them.' do
success Entities::LdapGroup success EE::API::Entities::LdapGroup
end end
params do params do
use :search_params use :search_params
end end
get ':provider/groups' do get ':provider/groups' do
groups = get_group_list(params[:provider], params[:search]) groups = get_group_list(params[:provider], params[:search])
present groups, with: Entities::LdapGroup present groups, with: EE::API::Entities::LdapGroup
end end
end end
end end
......
...@@ -7,7 +7,7 @@ module API ...@@ -7,7 +7,7 @@ module API
end end
resource :groups do resource :groups do
desc 'Add a linked LDAP group to group' do desc 'Add a linked LDAP group to group' do
success Entities::LdapGroupLink success EE::API::Entities::LdapGroupLink
end end
params do params do
requires 'cn', type: String, desc: 'The CN of a LDAP group' requires 'cn', type: String, desc: 'The CN of a LDAP group'
...@@ -21,7 +21,7 @@ module API ...@@ -21,7 +21,7 @@ module API
ldap_group_link = group.ldap_group_links.new(declared_params(include_missing: false)) ldap_group_link = group.ldap_group_links.new(declared_params(include_missing: false))
if ldap_group_link.save if ldap_group_link.save
present ldap_group_link, with: Entities::LdapGroupLink present ldap_group_link, with: EE::API::Entities::LdapGroupLink
else else
render_api_error!(ldap_group_link.errors.full_messages.first, 409) render_api_error!(ldap_group_link.errors.full_messages.first, 409)
end end
......
...@@ -4,16 +4,16 @@ module API ...@@ -4,16 +4,16 @@ module API
resource :license do resource :license do
desc 'Get information on the currently active license' do desc 'Get information on the currently active license' do
success Entities::GitlabLicense success EE::API::Entities::GitlabLicense
end end
get do get do
license = ::License.current license = ::License.current
present license, with: Entities::GitlabLicense present license, with: EE::API::Entities::GitlabLicense
end end
desc 'Add a new license' do desc 'Add a new license' do
success Entities::GitlabLicense success EE::API::Entities::GitlabLicense
end end
params do params do
requires :license, type: String, desc: 'The license text' requires :license, type: String, desc: 'The license text'
...@@ -21,7 +21,7 @@ module API ...@@ -21,7 +21,7 @@ module API
post do post do
license = ::License.new(data: params[:license]) license = ::License.new(data: params[:license])
if license.save if license.save
present license, with: Entities::GitlabLicense present license, with: EE::API::Entities::GitlabLicense
else else
render_api_error!(license.errors.full_messages.first, 400) render_api_error!(license.errors.full_messages.first, 400)
end end
......
...@@ -25,15 +25,15 @@ module API ...@@ -25,15 +25,15 @@ module API
end end
desc 'Get project push rule' do desc 'Get project push rule' do
success Entities::ProjectPushRule success EE::API::Entities::ProjectPushRule
end end
get ":id/push_rule" do get ":id/push_rule" do
push_rule = user_project.push_rule push_rule = user_project.push_rule
present push_rule, with: Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
end end
desc 'Add a push rule to a project' do desc 'Add a push rule to a project' do
success Entities::ProjectPushRule success EE::API::Entities::ProjectPushRule
end end
params do params do
use :push_rule_params use :push_rule_params
...@@ -43,12 +43,12 @@ module API ...@@ -43,12 +43,12 @@ module API
error!("Project push rule exists", 422) error!("Project push rule exists", 422)
else else
push_rule = user_project.create_push_rule(declared_params(include_missing: false)) push_rule = user_project.create_push_rule(declared_params(include_missing: false))
present push_rule, with: Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
end end
end end
desc 'Update an existing project push rule' do desc 'Update an existing project push rule' do
success Entities::ProjectPushRule success EE::API::Entities::ProjectPushRule
end end
params do params do
use :push_rule_params use :push_rule_params
...@@ -58,7 +58,7 @@ module API ...@@ -58,7 +58,7 @@ module API
not_found!('Push Rule') unless push_rule not_found!('Push Rule') unless push_rule
if push_rule.update_attributes(declared_params(include_missing: false)) if push_rule.update_attributes(declared_params(include_missing: false))
present push_rule, with: Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
else else
render_validation_error!(push_rule) render_validation_error!(push_rule)
end end
......
...@@ -20,16 +20,16 @@ module API ...@@ -20,16 +20,16 @@ module API
end end
desc 'Get project push rule' do desc 'Get project push rule' do
success ::API::Entities::ProjectPushRule success EE::API::Entities::ProjectPushRule
detail DEPRECATION_MESSAGE detail DEPRECATION_MESSAGE
end end
get ":id/git_hook" do get ":id/git_hook" do
push_rule = user_project.push_rule push_rule = user_project.push_rule
present push_rule, with: ::API::Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
end end
desc 'Add a push rule to a project' do desc 'Add a push rule to a project' do
success ::API::Entities::ProjectPushRule success EE::API::Entities::ProjectPushRule
detail DEPRECATION_MESSAGE detail DEPRECATION_MESSAGE
end end
params do params do
...@@ -40,12 +40,12 @@ module API ...@@ -40,12 +40,12 @@ module API
error!("Project push rule exists", 422) error!("Project push rule exists", 422)
else else
push_rule = user_project.create_push_rule(declared_params) push_rule = user_project.create_push_rule(declared_params)
present push_rule, with: ::API::Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
end end
end end
desc 'Update an existing project push rule' do desc 'Update an existing project push rule' do
success ::API::Entities::ProjectPushRule success EE::API::Entities::ProjectPushRule
detail DEPRECATION_MESSAGE detail DEPRECATION_MESSAGE
end end
params do params do
...@@ -56,7 +56,7 @@ module API ...@@ -56,7 +56,7 @@ module API
not_found!('Push Rule') unless push_rule not_found!('Push Rule') unless push_rule
if push_rule.update_attributes(declared_params(include_missing: false)) if push_rule.update_attributes(declared_params(include_missing: false))
present push_rule, with: ::API::Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
else else
render_validation_error!(push_rule) render_validation_error!(push_rule)
end end
......
This diff is collapsed.
require 'spec_helper' require 'spec_helper'
describe API::Entities::GeoNodeStatus, :postgresql do describe EE::API::Entities::GeoNodeStatus, :postgresql do
include ::EE::GeoHelpers include ::EE::GeoHelpers
let(:geo_node_status) { build(:geo_node_status) } let(:geo_node_status) { build(:geo_node_status) }
......
This diff is collapsed.
...@@ -368,12 +368,12 @@ module API ...@@ -368,12 +368,12 @@ module API
# GET /projects/:id/merge_requests/:merge_request_iid/approvals # GET /projects/:id/merge_requests/:merge_request_iid/approvals
# #
desc "List a merge request's approvals" do desc "List a merge request's approvals" do
success Entities::MergeRequestApprovals success EE::API::Entities::MergeRequestApprovals
end end
get ':id/merge_requests/:merge_request_iid/approvals' do get ':id/merge_requests/:merge_request_iid/approvals' do
merge_request = find_merge_request_with_access(params[:merge_request_iid]) merge_request = find_merge_request_with_access(params[:merge_request_iid])
present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end end
# Approve a merge request # Approve a merge request
...@@ -385,7 +385,7 @@ module API ...@@ -385,7 +385,7 @@ module API
# POST /projects/:id/merge_requests/:merge_request_iid/approve # POST /projects/:id/merge_requests/:merge_request_iid/approve
# #
desc 'Approve a merge request' do desc 'Approve a merge request' do
success Entities::MergeRequestApprovals success EE::API::Entities::MergeRequestApprovals
end end
params do params do
optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch' optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
...@@ -401,11 +401,11 @@ module API ...@@ -401,11 +401,11 @@ module API
.new(user_project, current_user) .new(user_project, current_user)
.execute(merge_request) .execute(merge_request)
present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end end
desc 'Remove an approval from a merge request' do desc 'Remove an approval from a merge request' do
success Entities::MergeRequestApprovals success EE::API::Entities::MergeRequestApprovals
end end
post ':id/merge_requests/:merge_request_iid/unapprove' do post ':id/merge_requests/:merge_request_iid/unapprove' do
merge_request = find_project_merge_request(params[:merge_request_iid]) merge_request = find_project_merge_request(params[:merge_request_iid])
...@@ -416,7 +416,7 @@ module API ...@@ -416,7 +416,7 @@ module API
.new(user_project, current_user) .new(user_project, current_user)
.execute(merge_request) .execute(merge_request)
present merge_request, with: Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end end
desc 'List issues that will be closed on merge' do desc 'List issues that will be closed on merge' do
......
...@@ -79,13 +79,13 @@ module API ...@@ -79,13 +79,13 @@ module API
expose :lfs_enabled?, as: :lfs_enabled expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id expose :creator_id
expose :namespace, using: 'API::Entities::Namespace' expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? } expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: ->(project, options) { project.forked? }
expose :avatar_url do |user, options| expose :avatar_url do |user, options|
user.avatar_url(only_path: false) user.avatar_url(only_path: false)
end end
expose :star_count, :forks_count expose :star_count, :forks_count
expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? } expose :open_issues_count, if: ->(project, options) { project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? }
expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] } expose :runners_token, if: ->(_project, options) { options[:user_can_admin_project] }
expose :public_builds expose :public_builds
expose :shared_with_groups do |project, options| expose :shared_with_groups do |project, options|
::API::Entities::SharedGroup.represent(project.project_group_links.all, options) ::API::Entities::SharedGroup.represent(project.project_group_links.all, options)
...@@ -149,13 +149,6 @@ module API ...@@ -149,13 +149,6 @@ module API
class Group < Grape::Entity class Group < Grape::Entity
expose :id, :name, :path, :description, :visibility_level expose :id, :name, :path, :description, :visibility_level
# EE-only
expose :ldap_cn, :ldap_access
expose :ldap_group_links,
using: ::API::Entities::LdapGroupLink,
if: lambda { |group, options| group.ldap_group_links.any? }
# EE-only
expose :lfs_enabled?, as: :lfs_enabled expose :lfs_enabled?, as: :lfs_enabled
expose :avatar_url do |user, options| expose :avatar_url do |user, options|
user.avatar_url(only_path: false) user.avatar_url(only_path: false)
...@@ -302,7 +295,6 @@ module API ...@@ -302,7 +295,6 @@ module API
expose :upvotes, :downvotes expose :upvotes, :downvotes
expose :due_date expose :due_date
expose :confidential expose :confidential
expose :weight, if: ->(issue, _) { issue.supports_weight? }
expose :web_url do |issue, options| expose :web_url do |issue, options|
Gitlab::UrlBuilder.build(issue) Gitlab::UrlBuilder.build(issue)
...@@ -321,3 +313,6 @@ module API ...@@ -321,3 +313,6 @@ module API
end end
end end
end end
API::Entities.prepend_entity(::API::V3::Entities::Group, with: EE::API::Entities::Group)
API::Entities.prepend_entity(::API::V3::Entities::IssueBasic, with: EE::API::Entities::IssueBasic)
...@@ -312,7 +312,7 @@ module API ...@@ -312,7 +312,7 @@ module API
merge_request = user_project.merge_requests.find(params[:merge_request_id]) merge_request = user_project.merge_requests.find(params[:merge_request_id])
authorize! :read_merge_request, merge_request authorize! :read_merge_request, merge_request
present merge_request, with: ::API::Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end end
# Approve a merge request # Approve a merge request
...@@ -332,7 +332,7 @@ module API ...@@ -332,7 +332,7 @@ module API
.new(user_project, current_user) .new(user_project, current_user)
.execute(merge_request) .execute(merge_request)
present merge_request, with: ::API::Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end end
delete "#{path}/unapprove" do delete "#{path}/unapprove" do
...@@ -344,7 +344,7 @@ module API ...@@ -344,7 +344,7 @@ module API
.new(user_project, current_user) .new(user_project, current_user)
.execute(merge_request) .execute(merge_request)
present merge_request, with: ::API::Entities::MergeRequestApprovals, current_user: current_user present merge_request, with: EE::API::Entities::MergeRequestApprovals, current_user: current_user
end end
end end
end 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