diff options
Diffstat (limited to 'lib/api/entities')
-rw-r--r-- | lib/api/entities/application_setting.rb | 3 | ||||
-rw-r--r-- | lib/api/entities/award_emoji.rb | 1 | ||||
-rw-r--r-- | lib/api/entities/basic_release_details.rb | 16 | ||||
-rw-r--r-- | lib/api/entities/ci/job_request/artifacts.rb | 2 | ||||
-rw-r--r-- | lib/api/entities/clusters/agent.rb | 3 | ||||
-rw-r--r-- | lib/api/entities/commit_with_link.rb | 8 | ||||
-rw-r--r-- | lib/api/entities/issue.rb | 4 | ||||
-rw-r--r-- | lib/api/entities/member.rb | 1 | ||||
-rw-r--r-- | lib/api/entities/merge_request_changes.rb | 2 | ||||
-rw-r--r-- | lib/api/entities/metric_image.rb | 9 | ||||
-rw-r--r-- | lib/api/entities/project.rb | 5 | ||||
-rw-r--r-- | lib/api/entities/release.rb | 8 | ||||
-rw-r--r-- | lib/api/entities/user_with_admin.rb | 1 | ||||
-rw-r--r-- | lib/api/entities/wiki_attachment.rb | 4 |
14 files changed, 48 insertions, 19 deletions
diff --git a/lib/api/entities/application_setting.rb b/lib/api/entities/application_setting.rb index 465c5f4112b..db51d4380d0 100644 --- a/lib/api/entities/application_setting.rb +++ b/lib/api/entities/application_setting.rb @@ -40,6 +40,9 @@ module API expose :password_authentication_enabled_for_web, as: :signin_enabled expose :allow_local_requests_from_web_hooks_and_services, as: :allow_local_requests_from_hooks_and_services expose :asset_proxy_allowlist, as: :asset_proxy_whitelist + + # This field is deprecated and always returns true + expose(:housekeeping_bitmaps_enabled) { |_settings, _options| true } end end end diff --git a/lib/api/entities/award_emoji.rb b/lib/api/entities/award_emoji.rb index da9a183bf39..40dc38b1900 100644 --- a/lib/api/entities/award_emoji.rb +++ b/lib/api/entities/award_emoji.rb @@ -8,6 +8,7 @@ module API expose :user, using: Entities::UserBasic expose :created_at, :updated_at expose :awardable_id, :awardable_type + expose :url end end end diff --git a/lib/api/entities/basic_release_details.rb b/lib/api/entities/basic_release_details.rb new file mode 100644 index 00000000000..d13080f32f4 --- /dev/null +++ b/lib/api/entities/basic_release_details.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module API + module Entities + class BasicReleaseDetails < Grape::Entity + include ::API::Helpers::Presentable + + expose :name + expose :tag, as: :tag_name + expose :description + expose :created_at + expose :released_at + expose :upcoming_release?, as: :upcoming_release + end + end +end diff --git a/lib/api/entities/ci/job_request/artifacts.rb b/lib/api/entities/ci/job_request/artifacts.rb index 4b09db40504..d1fb7d330b9 100644 --- a/lib/api/entities/ci/job_request/artifacts.rb +++ b/lib/api/entities/ci/job_request/artifacts.rb @@ -6,7 +6,7 @@ module API module JobRequest class Artifacts < Grape::Entity expose :name - expose :untracked + expose :untracked, expose_nil: false expose :paths expose :exclude, expose_nil: false expose :when diff --git a/lib/api/entities/clusters/agent.rb b/lib/api/entities/clusters/agent.rb index 3b4538b81c2..140b680f5e8 100644 --- a/lib/api/entities/clusters/agent.rb +++ b/lib/api/entities/clusters/agent.rb @@ -5,7 +5,10 @@ module API module Clusters class Agent < Grape::Entity expose :id + expose :name expose :project, with: Entities::ProjectIdentity, as: :config_project + expose :created_at + expose :created_by_user_id end end end diff --git a/lib/api/entities/commit_with_link.rb b/lib/api/entities/commit_with_link.rb index a135cc19480..23efaca34d5 100644 --- a/lib/api/entities/commit_with_link.rb +++ b/lib/api/entities/commit_with_link.rb @@ -29,7 +29,7 @@ module API end expose :signature_html, if: { type: :full } do |commit| - render('projects/commit/_signature', signature: commit.signature) if commit.has_signature? + ::CommitPresenter.new(commit).signature_html end expose :prev_commit_id, if: { type: :full } do |commit| @@ -50,12 +50,6 @@ module API pipelines_project_commit_path(pipeline_project, commit.id, ref: pipeline_ref) end - - def render(*args) - return unless request.respond_to?(:render) && request.render.respond_to?(:call) - - request.render.call(*args) - end end end end diff --git a/lib/api/entities/issue.rb b/lib/api/entities/issue.rb index e2506cc596e..f87ef093cd8 100644 --- a/lib/api/entities/issue.rb +++ b/lib/api/entities/issue.rb @@ -35,6 +35,10 @@ module API issue end + expose :severity, + format_with: :upcase, + documentation: { type: "String", desc: "One of #{::IssuableSeverity.severities.keys.map(&:upcase)}" } + # Calculating the value of subscribed field triggers Markdown # processing. We can't do that for multiple issues / merge # requests in a single API request. diff --git a/lib/api/entities/member.rb b/lib/api/entities/member.rb index 87f03adba31..7ce1e73a043 100644 --- a/lib/api/entities/member.rb +++ b/lib/api/entities/member.rb @@ -6,6 +6,7 @@ module API expose :user, merge: true, using: UserBasic expose :access_level expose :created_at + expose :created_by, with: UserBasic, expose_nil: false expose :expires_at end end diff --git a/lib/api/entities/merge_request_changes.rb b/lib/api/entities/merge_request_changes.rb index 488f33dfb93..a1e8b5ae00a 100644 --- a/lib/api/entities/merge_request_changes.rb +++ b/lib/api/entities/merge_request_changes.rb @@ -24,7 +24,7 @@ module API end def expose_raw_diffs? - options[:access_raw_diffs] || ::Feature.enabled?(:mrc_api_use_raw_diffs_from_gitaly, options[:project]) + options[:access_raw_diffs] end end end diff --git a/lib/api/entities/metric_image.rb b/lib/api/entities/metric_image.rb new file mode 100644 index 00000000000..fd5e3a62e40 --- /dev/null +++ b/lib/api/entities/metric_image.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class MetricImage < Grape::Entity + expose :id, :created_at, :filename, :file_path, :url, :url_text + end + end +end diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb index 8f9a8add938..60cc5167c41 100644 --- a/lib/api/entities/project.rb +++ b/lib/api/entities/project.rb @@ -85,8 +85,11 @@ module API end expose :mr_default_target_self, if: -> (project) { project.forked? } + expose :import_url, if: -> (project, options) { Ability.allowed?(options[:current_user], :admin_project, project) } do |project| + project[:import_url] + end + expose :import_type, if: -> (project, options) { Ability.allowed?(options[:current_user], :admin_project, project) } expose :import_status - expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } do |project| project.import_state&.last_error end diff --git a/lib/api/entities/release.rb b/lib/api/entities/release.rb index 056b54674f1..2403c907f7f 100644 --- a/lib/api/entities/release.rb +++ b/lib/api/entities/release.rb @@ -2,20 +2,14 @@ module API module Entities - class Release < Grape::Entity + class Release < BasicReleaseDetails include ::API::Helpers::Presentable - expose :name - expose :tag, as: :tag_name, if: ->(_, _) { can_download_code? } - expose :description expose :description_html, if: -> (_, options) { options[:include_html_description] } do |entity| MarkupHelper.markdown_field(entity, :description, current_user: options[:current_user]) end - expose :created_at - expose :released_at expose :author, using: Entities::UserBasic, if: -> (release, _) { release.author.present? } expose :commit, using: Entities::Commit, if: ->(_, _) { can_download_code? } - expose :upcoming_release?, as: :upcoming_release expose :milestones, using: Entities::MilestoneWithStats, if: -> (release, _) { release.milestones.present? && can_read_milestone? } do |release, _| diff --git a/lib/api/entities/user_with_admin.rb b/lib/api/entities/user_with_admin.rb index e148a5c45b5..f9c1a646a4f 100644 --- a/lib/api/entities/user_with_admin.rb +++ b/lib/api/entities/user_with_admin.rb @@ -5,6 +5,7 @@ module API class UserWithAdmin < UserPublic expose :admin?, as: :is_admin expose :note + expose :namespace_id end end end diff --git a/lib/api/entities/wiki_attachment.rb b/lib/api/entities/wiki_attachment.rb index e622dea04dd..03a6cc8d644 100644 --- a/lib/api/entities/wiki_attachment.rb +++ b/lib/api/entities/wiki_attachment.rb @@ -16,11 +16,11 @@ module API end def filename - object.file_name + object[:file_name] end def secure_url - object.file_path + object[:file_path] end end end |