1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
# frozen_string_literal: true
module API
module Entities
module Ci
module JobRequest
class Response < Grape::Entity
expose :id
expose :token
expose :allow_git_fetch
expose :job_info, using: Entities::Ci::JobRequest::JobInfo do |model|
model
end
expose :git_info, using: Entities::Ci::JobRequest::GitInfo do |model|
model
end
expose :runner_info, using: Entities::Ci::JobRequest::RunnerInfo do |model|
model
end
expose :runner_variables, as: :variables
expose :steps, using: Entities::Ci::JobRequest::Step, unless: ->(job) do
job.execution_config&.run_steps.present?
end
expose :runtime_hooks, as: :hooks, using: Entities::Ci::JobRequest::Hook
expose :image, using: Entities::Ci::JobRequest::Image
expose :services, using: Entities::Ci::JobRequest::Service
expose :artifacts, using: Entities::Ci::JobRequest::Artifacts
expose :cache, using: Entities::Ci::JobRequest::Cache
expose :credentials, using: Entities::Ci::JobRequest::Credentials
expose :features
expose :dependencies do |job, options|
Entities::Ci::JobRequest::Dependency.represent(job.all_dependencies, options.merge(running_job: job))
end
expose :run, if: ->(job) { job.execution_config&.run_steps.present? } do |job|
job.execution_config.run_steps.to_json
end
end
end
end
end
end
API::Entities::Ci::JobRequest::Response.prepend_mod_with('API::Entities::Ci::JobRequest::Response')
|