summaryrefslogtreecommitdiff
path: root/lib/ci/api/entities.rb
blob: 3f5bdaba3f5d0f757e23411ce83c72282fe54d52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Ci
  module API
    module Entities
      class Commit < Grape::Entity
        expose :id, :sha, :project_id, :created_at
        expose :status, :finished_at, :duration
        expose :git_commit_message, :git_author_name, :git_author_email
      end

      class CommitWithBuilds < Commit
        expose :builds
      end

      class ArtifactFile < Grape::Entity
        expose :filename, :size
      end

      class Build < 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 BuildDetails < Build
        expose :commands
        expose :repo_url
        expose :before_sha
        expose :allow_git_fetch
        expose :token
        expose :artifacts_expire_at, if: ->(build, _) { build.artifacts? }

        expose :options do |model|
          model.options
        end

        expose :timeout do |model|
          model.timeout
        end

        expose :variables
        expose :depends_on_builds, using: Build
      end

      class Runner < Grape::Entity
        expose :id, :token
      end

      class RunnerProject < Grape::Entity
        expose :id, :project_id, :runner_id
      end

      class WebHook < Grape::Entity
        expose :id, :project_id, :url
      end

      class TriggerRequest < Grape::Entity
        expose :id, :variables
        expose :pipeline, using: Commit, as: :commit
      end
    end
  end
end