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 +4 -4
- data/CHANGES.md +14 -2
- data/lib/pager_judy/api/client.rb +4 -0
- data/lib/pager_judy/cli/main_command.rb +65 -4
- data/lib/pager_judy/cli/time_filtering.rb +2 -2
- data/lib/pager_judy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52d2f9ad7cc38c994d770a488563b643dbd568e40a635f912cab9fb32739d708
|
4
|
+
data.tar.gz: e5190b125b5602cb079fe476090f79fbbac07fb47aa3bdb950f6618db148f904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2cce233aace32a45888c9c7cae6dab59059032ab2c94b0c808582c209e70ad595bcdbd1b89f68fddc012b59c3af75ee3eca15fd48a03f860677b58b618a0af8
|
7
|
+
data.tar.gz: 0aeca53e8377f18636b37a317a8c08657b0a4d8721c370c715e3ea384a40fa82a0d2c948608af4b5065dfadb2821f31e05fcd1971dfc6bdcef9dd603c175ac57
|
data/CHANGES.md
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
-
##
|
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
|
|
@@ -41,7 +41,7 @@ module PagerJudy
|
|
41
41
|
include CollectionBehaviour
|
42
42
|
|
43
43
|
def collection
|
44
|
-
client.escalation_policies.with(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
|
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
|
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
|
244
|
+
client.teams.with("query" => query)
|
184
245
|
end
|
185
246
|
|
186
247
|
end
|
data/lib/pager_judy/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|