Class: Datadog::CI::Transport::Api::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/transport/api/base.rb

Direct Known Subclasses

Agentless, EvpProxy

Instance Method Summary collapse

Instance Method Details

#api_request(path:, payload:, headers: {}, verb: "post") ⇒ Object



12
13
14
# File 'lib/datadog/ci/transport/api/base.rb', line 12

def api_request(path:, payload:, headers: {}, verb: "post")
  headers[Ext::Transport::HEADER_CONTENT_TYPE] ||= Ext::Transport::CONTENT_TYPE_JSON
end

#citestcov_request(path:, payload:, headers: {}, verb: "post") ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/datadog/ci/transport/api/base.rb', line 20

def citestcov_request(path:, payload:, headers: {}, verb: "post")
  citestcov_request_boundary = ::SecureRandom.uuid

  headers[Ext::Transport::HEADER_CONTENT_TYPE] ||=
    "#{Ext::Transport::CONTENT_TYPE_MULTIPART_FORM_DATA}; boundary=#{citestcov_request_boundary}"

  @citestcov_payload = [
    "--#{citestcov_request_boundary}",
    'Content-Disposition: form-data; name="event"; filename="event.json"',
    "Content-Type: application/json",
    "",
    '{"dummy":true}',
    "--#{citestcov_request_boundary}",
    'Content-Disposition: form-data; name="coverage1"; filename="coverage1.msgpack"',
    "Content-Type: application/msgpack",
    "",
    payload,
    "--#{citestcov_request_boundary}--"
  ].join("\r\n")
end

#citestcycle_request(path:, payload:, headers: {}, verb: "post") ⇒ Object



16
17
18
# File 'lib/datadog/ci/transport/api/base.rb', line 16

def citestcycle_request(path:, payload:, headers: {}, verb: "post")
  headers[Ext::Transport::HEADER_CONTENT_TYPE] ||= Ext::Transport::CONTENT_TYPE_MESSAGEPACK
end

#headers_with_default(headers) ⇒ Object



41
42
43
44
# File 'lib/datadog/ci/transport/api/base.rb', line 41

def headers_with_default(headers)
  request_headers = default_headers
  request_headers.merge!(headers)
end