pagerduty_utils 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7652bf33022d2e8fe70580f88ad474e3f2ae332
4
- data.tar.gz: c3dee7a66a86bc84a13c3d0f246ebf6dee1ea591
3
+ metadata.gz: 786adecf96f43aeb54c2af64796a9927103ced49
4
+ data.tar.gz: af8ef65148b3512825a2dbf6a476bab48230b0da
5
5
  SHA512:
6
- metadata.gz: 563832e7ddb0a8f655a050365c26b398b082dc6e5b5af76c162124f6965cae577f632fde2141c31dc99519aae730dfcf0fec024074c67fef70d3c8ba43bb9558
7
- data.tar.gz: e3aeffa196409641b47f6e18bdf6e55cff80414421cd5ab7ee6b94ea50f049df9942c0733687ed67b62f79e1a27cfd699ae27f05eaa8a264a0664e04f10befaa
6
+ metadata.gz: cf597585a1c3a0aebc8f7673c9d28dd6b30814d1b99540703ca3901e6a551317454624afed97447d888e9a948cf62f0ef3880a2758e8f4c86cae4cfbc0c27c59
7
+ data.tar.gz: c7c4a7b7868e078ef026306140719e2563977931e84d1505c2d5db9b6dac6a379777020c11972cbb52d950dc214d45fe7c248270479f75a4a7f8605cdabeadf1
@@ -71,12 +71,14 @@ when 'get_on_call'
71
71
  puts '---'
72
72
  end
73
73
  when 'audit'
74
- Trollop::options do
74
+ opts = Trollop::options do
75
75
  usage 'audit'
76
- synopsis "\nThis script will return the last 30 days of pages or last 100 pages, which ever is fewer.\nThere are no options available for this command at this time."
76
+ opt :since, 'Get list of incidents since the given time window in days', default: 30, type: :int
77
+ opt :until, 'Get list of incidents until the given time window in days relative to since parameter', default: 30, type: :int
78
+ synopsis "\nBy default, this script will return the last 30 days of pages or last 100 pages, which ever is fewer.\nThere are parameters to adjust the date range, but 100 pages is still the cap."
77
79
  end
78
80
 
79
- incidents = Tapjoy::PagerDuty::Base.new.get_incidents
81
+ incidents = Tapjoy::PagerDuty::Base.new.get_incidents(query_start: opts[:since], query_end: opts[:until])
80
82
  puts incidents['incidents'].to_yaml
81
83
  puts "Total Alerts: #{incidents['total']}"
82
84
 
@@ -9,8 +9,8 @@ module Tapjoy
9
9
  pg_conn = YAML.load_file(config_file) if File.readable?(config_file)
10
10
 
11
11
  @AUTH_HEADER = {
12
- :subdomain => ENV['PAGERDUTY_SUBDOMAIN'] || pg_conn[:subdomain],
13
- :token_string => "Token token=#{ENV['PAGERDUTY_API_TOKEN'] || pg_conn[:api_token]}"
12
+ subdomain: ENV['PAGERDUTY_SUBDOMAIN'] || pg_conn[:subdomain],
13
+ token_string: "Token token=#{ENV['PAGERDUTY_API_TOKEN'] || pg_conn[:api_token]}"
14
14
  }
15
15
 
16
16
  raise 'Missing subdomain value' if @AUTH_HEADER[:subdomain].nil?
@@ -82,8 +82,10 @@ module Tapjoy
82
82
  post_object(endpoint, data)
83
83
  end
84
84
 
85
- def get_incidents
86
- endpoint = return_pagerduty_url(:incidents)
85
+ def get_incidents(query_start:, query_end:)
86
+ since_date = Date.today - query_start
87
+ until_date = since_date + query_end
88
+ endpoint = "#{return_pagerduty_url(:incidents)}?since=#{since_date}&until=#{until_date}"
87
89
  return get_object(endpoint)
88
90
  end
89
91
 
@@ -3,7 +3,7 @@ module Tapjoy
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- PATCH = 1
6
+ PATCH = 2
7
7
  end
8
8
 
9
9
  VERSION = [Version::MAJOR, Version::MINOR, Version::PATCH].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagerduty_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Tayarani
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-22 00:00:00.000000000 Z
12
+ date: 2015-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: trollop