Class: GCPT::BuildReport::ReportApi

Inherits:
Object
  • Object
show all
Defined in:
lib/gcpt/build_report/report_api.rb

Class Method Summary collapse

Class Method Details

.faas_post(method, data) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gcpt/build_report/report_api.rb', line 9

def self.faas_post(method, data)
  uri = URI(FAAS_URL_PREFIX + method)
  res = Net::HTTP.post(uri, data.to_json, {
    'Content-Type' => 'application/json',
    'x-gsdk-access' => ENV['X_GSDK_ACCESS']
  })
  raise "Http error, code: #{res.code}" unless res.code == '200'

  content = JSON.parse(res.body)
  if content['code'] != 0
    raise "faas request error: #{content['message']}"
  end
  return content['data']
end

.report(data) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/gcpt/build_report/report_api.rb', line 24

def self.report(data)
  begin
    faas_post('v3_collect_build', data)
  rescue => e
    puts "gsdkcp-tool report failed: #{e}"
  else
    puts 'gsdkcp-tool report success'
  end
end