pager_judy 0.2.1 → 0.2.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
  SHA256:
3
- metadata.gz: b648199a7a825271e111d4648bfaac509d2cfadf48f407bbc1ec1f9881d79b9d
4
- data.tar.gz: 471f4ed13b11cd30304cb5dc5cfb8953574bb926b64ad0c6e5e5f57aef8feb62
3
+ metadata.gz: 52d2f9ad7cc38c994d770a488563b643dbd568e40a635f912cab9fb32739d708
4
+ data.tar.gz: e5190b125b5602cb079fe476090f79fbbac07fb47aa3bdb950f6618db148f904
5
5
  SHA512:
6
- metadata.gz: f7aa402999e338dbdb8b6e4810f957d6a1bdbc30a97de4f691687bb7c7092b43831b1fa0beaa2ecfb98d3bfe9fc85f556613dfad0d51ce450218daed4b2bd8b7
7
- data.tar.gz: 1400529af5831bc3c97ad015b7504ca1157f15d6cfba64268e1e63887748bc19a515bfdd13a6d9d813cc2a55ef498777f897ae094520698e538012b64b09a5fb
6
+ metadata.gz: d2cce233aace32a45888c9c7cae6dab59059032ab2c94b0c808582c209e70ad595bcdbd1b89f68fddc012b59c3af75ee3eca15fd48a03f860677b58b618a0af8
7
+ data.tar.gz: 0aeca53e8377f18636b37a317a8c08657b0a4d8721c370c715e3ea384a40fa82a0d2c948608af4b5065dfadb2821f31e05fcd1971dfc6bdcef9dd603c175ac57
data/CHANGES.md CHANGED
@@ -1,7 +1,19 @@
1
- ## PENDING
1
+ ## 0.2.2 (2019-03-19)
2
+
3
+ * Add support for "oncalls".
4
+
5
+ ## 0.2.1 (2019-03-19)
6
+
7
+ * Remove "configure" subcommand.
8
+ * Add missing dependencies to gemspec.
9
+
10
+ ## 0.2.0 (2018-12-27)
2
11
 
3
12
  * Add "--include" option for services.
4
- * Add "vendors".
13
+ * Add support for "vendors".
14
+ * Add support for "notifications".
15
+ * Add "viz" subcommand.
16
+ * Support JMESPath in "data" subcommands.
5
17
 
6
18
  ## 0.1.5 (2017-08-19)
7
19
 
@@ -35,6 +35,10 @@ module PagerJudy
35
35
  collection("notifications")
36
36
  end
37
37
 
38
+ def oncalls
39
+ collection("oncalls")
40
+ end
41
+
38
42
  def schedules
39
43
  collection("schedules")
40
44
  end
@@ -41,7 +41,7 @@ module PagerJudy
41
41
  include CollectionBehaviour
42
42
 
43
43
  def collection
44
- client.escalation_policies.with(query: query)
44
+ client.escalation_policies.with("query" => query)
45
45
  end
46
46
 
47
47
  end
@@ -65,7 +65,7 @@ module PagerJudy
65
65
  include CollectionBehaviour
66
66
 
67
67
  def collection
68
- client.extensions.with(query: query)
68
+ client.extensions.with("query" => query)
69
69
  end
70
70
 
71
71
  end
@@ -103,6 +103,67 @@ module PagerJudy
103
103
 
104
104
  end
105
105
 
106
+ subcommand "oncalls", "Display those currently on-call" do
107
+
108
+ include TimeFiltering
109
+
110
+ option %w[-s --schedule], "ID", "schedule ID", :multivalued => true
111
+ option %w[-u --user], "ID", "user ID", :multivalued => true
112
+
113
+ self.default_subcommand = "summary"
114
+
115
+ subcommand ["summary", "s"], "One-line summary" do
116
+
117
+ def execute
118
+ collection.map(&method(:oncall_summary)).compact.uniq.each(&method(:puts))
119
+ end
120
+
121
+ def oncall_summary(oncall)
122
+ schedule = oncall.dig('schedule', 'summary')
123
+ return nil if schedule.nil?
124
+ from = parse_time(oncall.fetch('start'))
125
+ to = parse_time(oncall.fetch('end'))
126
+ who = oncall.dig('user', 'summary')
127
+ sprintf("%-35s %-19s %s", schedule, who, format_time_range(from, to))
128
+ end
129
+
130
+ def parse_time(string)
131
+ return nil if string.nil?
132
+ Time.parse(string).localtime
133
+ end
134
+
135
+ def format_time_range(from, to)
136
+ bits = [from.strftime("%Y-%m-%d %H:%M")]
137
+ unless to.nil?
138
+ if to.to_date == from.to_date
139
+ bits << to.strftime("%H:%M")
140
+ else
141
+ bits << to.strftime("%Y-%m-%d %H:%M")
142
+ end
143
+ end
144
+ bits.join(" - ")
145
+ end
146
+
147
+ end
148
+
149
+ subcommand ["data", "d"], "Full details" do
150
+ include CollectionBehaviour::DataSubcommand
151
+ end
152
+
153
+ def collection
154
+ filters = time_filters.merge(other_filters)
155
+ client.oncalls.with(filters)
156
+ end
157
+
158
+ def other_filters
159
+ {
160
+ "user_ids[]" => user_list,
161
+ "schedule_ids[]" => schedule_list
162
+ }.reject { |_,v| v.empty? }
163
+ end
164
+
165
+ end
166
+
106
167
  subcommand "schedule", "Display schedule" do
107
168
 
108
169
  parameter "ID", "schedule ID"
@@ -122,7 +183,7 @@ module PagerJudy
122
183
  include CollectionBehaviour
123
184
 
124
185
  def collection
125
- client.schedules.with(query: query)
186
+ client.schedules.with("query" => query)
126
187
  end
127
188
 
128
189
  end
@@ -180,7 +241,7 @@ module PagerJudy
180
241
  include CollectionBehaviour
181
242
 
182
243
  def collection
183
- client.teams.with(query: query)
244
+ client.teams.with("query" => query)
184
245
  end
185
246
 
186
247
  end
@@ -17,8 +17,8 @@ module PagerJudy
17
17
 
18
18
  def time_filters
19
19
  {
20
- since: after,
21
- until: before
20
+ "since" => after,
21
+ "until" => before
22
22
  }.select { |_,v| v }
23
23
  end
24
24
 
@@ -1,5 +1,5 @@
1
1
  module PagerJudy
2
2
 
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pager_judy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-18 00:00:00.000000000 Z
11
+ date: 2019-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp