BigW Consortium Gitlab

entities.rb 2.53 KB
Newer Older
1 2 3 4
module Ci
  module API
    module Entities
      class Commit < Grape::Entity
5
        expose :id, :sha, :project_id, :created_at
6 7 8 9 10 11 12 13
        expose :status, :finished_at, :duration
        expose :git_commit_message, :git_author_name, :git_author_email
      end

      class CommitWithBuilds < Commit
        expose :builds
      end

14 15 16 17
      class ArtifactFile < Grape::Entity
        expose :filename, :size
      end

18 19 20 21 22 23 24 25 26
      class BuildOptions < Grape::Entity
        expose :image
        expose :services
        expose :artifacts
        expose :cache
        expose :dependencies
        expose :after_script
      end

27
      class Build < Grape::Entity
28
        expose :id, :ref, :tag, :sha, :status
29
        expose :name, :token, :stage
30 31
        expose :project_id
        expose :project_name
32
        expose :artifacts_file, using: ArtifactFile, if: ->(build, _) { build.artifacts? }
33 34
      end

35 36 37 38
      class BuildCredentials < Grape::Entity
        expose :type, :url, :username, :password
      end

39 40 41 42 43 44
      class BuildDetails < Build
        expose :commands
        expose :repo_url
        expose :before_sha
        expose :allow_git_fetch
        expose :token
45
        expose :artifacts_expire_at, if: ->(build, _) { build.artifacts? }
46

Valery Sizov committed
47
        expose :options do |model|
48 49 50 51 52
          # This part ensures that output of old API is still the same after adding support
          # for extended docker configuration options, used by new API
          #
          # I'm leaving this here, not in the model, because it should be removed at the same time
          # when old API will be removed (planned for August 2017).
53 54
          model.options.dup.tap do |options|
            options[:image] = options[:image][:name] if options[:image].is_a?(Hash)
55 56 57 58 59 60 61 62
            options[:services].map! do |service|
              if service.is_a?(Hash)
                service[:name]
              else
                service
              end
            end
          end
Valery Sizov committed
63
        end
Valery Sizov committed
64 65 66 67

        expose :timeout do |model|
          model.timeout
        end
68 69

        expose :variables
70
        expose :depends_on_builds, using: Build
71

72
        expose :credentials, using: BuildCredentials
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
      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
89
        expose :pipeline, using: Commit, as: :commit
90 91 92 93
      end
    end
  end
end