Commit 336089c0 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Move Entities::JobRequest under Ci namespace

Move `Entities::JobRequest` under `Entities::Ci::JobRequest`
parent d6bb6a6c
...@@ -209,7 +209,7 @@ module Ci ...@@ -209,7 +209,7 @@ module Ci
# We need to use the presenter here because Gitaly calls in the presenter # We need to use the presenter here because Gitaly calls in the presenter
# may fail, and we need to ensure the response has been generated. # may fail, and we need to ensure the response has been generated.
presented_build = ::Ci::BuildRunnerPresenter.new(build) # rubocop:disable CodeReuse/Presenter presented_build = ::Ci::BuildRunnerPresenter.new(build) # rubocop:disable CodeReuse/Presenter
build_json = ::API::Entities::JobRequest::Response.new(presented_build).to_json build_json = ::API::Entities::Ci::JobRequest::Response.new(presented_build).to_json
Result.new(build, build_json, true) Result.new(build, build_json, true)
end end
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module EE module EE
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
module Response module Response
extend ActiveSupport::Concern extend ActiveSupport::Concern
...@@ -14,4 +15,5 @@ module EE ...@@ -14,4 +15,5 @@ module EE
end end
end end
end end
end
end end
...@@ -22,7 +22,7 @@ module EE ...@@ -22,7 +22,7 @@ module EE
{ {
allowed_agents: ::API::Entities::Clusters::Agent.represent(allowed_agents), allowed_agents: ::API::Entities::Clusters::Agent.represent(allowed_agents),
job: ::API::Entities::JobRequest::JobInfo.represent(current_authenticated_job), job: ::API::Entities::Ci::JobRequest::JobInfo.represent(current_authenticated_job),
pipeline: ::API::Entities::Ci::PipelineBasic.represent(pipeline), pipeline: ::API::Entities::Ci::PipelineBasic.represent(pipeline),
project: ::API::Entities::ProjectIdentity.represent(project), project: ::API::Entities::ProjectIdentity.represent(project),
user: ::API::Entities::UserBasic.represent(current_user) user: ::API::Entities::UserBasic.represent(current_user)
......
...@@ -82,7 +82,7 @@ module API ...@@ -82,7 +82,7 @@ module API
before { set_application_context } before { set_application_context }
desc 'Request a job' do desc 'Request a job' do
success Entities::JobRequest::Response success Entities::Ci::JobRequest::Response
http_codes [[201, 'Job was scheduled'], http_codes [[201, 'Job was scheduled'],
[204, 'No job for Runner'], [204, 'No job for Runner'],
[403, 'Forbidden']] [403, 'Forbidden']]
...@@ -267,7 +267,7 @@ module API ...@@ -267,7 +267,7 @@ module API
end end
desc 'Upload artifacts for job' do desc 'Upload artifacts for job' do
success Entities::JobRequest::Response success Entities::Ci::JobRequest::Response
http_codes [[201, 'Artifact uploaded'], http_codes [[201, 'Artifact uploaded'],
[400, 'Bad request'], [400, 'Bad request'],
[403, 'Forbidden'], [403, 'Forbidden'],
......
# frozen_string_literal: true
module API
module Entities
module Ci
module JobRequest
class Artifacts < Grape::Entity
expose :name
expose :untracked
expose :paths
expose :exclude, expose_nil: false
expose :when
expose :expire_in
expose :artifact_type
expose :artifact_format
end
end
end
end
end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class Cache < Grape::Entity class Cache < Grape::Entity
expose :key, :untracked, :paths, :policy, :when expose :key, :untracked, :paths, :policy, :when
end end
end end
end end
end
end end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class Credentials < Grape::Entity class Credentials < Grape::Entity
expose :type, :url, :username, :password expose :type, :url, :username, :password
end end
end end
end end
end
end end
# frozen_string_literal: true
module API
module Entities
module Ci
module JobRequest
class Dependency < Grape::Entity
expose :id, :name, :token
expose :artifacts_file, using: Entities::Ci::JobArtifactFile, if: ->(job, _) { job.artifacts? }
end
end
end
end
end
# frozen_string_literal: true
module API
module Entities
module Ci
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
end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class Image < Grape::Entity class Image < Grape::Entity
expose :name, :entrypoint expose :name, :entrypoint
expose :ports, using: Entities::JobRequest::Port expose :ports, using: Entities::Ci::JobRequest::Port
end
end end
end end
end end
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class JobInfo < Grape::Entity class JobInfo < Grape::Entity
expose :id, :name, :stage expose :id, :name, :stage
...@@ -9,4 +10,5 @@ module API ...@@ -9,4 +10,5 @@ module API
end end
end end
end end
end
end end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class Port < Grape::Entity class Port < Grape::Entity
expose :number, :protocol, :name expose :number, :protocol, :name
end end
end end
end end
end
end end
# 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
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 :all_dependencies, as: :dependencies, using: Entities::Ci::JobRequest::Dependency
expose :features
end
end
end
end
end
API::Entities::Ci::JobRequest::Response.prepend_mod_with('API::Entities::Ci::JobRequest::Response')
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class RunnerInfo < Grape::Entity class RunnerInfo < Grape::Entity
expose :metadata_timeout, as: :timeout expose :metadata_timeout, as: :timeout
...@@ -9,4 +10,5 @@ module API ...@@ -9,4 +10,5 @@ module API
end end
end end
end end
end
end end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class Service < Entities::JobRequest::Image class Service < Entities::Ci::JobRequest::Image
expose :alias, :command expose :alias, :command
end end
end end
end end
end
end end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
module API module API
module Entities module Entities
module Ci
module JobRequest module JobRequest
class Step < Grape::Entity class Step < Grape::Entity
expose :name, :script, :timeout, :when, :allow_failure expose :name, :script, :timeout, :when, :allow_failure
end end
end end
end end
end
end end
# frozen_string_literal: true
module API
module Entities
module JobRequest
class Artifacts < Grape::Entity
expose :name
expose :untracked
expose :paths
expose :exclude, expose_nil: false
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 Dependency < Grape::Entity
expose :id, :name, :token
expose :artifacts_file, using: Entities::Ci::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 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 :runner_variables, as: :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
API::Entities::JobRequest::Response.prepend_mod_with('API::Entities::JobRequest::Response')
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe API::Entities::JobRequest::Image do RSpec.describe API::Entities::Ci::JobRequest::Image do
let(:ports) { [{ number: 80, protocol: 'http', name: 'name' }]} let(:ports) { [{ number: 80, protocol: 'http', name: 'name' }]}
let(:image) { double(name: 'image_name', entrypoint: ['foo'], ports: ports)} let(:image) { double(name: 'image_name', entrypoint: ['foo'], ports: ports)}
let(:entity) { described_class.new(image) } let(:entity) { described_class.new(image) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ::API::Entities::JobRequest::Port do RSpec.describe ::API::Entities::Ci::JobRequest::Port do
let(:port) { double(number: 80, protocol: 'http', name: 'name')} let(:port) { double(number: 80, protocol: 'http', name: 'name')}
let(:entity) { described_class.new(port) } let(:entity) { described_class.new(port) }
......
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