summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 12:06:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 12:06:48 +0000
commitbd860c22f6a4b9473cbddd34a53eead8235a7ea1 (patch)
tree3f955a56c2ac90497863da26902a42dba49f3466 /lib/api
parente567b4c2df7dc4085d213db029eff6b6fcde0152 (diff)
downloadgitlab-ce-bd860c22f6a4b9473cbddd34a53eead8235a7ea1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb1
-rw-r--r--lib/api/groups.rb3
-rw-r--r--lib/api/helpers/issues_helpers.rb6
-rw-r--r--lib/api/helpers/services_helpers.rb1
-rw-r--r--lib/api/issues.rb25
-rw-r--r--lib/api/pipelines.rb23
6 files changed, 47 insertions, 12 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 4018ce900e1..9e820f00c42 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -400,6 +400,7 @@ module API
end
class GroupDetail < Group
+ expose :runners_token, if: lambda { |group, options| options[:user_can_admin_group] }
expose :projects, using: Entities::Project do |group, options|
projects = GroupProjectsFinder.new(
group: group,
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index 4ae9b8c70d3..9d1628de7e5 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -173,7 +173,8 @@ module API
options = {
with: params[:with_projects] ? Entities::GroupDetail : Entities::Group,
- current_user: current_user
+ current_user: current_user,
+ user_can_admin_group: can?(current_user, :admin_group, group)
}
group, options = with_custom_attributes(group, options)
diff --git a/lib/api/helpers/issues_helpers.rb b/lib/api/helpers/issues_helpers.rb
index 8addcd18fe3..e272b13f3ae 100644
--- a/lib/api/helpers/issues_helpers.rb
+++ b/lib/api/helpers/issues_helpers.rb
@@ -11,6 +11,9 @@ module API
params :optional_issues_params_ee do
end
+ params :optional_issue_not_params_ee do
+ end
+
def self.update_params_at_least_one_of
[
:assignee_id,
@@ -35,8 +38,11 @@ module API
args = declared_params.merge(args)
args.delete(:id)
+ args[:not] ||= {}
args[:milestone_title] ||= args.delete(:milestone)
+ args[:not][:milestone_title] ||= args[:not]&.delete(:milestone)
args[:label_name] ||= args.delete(:labels)
+ args[:not][:label_name] ||= args[:not]&.delete(:labels)
args[:scope] = args[:scope].underscore if args[:scope]
args[:sort] = "#{args[:order_by]}_#{args[:sort]}"
diff --git a/lib/api/helpers/services_helpers.rb b/lib/api/helpers/services_helpers.rb
index 5331de3c035..eba4ebb4b6e 100644
--- a/lib/api/helpers/services_helpers.rb
+++ b/lib/api/helpers/services_helpers.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
module API
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index 215178478d0..d06550191ad 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -9,28 +9,35 @@ module API
before { authenticate_non_get! }
helpers do
- params :issues_stats_params do
+ params :negatable_issue_filter_params do
optional :labels, type: Array[String], coerce_with: Validations::Types::LabelsList.coerce, desc: 'Comma-separated list of label names'
optional :milestone, type: String, desc: 'Milestone title'
- optional :milestone, type: String, desc: 'Return issues for a specific milestone'
optional :iids, type: Array[Integer], desc: 'The IID array of issues'
optional :search, type: String, desc: 'Search issues for text present in the title, description, or any combination of these'
optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma'
- optional :created_after, type: DateTime, desc: 'Return issues created after the specified time'
- optional :created_before, type: DateTime, desc: 'Return issues created before the specified time'
- optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time'
- optional :updated_before, type: DateTime, desc: 'Return issues updated before the specified time'
optional :author_id, type: Integer, desc: 'Return issues which are authored by the user with the given ID'
optional :author_username, type: String, desc: 'Return issues which are authored by the user with the given username'
mutually_exclusive :author_id, :author_username
optional :assignee_id, types: [Integer, String], integer_none_any: true,
- desc: 'Return issues which are assigned to the user with the given ID'
+ desc: 'Return issues which are assigned to the user with the given ID'
optional :assignee_username, type: Array[String], check_assignees_count: true,
- coerce_with: Validations::CheckAssigneesCount.coerce,
- desc: 'Return issues which are assigned to the user with the given username'
+ coerce_with: Validations::CheckAssigneesCount.coerce,
+ desc: 'Return issues which are assigned to the user with the given username'
mutually_exclusive :assignee_id, :assignee_username
+ end
+
+ params :issues_stats_params do
+ use :negatable_issue_filter_params
+ optional :created_after, type: DateTime, desc: 'Return issues created after the specified time'
+ optional :created_before, type: DateTime, desc: 'Return issues created before the specified time'
+ optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time'
+ optional :updated_before, type: DateTime, desc: 'Return issues updated before the specified time'
+
+ optional :not, type: Hash do
+ use :negatable_issue_filter_params
+ end
optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all],
desc: 'Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`'
diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb
index 9e888368e7b..e09d226a13f 100644
--- a/lib/api/pipelines.rb
+++ b/lib/api/pipelines.rb
@@ -69,6 +69,19 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
+ desc 'Gets a the latest pipeline for the project branch' do
+ detail 'This feature was introduced in GitLab 12.3'
+ success Entities::Pipeline
+ end
+ params do
+ optional :ref, type: String, desc: 'branch ref of pipeline'
+ end
+ get ':id/pipelines/latest' do
+ authorize! :read_pipeline, latest_pipeline
+
+ present latest_pipeline, with: Entities::Pipeline
+ end
+
desc 'Gets a specific pipeline for the project' do
detail 'This feature was introduced in GitLab 8.11'
success Entities::Pipeline
@@ -144,7 +157,15 @@ module API
helpers do
def pipeline
- @pipeline ||= user_project.ci_pipelines.find(params[:pipeline_id])
+ strong_memoize(:pipeline) do
+ user_project.ci_pipelines.find(params[:pipeline_id])
+ end
+ end
+
+ def latest_pipeline
+ strong_memoize(:latest_pipeline) do
+ user_project.latest_pipeline_for_ref(params[:ref])
+ end
end
end
end