Commit e65daf20 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Stan Hu

Separate JobRequest entities into own class files

parent 6b95c3f9
---
title: Separate JobRequest entities into own class files
merge_request: 24977
author: Rajendra Kadam
type: added
......@@ -641,93 +641,6 @@ module API
end
end
module JobRequest
class JobInfo < Grape::Entity
expose :name, :stage
expose :project_id, :project_name
end
class GitInfo < Grape::Entity
expose :repo_url, :ref, :sha, :before_sha
expose :ref_type
expose :refspecs
expose :git_depth, as: :depth
end
class RunnerInfo < Grape::Entity
expose :metadata_timeout, as: :timeout
expose :runner_session_url
end
class Step < Grape::Entity
expose :name, :script, :timeout, :when, :allow_failure
end
class Port < Grape::Entity
expose :number, :protocol, :name
end
class Image < Grape::Entity
expose :name, :entrypoint
expose :ports, using: JobRequest::Port
end
class Service < Image
expose :alias, :command
end
class Artifacts < Grape::Entity
expose :name
expose :untracked
expose :paths
expose :when
expose :expire_in
expose :artifact_type
expose :artifact_format
end
class Cache < Grape::Entity
expose :key, :untracked, :paths, :policy
end
class Credentials < Grape::Entity
expose :type, :url, :username, :password
end
class Dependency < Grape::Entity
expose :id, :name, :token
expose :artifacts_file, using: JobArtifactFile, if: ->(job, _) { job.artifacts? }
end
class Response < Grape::Entity
expose :id
expose :token
expose :allow_git_fetch
expose :job_info, using: JobInfo do |model|
model
end
expose :git_info, using: GitInfo do |model|
model
end
expose :runner_info, using: RunnerInfo do |model|
model
end
expose :variables
expose :steps, using: Step
expose :image, using: Image
expose :services, using: Service
expose :artifacts, using: Artifacts
expose :cache, using: Cache
expose :credentials, using: Credentials
expose :all_dependencies, as: :dependencies, using: Dependency
expose :features
end
end
class UserAgentDetail < Grape::Entity
expose :user_agent
expose :ip_address
......
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Artifacts < Grape::Entity
expose :name
expose :untracked
expose :paths
expose :when
expose :expire_in
expose :artifact_type
expose :artifact_format
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Cache < Grape::Entity
expose :key, :untracked, :paths, :policy
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Credentials < Grape::Entity
expose :type, :url, :username, :password
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Dependency < Grape::Entity
expose :id, :name, :token
expose :artifacts_file, using: Entities::JobArtifactFile, if: ->(job, _) { job.artifacts? }
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class GitInfo < Grape::Entity
expose :repo_url, :ref, :sha, :before_sha
expose :ref_type
expose :refspecs
expose :git_depth, as: :depth
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Image < Grape::Entity
expose :name, :entrypoint
expose :ports, using: Entities::JobRequest::Port
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class JobInfo < Grape::Entity
expose :name, :stage
expose :project_id, :project_name
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Port < Grape::Entity
expose :number, :protocol, :name
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Response < Grape::Entity
expose :id
expose :token
expose :allow_git_fetch
expose :job_info, using: Entities::JobRequest::JobInfo do |model|
model
end
expose :git_info, using: Entities::JobRequest::GitInfo do |model|
model
end
expose :runner_info, using: Entities::JobRequest::RunnerInfo do |model|
model
end
expose :variables
expose :steps, using: Entities::JobRequest::Step
expose :image, using: Entities::JobRequest::Image
expose :services, using: Entities::JobRequest::Service
expose :artifacts, using: Entities::JobRequest::Artifacts
expose :cache, using: Entities::JobRequest::Cache
expose :credentials, using: Entities::JobRequest::Credentials
expose :all_dependencies, as: :dependencies, using: Entities::JobRequest::Dependency
expose :features
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class RunnerInfo < Grape::Entity
expose :metadata_timeout, as: :timeout
expose :runner_session_url
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Service < Entities::JobRequest::Image
expose :alias, :command
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Step < Grape::Entity
expose :name, :script, :timeout, :when, :allow_failure
end
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