2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-21 08:51:53 -05:00
|
|
|
class BuildArtifactEntity < Grape::Entity
|
2016-11-10 09:32:23 -05:00
|
|
|
include RequestAwareEntity
|
2019-12-25 13:07:46 -05:00
|
|
|
include GitlabRoutingHelper
|
2016-11-10 09:32:23 -05:00
|
|
|
|
2020-06-04 08:08:21 -04:00
|
|
|
alias_method :artifact, :object
|
2017-05-29 03:58:20 -04:00
|
|
|
|
2020-06-04 08:08:21 -04:00
|
|
|
expose :name do |artifact|
|
|
|
|
"#{artifact.job.name}:#{artifact.file_type}"
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|
2017-05-29 03:58:20 -04:00
|
|
|
|
2020-06-04 08:08:21 -04:00
|
|
|
expose :expire_at
|
|
|
|
expose :expired?, as: :expired
|
2017-05-29 03:58:20 -04:00
|
|
|
|
2020-06-04 08:08:21 -04:00
|
|
|
expose :path do |artifact|
|
|
|
|
fast_download_project_job_artifacts_path(
|
2021-04-06 05:09:03 -04:00
|
|
|
project,
|
2020-06-04 08:08:21 -04:00
|
|
|
artifact.job,
|
|
|
|
file_type: artifact.file_type
|
|
|
|
)
|
2017-05-29 03:58:20 -04:00
|
|
|
end
|
|
|
|
|
2021-03-16 17:11:53 -04:00
|
|
|
private
|
|
|
|
|
2021-04-06 05:09:03 -04:00
|
|
|
def project
|
|
|
|
options[:project] || artifact.project
|
|
|
|
end
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|