debian-mirror-gitlab/app/serializers/build_artifact_entity.rb

32 lines
745 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class BuildArtifactEntity < Grape::Entity
include RequestAwareEntity
2020-03-13 15:44:24 +05:30
include GitlabRoutingHelper
2017-08-17 22:00:37 +05:30
2020-06-23 00:09:42 +05:30
alias_method :artifact, :object
2017-09-10 17:25:29 +05:30
2020-06-23 00:09:42 +05:30
expose :name do |artifact|
"#{artifact.job.name}:#{artifact.file_type}"
2017-09-10 17:25:29 +05:30
end
2020-06-23 00:09:42 +05:30
expose :expire_at
expose :expired?, as: :expired
2017-09-10 17:25:29 +05:30
2020-06-23 00:09:42 +05:30
expose :path do |artifact|
fast_download_project_job_artifacts_path(
artifact.project,
artifact.job,
file_type: artifact.file_type
)
2017-09-10 17:25:29 +05:30
end
2020-06-23 00:09:42 +05:30
expose :keep_path, if: -> (*) { artifact.expiring? } do |artifact|
fast_keep_project_job_artifacts_path(artifact.project, artifact.job)
end
2017-09-10 17:25:29 +05:30
2020-06-23 00:09:42 +05:30
expose :browse_path do |artifact|
fast_browse_project_job_artifacts_path(artifact.project, artifact.job)
2017-08-17 22:00:37 +05:30
end
end