summaryrefslogtreecommitdiff
path: root/lib/api/entities
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /lib/api/entities
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'lib/api/entities')
-rw-r--r--lib/api/entities/application_setting.rb2
-rw-r--r--lib/api/entities/board.rb2
-rw-r--r--lib/api/entities/bulk_imports/export_status.rb14
-rw-r--r--lib/api/entities/ci/job_basic.rb5
-rw-r--r--lib/api/entities/ci/pipeline.rb1
-rw-r--r--lib/api/entities/deploy_token.rb3
-rw-r--r--lib/api/entities/environment.rb39
-rw-r--r--lib/api/entities/group.rb2
-rw-r--r--lib/api/entities/group_detail.rb2
-rw-r--r--lib/api/entities/identity.rb2
-rw-r--r--lib/api/entities/issuable_entity.rb2
-rw-r--r--lib/api/entities/issue.rb2
-rw-r--r--lib/api/entities/issue_basic.rb11
-rw-r--r--lib/api/entities/job_request/response.rb2
-rw-r--r--lib/api/entities/label_basic.rb2
-rw-r--r--lib/api/entities/list.rb2
-rw-r--r--lib/api/entities/member.rb2
-rw-r--r--lib/api/entities/merge_request_basic.rb2
-rw-r--r--lib/api/entities/namespace.rb2
-rw-r--r--lib/api/entities/package.rb1
-rw-r--r--lib/api/entities/package_file.rb2
-rw-r--r--lib/api/entities/project.rb2
-rw-r--r--lib/api/entities/protected_branch.rb2
-rw-r--r--lib/api/entities/protected_ref_access.rb2
-rw-r--r--lib/api/entities/release.rb11
-rw-r--r--lib/api/entities/terraform/module_versions.rb11
-rw-r--r--lib/api/entities/todo.rb2
-rw-r--r--lib/api/entities/user_basic.rb2
-rw-r--r--lib/api/entities/user_credit_card_validations.rb9
-rw-r--r--lib/api/entities/user_details_with_admin.rb2
-rw-r--r--lib/api/entities/user_path.rb2
-rw-r--r--lib/api/entities/user_public.rb2
-rw-r--r--lib/api/entities/user_with_admin.rb2
33 files changed, 121 insertions, 30 deletions
diff --git a/lib/api/entities/application_setting.rb b/lib/api/entities/application_setting.rb
index 2468c1f9b18..f23fce40468 100644
--- a/lib/api/entities/application_setting.rb
+++ b/lib/api/entities/application_setting.rb
@@ -36,4 +36,4 @@ module API
end
end
-API::Entities::ApplicationSetting.prepend_if_ee('EE::API::Entities::ApplicationSetting')
+API::Entities::ApplicationSetting.prepend_mod_with('API::Entities::ApplicationSetting')
diff --git a/lib/api/entities/board.rb b/lib/api/entities/board.rb
index fe0182ad772..ee0bea466e0 100644
--- a/lib/api/entities/board.rb
+++ b/lib/api/entities/board.rb
@@ -16,4 +16,4 @@ module API
end
end
-API::Entities::Board.prepend_if_ee('EE::API::Entities::Board')
+API::Entities::Board.prepend_mod_with('API::Entities::Board')
diff --git a/lib/api/entities/bulk_imports/export_status.rb b/lib/api/entities/bulk_imports/export_status.rb
new file mode 100644
index 00000000000..c9c7f34a16a
--- /dev/null
+++ b/lib/api/entities/bulk_imports/export_status.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ module BulkImports
+ class ExportStatus < Grape::Entity
+ expose :relation
+ expose :status
+ expose :error
+ expose :updated_at
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/ci/job_basic.rb b/lib/api/entities/ci/job_basic.rb
index a29788c7abf..c31340f1ff0 100644
--- a/lib/api/entities/ci/job_basic.rb
+++ b/lib/api/entities/ci/job_basic.rb
@@ -6,7 +6,10 @@ module API
class JobBasic < Grape::Entity
expose :id, :status, :stage, :name, :ref, :tag, :coverage, :allow_failure
expose :created_at, :started_at, :finished_at
- expose :duration
+ expose :duration,
+ documentation: { type: 'Floating', desc: 'Time spent running' }
+ expose :queued_duration,
+ documentation: { type: 'Floating', desc: 'Time spent enqueued' }
expose :user, with: ::API::Entities::User
expose :commit, with: ::API::Entities::Commit
expose :pipeline, with: ::API::Entities::Ci::PipelineBasic
diff --git a/lib/api/entities/ci/pipeline.rb b/lib/api/entities/ci/pipeline.rb
index 3dd3b9c9eff..11336ae070d 100644
--- a/lib/api/entities/ci/pipeline.rb
+++ b/lib/api/entities/ci/pipeline.rb
@@ -9,6 +9,7 @@ module API
expose :user, with: Entities::UserBasic
expose :created_at, :updated_at, :started_at, :finished_at, :committed_at
expose :duration
+ expose :queued_duration
expose :coverage
expose :detailed_status, using: DetailedStatusEntity do |pipeline, options|
pipeline.detailed_status(options[:current_user])
diff --git a/lib/api/entities/deploy_token.rb b/lib/api/entities/deploy_token.rb
index 9c5bf54e299..daee104ba6b 100644
--- a/lib/api/entities/deploy_token.rb
+++ b/lib/api/entities/deploy_token.rb
@@ -4,7 +4,8 @@ module API
module Entities
class DeployToken < Grape::Entity
# exposing :token is a security risk and should be avoided
- expose :id, :name, :username, :expires_at, :scopes
+ expose :id, :name, :username, :expires_at, :scopes, :revoked
+ expose :expired?, as: :expired
end
end
end
diff --git a/lib/api/entities/environment.rb b/lib/api/entities/environment.rb
index cb39ce1b13a..91867f3403d 100644
--- a/lib/api/entities/environment.rb
+++ b/lib/api/entities/environment.rb
@@ -3,9 +3,48 @@
module API
module Entities
class Environment < Entities::EnvironmentBasic
+ include RequestAwareEntity
+ include Gitlab::Utils::StrongMemoize
+
expose :project, using: Entities::BasicProjectDetails
expose :last_deployment, using: Entities::Deployment, if: { last_deployment: true }
expose :state
+
+ expose :enable_advanced_logs_querying, if: -> (*) { can_read_pod_logs? } do |environment|
+ environment.elastic_stack_available?
+ end
+
+ expose :logs_api_path, if: -> (*) { can_read_pod_logs? } do |environment|
+ if environment.elastic_stack_available?
+ elasticsearch_project_logs_path(environment.project, environment_name: environment.name, format: :json)
+ else
+ k8s_project_logs_path(environment.project, environment_name: environment.name, format: :json)
+ end
+ end
+
+ expose :gitlab_managed_apps_logs_path, if: -> (*) { can_read_pod_logs? && cluster } do |environment|
+ ::Clusters::ClusterPresenter.new(cluster, current_user: current_user).gitlab_managed_apps_logs_path # rubocop: disable CodeReuse/Presenter
+ end
+
+ private
+
+ alias_method :environment, :object
+
+ def can_read_pod_logs?
+ strong_memoize(:can_read_pod_logs) do
+ current_user&.can?(:read_pod_logs, environment.project)
+ end
+ end
+
+ def cluster
+ strong_memoize(:cluster) do
+ environment&.last_deployment&.cluster
+ end
+ end
+
+ def current_user
+ options[:current_user]
+ end
end
end
end
diff --git a/lib/api/entities/group.rb b/lib/api/entities/group.rb
index e430eba4880..048b7a3c15a 100644
--- a/lib/api/entities/group.rb
+++ b/lib/api/entities/group.rb
@@ -38,4 +38,4 @@ module API
end
end
-API::Entities::Group.prepend_if_ee('EE::API::Entities::Group', with_descendants: true)
+API::Entities::Group.prepend_mod_with('API::Entities::Group', with_descendants: true)
diff --git a/lib/api/entities/group_detail.rb b/lib/api/entities/group_detail.rb
index 2d9d4ca7992..e63a3fc1334 100644
--- a/lib/api/entities/group_detail.rb
+++ b/lib/api/entities/group_detail.rb
@@ -39,4 +39,4 @@ module API
end
end
-API::Entities::GroupDetail.prepend_if_ee('EE::API::Entities::GroupDetail')
+API::Entities::GroupDetail.prepend_mod_with('API::Entities::GroupDetail')
diff --git a/lib/api/entities/identity.rb b/lib/api/entities/identity.rb
index 52045b6250a..7c8cda8f9c2 100644
--- a/lib/api/entities/identity.rb
+++ b/lib/api/entities/identity.rb
@@ -8,4 +8,4 @@ module API
end
end
-API::Entities::Identity.prepend_if_ee('EE::API::Entities::Identity')
+API::Entities::Identity.prepend_mod_with('API::Entities::Identity')
diff --git a/lib/api/entities/issuable_entity.rb b/lib/api/entities/issuable_entity.rb
index e2c674c0b8b..fd5d6c8137f 100644
--- a/lib/api/entities/issuable_entity.rb
+++ b/lib/api/entities/issuable_entity.rb
@@ -24,7 +24,7 @@ module API
# entity according to the current top-level entity options, such
# as the current_user.
def lazy_issuable_metadata
- BatchLoader.for(object).batch(key: [current_user, :issuable_metadata]) do |models, loader, args|
+ BatchLoader.for(object).batch(key: [current_user, :issuable_metadata], replace_methods: false) do |models, loader, args|
current_user = args[:key].first
issuable_metadata = Gitlab::IssuableMetadata.new(current_user, models)
diff --git a/lib/api/entities/issue.rb b/lib/api/entities/issue.rb
index 82102854394..e2506cc596e 100644
--- a/lib/api/entities/issue.rb
+++ b/lib/api/entities/issue.rb
@@ -48,4 +48,4 @@ module API
end
end
-API::Entities::Issue.prepend_if_ee('EE::API::Entities::Issue')
+API::Entities::Issue.prepend_mod_with('API::Entities::Issue')
diff --git a/lib/api/entities/issue_basic.rb b/lib/api/entities/issue_basic.rb
index cf96c6556ec..d27cc5498bd 100644
--- a/lib/api/entities/issue_basic.rb
+++ b/lib/api/entities/issue_basic.rb
@@ -3,6 +3,10 @@
module API
module Entities
class IssueBasic < IssuableEntity
+ format_with(:upcase) do |item|
+ item.upcase if item.respond_to?(:upcase)
+ end
+
expose :closed_at
expose :closed_by, using: Entities::UserBasic
@@ -16,6 +20,10 @@ module API
expose :milestone, using: Entities::Milestone
expose :assignees, :author, using: Entities::UserBasic
+ expose :issue_type,
+ as: :type,
+ format_with: :upcase,
+ documentation: { type: "String", desc: "One of #{Issue.issue_types.keys.map(&:upcase)}" }
expose :assignee, using: ::API::Entities::UserBasic do |issue|
issue.assignees.first
@@ -28,6 +36,7 @@ module API
expose :due_date
expose :confidential
expose :discussion_locked
+ expose :issue_type
expose :web_url do |issue|
Gitlab::UrlBuilder.build(issue)
@@ -42,4 +51,4 @@ module API
end
end
-API::Entities::IssueBasic.prepend_if_ee('EE::API::Entities::IssueBasic', with_descendants: true)
+API::Entities::IssueBasic.prepend_mod_with('API::Entities::IssueBasic', with_descendants: true)
diff --git a/lib/api/entities/job_request/response.rb b/lib/api/entities/job_request/response.rb
index bf22ea1e6e2..2e8dfc5bde0 100644
--- a/lib/api/entities/job_request/response.rb
+++ b/lib/api/entities/job_request/response.rb
@@ -34,4 +34,4 @@ module API
end
end
-API::Entities::JobRequest::Response.prepend_if_ee('EE::API::Entities::JobRequest::Response')
+API::Entities::JobRequest::Response.prepend_mod_with('API::Entities::JobRequest::Response')
diff --git a/lib/api/entities/label_basic.rb b/lib/api/entities/label_basic.rb
index ed52688638e..00ecea26ec3 100644
--- a/lib/api/entities/label_basic.rb
+++ b/lib/api/entities/label_basic.rb
@@ -3,7 +3,7 @@
module API
module Entities
class LabelBasic < Grape::Entity
- expose :id, :name, :color, :description, :description_html, :text_color
+ expose :id, :name, :color, :description, :description_html, :text_color, :remove_on_close
end
end
end
diff --git a/lib/api/entities/list.rb b/lib/api/entities/list.rb
index 480e722c22c..e9d31827e2f 100644
--- a/lib/api/entities/list.rb
+++ b/lib/api/entities/list.rb
@@ -10,4 +10,4 @@ module API
end
end
-API::Entities::List.prepend_if_ee('EE::API::Entities::List')
+API::Entities::List.prepend_mod_with('API::Entities::List')
diff --git a/lib/api/entities/member.rb b/lib/api/entities/member.rb
index ad62f92e5a0..87f03adba31 100644
--- a/lib/api/entities/member.rb
+++ b/lib/api/entities/member.rb
@@ -11,4 +11,4 @@ module API
end
end
-API::Entities::Member.prepend_if_ee('EE::API::Entities::Member', with_descendants: true)
+API::Entities::Member.prepend_mod_with('API::Entities::Member', with_descendants: true)
diff --git a/lib/api/entities/merge_request_basic.rb b/lib/api/entities/merge_request_basic.rb
index 88c84c494e2..cf8d03bf176 100644
--- a/lib/api/entities/merge_request_basic.rb
+++ b/lib/api/entities/merge_request_basic.rb
@@ -89,4 +89,4 @@ module API
end
end
-API::Entities::MergeRequestBasic.prepend_if_ee('EE::API::Entities::MergeRequestBasic', with_descendants: true)
+API::Entities::MergeRequestBasic.prepend_mod_with('API::Entities::MergeRequestBasic', with_descendants: true)
diff --git a/lib/api/entities/namespace.rb b/lib/api/entities/namespace.rb
index a7e06cc3e02..f11303d41a6 100644
--- a/lib/api/entities/namespace.rb
+++ b/lib/api/entities/namespace.rb
@@ -14,4 +14,4 @@ module API
end
end
-API::Entities::Namespace.prepend_if_ee('EE::API::Entities::Namespace')
+API::Entities::Namespace.prepend_mod_with('API::Entities::Namespace')
diff --git a/lib/api/entities/package.rb b/lib/api/entities/package.rb
index e7153f9bebb..2f60a0bf6bd 100644
--- a/lib/api/entities/package.rb
+++ b/lib/api/entities/package.rb
@@ -22,6 +22,7 @@ module API
expose :version
expose :package_type
+ expose :status
expose :_links do
expose :web_path do |package|
diff --git a/lib/api/entities/package_file.rb b/lib/api/entities/package_file.rb
index 2cc2f62a948..e34a6a7aa1d 100644
--- a/lib/api/entities/package_file.rb
+++ b/lib/api/entities/package_file.rb
@@ -5,7 +5,7 @@ module API
class PackageFile < Grape::Entity
expose :id, :package_id, :created_at
expose :file_name, :size
- expose :file_md5, :file_sha1
+ expose :file_md5, :file_sha1, :file_sha256
expose :pipelines, if: ->(package_file) { package_file.pipelines.present? }, using: Package::Pipeline
end
end
diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb
index 690bc5d419d..442013c07dd 100644
--- a/lib/api/entities/project.rb
+++ b/lib/api/entities/project.rb
@@ -147,4 +147,4 @@ module API
end
end
-API::Entities::Project.prepend_if_ee('EE::API::Entities::Project', with_descendants: true)
+API::Entities::Project.prepend_mod_with('API::Entities::Project', with_descendants: true)
diff --git a/lib/api/entities/protected_branch.rb b/lib/api/entities/protected_branch.rb
index e5dbaffb591..ac44d06e69c 100644
--- a/lib/api/entities/protected_branch.rb
+++ b/lib/api/entities/protected_branch.rb
@@ -12,4 +12,4 @@ module API
end
end
-API::Entities::ProtectedBranch.prepend_if_ee('EE::API::Entities::ProtectedBranch')
+API::Entities::ProtectedBranch.prepend_mod_with('API::Entities::ProtectedBranch')
diff --git a/lib/api/entities/protected_ref_access.rb b/lib/api/entities/protected_ref_access.rb
index f0185705b06..443277e23cf 100644
--- a/lib/api/entities/protected_ref_access.rb
+++ b/lib/api/entities/protected_ref_access.rb
@@ -11,4 +11,4 @@ module API
end
end
-API::Entities::ProtectedRefAccess.prepend_if_ee('EE::API::Entities::ProtectedRefAccess')
+API::Entities::ProtectedRefAccess.prepend_mod_with('API::Entities::ProtectedRefAccess')
diff --git a/lib/api/entities/release.rb b/lib/api/entities/release.rb
index f6c3dd5a509..94124352298 100644
--- a/lib/api/entities/release.rb
+++ b/lib/api/entities/release.rb
@@ -8,7 +8,7 @@ module API
expose :name
expose :tag, as: :tag_name, if: ->(_, _) { can_download_code? }
expose :description
- expose :description_html do |entity|
+ expose :description_html, unless: ->(_, _) { remove_description_html? } do |entity|
MarkupHelper.markdown_field(entity, :description, current_user: options[:current_user])
end
expose :created_at
@@ -28,9 +28,7 @@ module API
expose :assets do
expose :assets_count, as: :count
expose :sources, using: Entities::Releases::Source, if: ->(_, _) { can_download_code? }
- expose :links, using: Entities::Releases::Link do |release, options|
- release.links.sorted
- end
+ expose :sorted_links, as: :links, using: Entities::Releases::Link
end
expose :evidences, using: Entities::Releases::Evidence, expose_nil: false, if: ->(_, _) { can_download_code? }
expose :_links do
@@ -47,6 +45,11 @@ module API
def can_read_milestone?
Ability.allowed?(options[:current_user], :read_milestone, object.project)
end
+
+ def remove_description_html?
+ ::Feature.enabled?(:remove_description_html_in_release_api, object.project, default_enabled: :yaml) &&
+ ::Feature.disabled?(:remove_description_html_in_release_api_override, object.project)
+ end
end
end
end
diff --git a/lib/api/entities/terraform/module_versions.rb b/lib/api/entities/terraform/module_versions.rb
new file mode 100644
index 00000000000..75037039117
--- /dev/null
+++ b/lib/api/entities/terraform/module_versions.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ module Terraform
+ class ModuleVersions < Grape::Entity
+ expose :modules
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/todo.rb b/lib/api/entities/todo.rb
index 0acbb4cb704..8d222db488a 100644
--- a/lib/api/entities/todo.rb
+++ b/lib/api/entities/todo.rb
@@ -58,4 +58,4 @@ module API
end
end
-API::Entities::Todo.prepend_if_ee('EE::API::Entities::Todo')
+API::Entities::Todo.prepend_mod_with('API::Entities::Todo')
diff --git a/lib/api/entities/user_basic.rb b/lib/api/entities/user_basic.rb
index 80f3ee7b502..b8ee4e5a6e0 100644
--- a/lib/api/entities/user_basic.rb
+++ b/lib/api/entities/user_basic.rb
@@ -19,4 +19,4 @@ module API
end
end
-API::Entities::UserBasic.prepend_if_ee('EE::API::Entities::UserBasic')
+API::Entities::UserBasic.prepend_mod_with('API::Entities::UserBasic')
diff --git a/lib/api/entities/user_credit_card_validations.rb b/lib/api/entities/user_credit_card_validations.rb
new file mode 100644
index 00000000000..fcd42388b16
--- /dev/null
+++ b/lib/api/entities/user_credit_card_validations.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class UserCreditCardValidations < Grape::Entity
+ expose :user_id, :credit_card_validated_at
+ end
+ end
+end
diff --git a/lib/api/entities/user_details_with_admin.rb b/lib/api/entities/user_details_with_admin.rb
index e48b1da7859..3572b677646 100644
--- a/lib/api/entities/user_details_with_admin.rb
+++ b/lib/api/entities/user_details_with_admin.rb
@@ -11,4 +11,4 @@ module API
end
end
-API::Entities::UserDetailsWithAdmin.prepend_if_ee('EE::API::Entities::UserDetailsWithAdmin')
+API::Entities::UserDetailsWithAdmin.prepend_mod_with('API::Entities::UserDetailsWithAdmin')
diff --git a/lib/api/entities/user_path.rb b/lib/api/entities/user_path.rb
index 3f007659813..ed54857d041 100644
--- a/lib/api/entities/user_path.rb
+++ b/lib/api/entities/user_path.rb
@@ -13,4 +13,4 @@ module API
end
end
-API::Entities::UserPath.prepend_if_ee('EE::API::Entities::UserPath')
+API::Entities::UserPath.prepend_mod_with('API::Entities::UserPath')
diff --git a/lib/api/entities/user_public.rb b/lib/api/entities/user_public.rb
index 685adb1dd10..78f088d3c1a 100644
--- a/lib/api/entities/user_public.rb
+++ b/lib/api/entities/user_public.rb
@@ -19,4 +19,4 @@ module API
end
end
-API::Entities::UserPublic.prepend_if_ee('EE::API::Entities::UserPublic', with_descendants: true)
+API::Entities::UserPublic.prepend_mod_with('API::Entities::UserPublic', with_descendants: true)
diff --git a/lib/api/entities/user_with_admin.rb b/lib/api/entities/user_with_admin.rb
index ab7bc738ff8..e148a5c45b5 100644
--- a/lib/api/entities/user_with_admin.rb
+++ b/lib/api/entities/user_with_admin.rb
@@ -9,4 +9,4 @@ module API
end
end
-API::Entities::UserWithAdmin.prepend_if_ee('EE::API::Entities::UserWithAdmin')
+API::Entities::UserWithAdmin.prepend_mod_with('API::Entities::UserWithAdmin')