pagerduty_utils 0.2.0 → 0.3.1

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: b78ef3120e4fcfc5c4579c60e349ff7ccca904ab
4
- data.tar.gz: 5a1df5a97c35c826f4c41767ac81488195a21f5d
3
+ metadata.gz: b7652bf33022d2e8fe70580f88ad474e3f2ae332
4
+ data.tar.gz: c3dee7a66a86bc84a13c3d0f246ebf6dee1ea591
5
5
  SHA512:
6
- metadata.gz: 0f0e66729f30f8ac6c05a9574d9214bab47a8380068cb0435d96b819b01df5a761a197072e4863e5a8538f71cd45affb6f1e84e7787c567b14f2c3d423de7fe3
7
- data.tar.gz: 51beffa82f6a8f690c2f172bb5bcf893da676a7d4f7e5fc523129f57505a5e336e9ab59199257e47c6db83f222f80a657a093cb0fce60ecfd9acccd514a29051
6
+ metadata.gz: 563832e7ddb0a8f655a050365c26b398b082dc6e5b5af76c162124f6965cae577f632fde2141c31dc99519aae730dfcf0fec024074c67fef70d3c8ba43bb9558
7
+ data.tar.gz: e3aeffa196409641b47f6e18bdf6e55cff80414421cd5ab7ee6b94ea50f049df9942c0733687ed67b62f79e1a27cfd699ae27f05eaa8a264a0664e04f10befaa
data/bin/pgutils CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby -w
2
2
 
3
- require 'pagerduty/base'
3
+ require 'tapjoy/pagerduty'
4
4
 
5
5
  def load_trigger(trigger_name, message)
6
6
  config_file = "#{ENV['PAGERDUTY_CONFIG_DIR'] ? ENV['PAGERDUTY_CONFIG_DIR'] + 'triggers.yml' : ENV['HOME'] + '/.pgutils/triggers.yaml'}"
@@ -22,7 +22,7 @@ def get_level_one_users(pg)
22
22
  end
23
23
  end
24
24
 
25
- SUB_COMMANDS = %w(set_override trigger get_on_call)
25
+ SUB_COMMANDS = %w(set_override trigger get_on_call audit)
26
26
  Trollop::options do
27
27
  usage '[SUB_COMMAND] [options]'
28
28
  synopsis "\nTool to integrate with PagerDuty API.\nAvailable subcommands are: #{SUB_COMMANDS}"
@@ -70,6 +70,16 @@ when 'get_on_call'
70
70
  end
71
71
  puts '---'
72
72
  end
73
+ when 'audit'
74
+ Trollop::options do
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."
77
+ end
78
+
79
+ incidents = Tapjoy::PagerDuty::Base.new.get_incidents
80
+ puts incidents['incidents'].to_yaml
81
+ puts "Total Alerts: #{incidents['total']}"
82
+
73
83
  else
74
84
  Trollop::educate
75
85
  end
@@ -1,11 +1,3 @@
1
- require 'httparty'
2
- require 'json'
3
- require 'yaml'
4
- require 'date'
5
- require 'trollop'
6
- require 'pagerduty/override'
7
- require_relative 'version'
8
-
9
1
  module Tapjoy
10
2
  module PagerDuty
11
3
  class Base
@@ -90,6 +82,11 @@ module Tapjoy
90
82
  post_object(endpoint, data)
91
83
  end
92
84
 
85
+ def get_incidents
86
+ endpoint = return_pagerduty_url(:incidents)
87
+ return get_object(endpoint)
88
+ end
89
+
93
90
  private
94
91
  # Helper method for all GETs
95
92
  def get_object(endpoint)
@@ -118,7 +115,7 @@ module Tapjoy
118
115
  # Helper method for building PagerDuty URLs
119
116
  def return_pagerduty_url(object_type)
120
117
  rest_api_url = "https://#{@AUTH_HEADER[:subdomain]}.pagerduty.com/api/v1"
121
- incident_api_url = 'https://events.pagerduty.com/generic/2010-04-15'
118
+ integration_api_url = 'https://events.pagerduty.com/generic/2010-04-15'
122
119
  case object_type
123
120
  when :users
124
121
  return rest_api_url + '/users'
@@ -126,8 +123,10 @@ module Tapjoy
126
123
  return rest_api_url + '/schedules'
127
124
  when :escalation_on_call
128
125
  return rest_api_url + '/escalation_policies/on_call'
126
+ when :incidents
127
+ return rest_api_url + '/incidents'
129
128
  when :create_trigger
130
- return incident_api_url + '/create_event.json'
129
+ return integration_api_url + '/create_event.json'
131
130
  else
132
131
  abort("Unknown object type: #{object_type}. Can't build URL.")
133
132
  end
File without changes
@@ -2,8 +2,8 @@ module Tapjoy
2
2
  module PagerDuty
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 2
6
- PATCH = 0
5
+ MINOR = 3
6
+ PATCH = 1
7
7
  end
8
8
 
9
9
  VERSION = [Version::MAJOR, Version::MINOR, Version::PATCH].join('.')
@@ -0,0 +1,13 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'yaml'
4
+ require 'date'
5
+ require 'trollop'
6
+ require_relative 'pagerduty/override'
7
+ require_relative 'pagerduty/version'
8
+ require_relative 'pagerduty/base'
9
+
10
+ module Tapjoy
11
+ module PagerDuty
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagerduty_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Tayarani
8
+ - Ed Healy
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-04-02 00:00:00.000000000 Z
12
+ date: 2015-04-22 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: trollop
@@ -74,9 +75,10 @@ extensions: []
74
75
  extra_rdoc_files: []
75
76
  files:
76
77
  - bin/pgutils
77
- - lib/pagerduty/base.rb
78
- - lib/pagerduty/override.rb
79
- - lib/pagerduty/version.rb
78
+ - lib/tapjoy/pagerduty.rb
79
+ - lib/tapjoy/pagerduty/base.rb
80
+ - lib/tapjoy/pagerduty/override.rb
81
+ - lib/tapjoy/pagerduty/version.rb
80
82
  homepage: https://github.com/tapjoy/pagerduty_utils
81
83
  licenses:
82
84
  - MIT