summaryrefslogtreecommitdiff
path: root/qa/qa/resource/job.rb
blob: 5b0dac9b2dfb82d42c4b6666ce4ce90e8e532919 (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
# frozen_string_literal: true

module QA
  module Resource
    class Job < Base
      attr_accessor :id, :name, :project

      attributes :id,
                 :project

      def fabricate_via_api!
        resource_web_url(api_get)
      rescue ResourceNotFoundError
        super
      end

      def artifacts
        parse_body(api_get_from(api_get_path))[:artifacts]
      end

      def api_get_path
        "/projects/#{project.id}/jobs/#{id}"
      end

      def api_trace_path
        "#{api_get_path}/trace"
      end

      def api_post_path
      end

      def api_post_body
        {
          artifacts: artifacts
        }
      end

      # Job log
      def trace
        get(request_url(api_trace_path))
      end
    end
  end
end