Module: Rollbar::Deploy

Defined in:
lib/rollbar/deploy.rb

Overview

Deploy Tracking API wrapper module

Constant Summary collapse

ENDPOINT =
'https://api.rollbar.com/api/1/deploy/'.freeze

Class Method Summary collapse

Class Method Details

.report(opts, access_token, environment, revision) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rollbar/deploy.rb', line 8

def self.report(opts, access_token, environment, revision)
  return {} unless access_token && !access_token.empty?

  opts[:status] ||= :started

  uri = ::URI.parse(::Rollbar::Deploy::ENDPOINT)

  request_data = {
    :access_token => access_token,
    :environment => environment,
    :revision => revision
  }.merge(opts)
  request_data.delete(:proxy)
  request_data.delete(:dry_run)

  request = ::Net::HTTP::Post.new(uri.request_uri)
  request.body = ::JSON.dump(request_data)

  send_request(opts, uri, request)
end

.update(opts, access_token, deploy_id, status) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rollbar/deploy.rb', line 29

def self.update(opts, access_token, deploy_id, status)
  return {} unless access_token && !access_token.empty?

  uri = ::URI.parse(
    "#{::Rollbar::Deploy::ENDPOINT}#{deploy_id}?access_token=#{access_token}"
  )

  request = ::Net::HTTP::Patch.new(uri.request_uri)
  request.body = ::JSON.dump(:status => status.to_s, :comment => opts[:comment])

  send_request(opts, uri, request)
end