gitlab-org--gitlab-foss/app/serializers/build_artifact_entity.rb

32 lines
745 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class BuildArtifactEntity < Grape::Entity
include RequestAwareEntity
include GitlabRoutingHelper
alias_method :artifact, :object
2017-05-29 03:58:20 -04:00
expose :name do |artifact|
"#{artifact.job.name}:#{artifact.file_type}"
end
2017-05-29 03:58:20 -04:00
expose :expire_at
expose :expired?, as: :expired
2017-05-29 03:58:20 -04:00
expose :path do |artifact|
fast_download_project_job_artifacts_path(
artifact.project,
artifact.job,
file_type: artifact.file_type
)
2017-05-29 03:58:20 -04:00
end
expose :keep_path, if: -> (*) { artifact.expiring? } do |artifact|
fast_keep_project_job_artifacts_path(artifact.project, artifact.job)
end
2017-05-29 03:58:20 -04:00
expose :browse_path do |artifact|
fast_browse_project_job_artifacts_path(artifact.project, artifact.job)
2017-05-29 03:58:20 -04:00
end
end