summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb94
1 files changed, 67 insertions, 27 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index cb3b409b8d0..7e07154600a 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -698,42 +698,82 @@ module API
expose :active?, as: :active
end
- class ArtifactFile < Grape::Entity
- expose :filename, :size
- 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 do |model|
+ if model.tag
+ 'tag'
+ else
+ 'branch'
+ end
+ end
+ end
- class JobCredentials < Grape::Entity
- expose :type, :url, :username, :password
- end
+ class RunnerInfo < Grape::Entity
+ expose :timeout
+ end
- class JobResponse < Grape::Entity
- expose :id, :ref, :tag, :sha, :status
- expose :name, :token, :stage
- expose :project_id
- expose :project_name
- expose :artifacts_file, using: ArtifactFile, if: ->(build, _) { build.artifacts? }
- end
+ class Step < Grape::Entity
+ expose :name, :script, :timeout, :condition, :result
+ end
- class RequestJobResponse < JobResponse
- expose :commands
- expose :repo_url
- expose :before_sha
- expose :allow_git_fetch
- expose :token
- expose :artifacts_expire_at, if: ->(build, _) { build.artifacts? }
+ class Image < Grape::Entity
+ expose :name
+ end
- expose :options do |model|
- model.options
+ class Artifacts < Grape::Entity
+ expose :name, :untracked, :paths, :when, :expire_in
end
- expose :timeout do |model|
- model.timeout
+ class Cache < Grape::Entity
+ expose :key, :untracked, :paths
end
- expose :variables
- expose :depends_on_builds, using: JobResponse
+ class Credentials < Grape::Entity
+ expose :type, :url, :username, :password
+ end
- expose :credentials, using: JobCredentials
+ class ArtifactFile < Grape::Entity
+ expose :filename, :size
+ end
+
+ class Dependency < Grape::Entity
+ expose :id, :name
+ expose :artifacts_file, using: ArtifactFile, 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: Image
+ expose :artifacts, using: Artifacts
+ expose :cache, using: Cache
+ expose :credentials, using: Credentials
+ expose :depends_on_builds, as: :dependencies, using: Dependency
+ end
end
end
end