Commit a8779fd0 authored by Stan Hu's avatar Stan Hu

Merge branch 'refactoring-entities-file-21' into 'master'

Separate job entities into own class files

See merge request gitlab-org/gitlab!24948
parents 34df7dcb 5e49d576
---
title: Separate job entities into own class files
merge_request: 24948
author: Rajendra Kadam
type: added
......@@ -317,40 +317,6 @@ module API
expose :id, :token
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
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