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

72 lines
1.7 KiB
Ruby
Raw Normal View History

class PipelineEntity < Grape::Entity
include RequestAwareEntity
expose :id
expose :user, using: UserEntity
2016-11-10 15:16:54 -05:00
expose :path do |pipeline|
2016-11-10 12:15:16 -05:00
namespace_project_pipeline_path(
pipeline.project.namespace,
pipeline.project,
pipeline)
end
expose :details do
expose :status do |pipeline, options|
StatusEntity.represent(
pipeline.detailed_status(request.user),
options)
end
2016-11-10 11:50:55 -05:00
expose :duration
expose :finished_at
expose :stages, using: PipelineStageEntity
2016-11-10 11:50:55 -05:00
expose :artifacts, using: PipelineArtifactEntity
expose :manual_actions, using: PipelineActionEntity
end
expose :flags do
expose :latest?, as: :latest
expose :triggered?, as: :triggered
2016-11-10 15:16:54 -05:00
expose :yaml_errors?, as: :yaml_errors do |pipeline|
pipeline.yaml_errors.present?
end
2016-11-10 15:16:54 -05:00
2016-12-15 16:06:39 -05:00
expose :stuck?, as: :stuck
end
expose :ref do
expose :name do |pipeline|
pipeline.ref
end
2016-11-10 12:15:16 -05:00
expose :url do |pipeline|
namespace_project_tree_url(
pipeline.project.namespace,
pipeline.project,
id: pipeline.ref)
end
expose :tag?
end
expose :commit, using: CommitEntity
expose :retry_url do |pipeline|
2016-11-10 15:16:54 -05:00
can?(request.user, :update_pipeline, pipeline.project) &&
pipeline.retryable? &&
2016-11-10 15:16:54 -05:00
retry_namespace_project_pipeline_path(pipeline.project.namespace,
pipeline.project, pipeline.id)
end
expose :cancel_url do |pipeline|
2016-11-10 15:16:54 -05:00
can?(request.user, :update_pipeline, pipeline.project) &&
pipeline.cancelable? &&
2016-11-10 15:16:54 -05:00
cancel_namespace_project_pipeline_path(pipeline.project.namespace,
pipeline.project, pipeline.id)
end
expose :created_at, :updated_at
end