Commit 5e49d576 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Stan Hu

Separate job entities into own class files

parent 5e532c2c
---
title: Separate job entities into own class files
merge_request: 24948
author: Rajendra Kadam
type: added
...@@ -549,40 +549,6 @@ module API ...@@ -549,40 +549,6 @@ module API
expose :id, :token expose :id, :token
end end
class JobArtifactFile < Grape::Entity
expose :filename
expose :cached_size, as: :size
end
class JobArtifact < Grape::Entity
expose :file_type, :size, :filename, :file_format
end
class JobBasic < Grape::Entity
expose :id, :status, :stage, :name, :ref, :tag, :coverage, :allow_failure
expose :created_at, :started_at, :finished_at
expose :duration
expose :user, with: Entities::User
expose :commit, with: Entities::Commit
expose :pipeline, with: Entities::PipelineBasic
expose :web_url do |job, _options|
Gitlab::Routing.url_helpers.project_job_url(job.project, job)
end
end
class Job < JobBasic
# artifacts_file is included in job_artifacts, but kept for backward compatibility (remove in api/v5)
expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? }
expose :job_artifacts, as: :artifacts, using: JobArtifact
expose :runner, with: Runner
expose :artifacts_expire_at
end
class JobBasicWithProject < JobBasic
expose :project, with: Entities::ProjectIdentity
end
class Trigger < Grape::Entity class Trigger < Grape::Entity
include ::API::Helpers::Presentable include ::API::Helpers::Presentable
......
# frozen_string_literal: true
module API
module Entities
class Job < Entities::JobBasic
# artifacts_file is included in job_artifacts, but kept for backward compatibility (remove in api/v5)
expose :artifacts_file, using: Entities::JobArtifactFile, if: -> (job, opts) { job.artifacts? }
expose :job_artifacts, as: :artifacts, using: Entities::JobArtifact
expose :runner, with: Entities::Runner
expose :artifacts_expire_at
end
end
end
# frozen_string_literal: true
module API
module Entities
class JobArtifact < Grape::Entity
expose :file_type, :size, :filename, :file_format
end
end
end
# frozen_string_literal: true
module API
module Entities
class JobArtifactFile < Grape::Entity
expose :filename
expose :cached_size, as: :size
end
end
end
# frozen_string_literal: true
module API
module Entities
class JobBasic < Grape::Entity
expose :id, :status, :stage, :name, :ref, :tag, :coverage, :allow_failure
expose :created_at, :started_at, :finished_at
expose :duration
expose :user, with: Entities::User
expose :commit, with: Entities::Commit
expose :pipeline, with: Entities::PipelineBasic
expose :web_url do |job, _options|
Gitlab::Routing.url_helpers.project_job_url(job.project, job)
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class JobBasicWithProject < Entities::JobBasic
expose :project, with: Entities::ProjectIdentity
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment