flapjack-diner 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +21 -0
- data/.rubocop_todo.yml +135 -0
- data/Gemfile +7 -0
- data/README.md +86 -20
- data/flapjack-diner.gemspec +11 -15
- data/lib/flapjack-diner.rb +23 -548
- data/lib/flapjack-diner/argument_validator.rb +31 -22
- data/lib/flapjack-diner/resources/checks.rb +58 -0
- data/lib/flapjack-diner/resources/contacts.rb +70 -0
- data/lib/flapjack-diner/resources/entities.rb +68 -0
- data/lib/flapjack-diner/resources/maintenance_periods.rb +82 -0
- data/lib/flapjack-diner/resources/media.rb +61 -0
- data/lib/flapjack-diner/resources/notification_rules.rb +66 -0
- data/lib/flapjack-diner/resources/notifications.rb +27 -0
- data/lib/flapjack-diner/resources/pagerduty_credentials.rb +60 -0
- data/lib/flapjack-diner/resources/reports.rb +33 -0
- data/lib/flapjack-diner/tools.rb +277 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/spec/argument_validator_spec.rb +15 -15
- data/spec/flapjack-diner_spec.rb +58 -1275
- data/spec/pacts/flapjack-diner-flapjack.json +4522 -0
- data/spec/resources/checks_spec.rb +171 -0
- data/spec/resources/contacts_spec.rb +297 -0
- data/spec/resources/entities_spec.rb +181 -0
- data/spec/resources/maintenance_periods_spec.rb +603 -0
- data/spec/resources/media_spec.rb +277 -0
- data/spec/resources/notification_rules_spec.rb +341 -0
- data/spec/resources/notifications_spec.rb +210 -0
- data/spec/resources/pagerduty_credentials_spec.rb +243 -0
- data/spec/resources/reports_spec.rb +255 -0
- data/spec/spec_helper.rb +14 -2
- metadata +35 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4628fa35a6db22f5a6318835a606b1622f355dec
|
4
|
+
data.tar.gz: 548b762bb9f80d2180be0c74f12b73b32f6f60f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8bcacc5f5c584dad6cc3b6f928233eac11acb68a5830d5a676611d123eb1d4f0d83eaf2fdc6308236a243d2f0b8a9ba116680f7811b2968c8d676b59e867559
|
7
|
+
data.tar.gz: fad9ad761c145505b1a0e5fbdb79d146e6cc6226b3966481da3388e35828e444eb7a612c4d66a5406d4efd0880df77575c136f4dfa6f62b8e37877f9733b7e2e
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- 'lib/flapjack-diner.rb'
|
6
|
+
|
7
|
+
# doesn't handle multi-file state
|
8
|
+
Documentation:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/HashSyntax:
|
12
|
+
EnforcedStyle: hash_rockets
|
13
|
+
|
14
|
+
Style/SignalException:
|
15
|
+
EnforcedStyle: only_raise
|
16
|
+
|
17
|
+
Style/SpaceInsideBlockBraces:
|
18
|
+
SpaceBeforeBlockParameters: false
|
19
|
+
|
20
|
+
Style/SpaceInsideHashLiteralBraces:
|
21
|
+
EnforcedStyle: no_space
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`.
|
2
|
+
# The point is for the user to remove these configuration records
|
3
|
+
# one by one as the offences are removed from the code base.
|
4
|
+
|
5
|
+
# AccessorMethodName:
|
6
|
+
# Enabled: false
|
7
|
+
|
8
|
+
# AlignArray:
|
9
|
+
# Enabled: false
|
10
|
+
|
11
|
+
# AlignHash:
|
12
|
+
# Enabled: false
|
13
|
+
|
14
|
+
# AlignParameters:
|
15
|
+
# Enabled: false
|
16
|
+
|
17
|
+
# AndOr:
|
18
|
+
# Enabled: false
|
19
|
+
|
20
|
+
# AssignmentInCondition:
|
21
|
+
# Enabled: false
|
22
|
+
|
23
|
+
# BlockAlignment:
|
24
|
+
# Enabled: false
|
25
|
+
|
26
|
+
# BlockNesting:
|
27
|
+
# Max: 4
|
28
|
+
|
29
|
+
# Blocks:
|
30
|
+
# Enabled: false
|
31
|
+
|
32
|
+
# BracesAroundHashParameters:
|
33
|
+
# Enabled: false
|
34
|
+
|
35
|
+
# CaseIndentation:
|
36
|
+
# Enabled: false
|
37
|
+
|
38
|
+
# ClassLength:
|
39
|
+
# Max: 221
|
40
|
+
|
41
|
+
# CollectionMethods:
|
42
|
+
# Enabled: false
|
43
|
+
|
44
|
+
# CommentAnnotation:
|
45
|
+
# Enabled: false
|
46
|
+
|
47
|
+
# CyclomaticComplexity:
|
48
|
+
# Max: 32
|
49
|
+
|
50
|
+
# DotPosition:
|
51
|
+
# Enabled: false
|
52
|
+
|
53
|
+
# EmptyLines:
|
54
|
+
# Enabled: false
|
55
|
+
|
56
|
+
# EmptyLinesAroundBody:
|
57
|
+
# Enabled: false
|
58
|
+
|
59
|
+
# EndAlignment:
|
60
|
+
# Enabled: false
|
61
|
+
|
62
|
+
# FavorUnlessOverNegatedIf:
|
63
|
+
# Enabled: false
|
64
|
+
|
65
|
+
# FinalNewline:
|
66
|
+
# Enabled: false
|
67
|
+
|
68
|
+
# HashMethods:
|
69
|
+
# Enabled: false
|
70
|
+
|
71
|
+
# IfUnlessModifier:
|
72
|
+
# Enabled: false
|
73
|
+
|
74
|
+
# IndentationWidth:
|
75
|
+
# Enabled: false
|
76
|
+
|
77
|
+
# LineLength:
|
78
|
+
# Max: 120
|
79
|
+
|
80
|
+
# MethodCallParentheses:
|
81
|
+
# Enabled: false
|
82
|
+
|
83
|
+
# MethodLength:
|
84
|
+
# Max: 95
|
85
|
+
|
86
|
+
# MultilineBlockChain:
|
87
|
+
# Enabled: false
|
88
|
+
|
89
|
+
# ParenthesesAroundCondition:
|
90
|
+
# Enabled: false
|
91
|
+
|
92
|
+
# PredicateName:
|
93
|
+
# Enabled: false
|
94
|
+
|
95
|
+
# RaiseArgs:
|
96
|
+
# Enabled: false
|
97
|
+
|
98
|
+
# RedundantSelf:
|
99
|
+
# Enabled: false
|
100
|
+
|
101
|
+
# RescueException:
|
102
|
+
# Enabled: false
|
103
|
+
|
104
|
+
# Semicolon:
|
105
|
+
# Enabled: false
|
106
|
+
|
107
|
+
# ShadowingOuterLocalVariable:
|
108
|
+
# Enabled: false
|
109
|
+
|
110
|
+
# SpaceAfterNot:
|
111
|
+
# Enabled: false
|
112
|
+
|
113
|
+
# SpaceAroundOperators:
|
114
|
+
# Enabled: false
|
115
|
+
|
116
|
+
# SpaceInsideHashLiteralBraces:
|
117
|
+
# Enabled: false
|
118
|
+
|
119
|
+
# SpaceInsideParens:
|
120
|
+
# Enabled: false
|
121
|
+
|
122
|
+
# SpecialGlobalVars:
|
123
|
+
# Enabled: false
|
124
|
+
|
125
|
+
# StringLiterals:
|
126
|
+
# Enabled: false
|
127
|
+
|
128
|
+
# TrivialAccessors:
|
129
|
+
# Enabled: false
|
130
|
+
|
131
|
+
# UselessAssignment:
|
132
|
+
# Enabled: false
|
133
|
+
|
134
|
+
# WordArray:
|
135
|
+
# Enabled: false
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,16 @@ Optionally, set a logger to log requests & responses:
|
|
36
36
|
Flapjack::Diner.logger = Logger.new('logs/flapjack_diner.log')
|
37
37
|
```
|
38
38
|
|
39
|
+
If you want to alter timeout periods for HTTP connection open and reading responses:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# Set HTTP connect timeout to 30 seconds
|
43
|
+
Flapjack::Diner.open_timeout(30)
|
44
|
+
|
45
|
+
# Set HTTP read timeout to 5 minutes
|
46
|
+
Flapjack::Diner.read_timeout(300)
|
47
|
+
```
|
48
|
+
|
39
49
|
If you want the old behaviour wrt returning hashes with keys as strings (they're now symbols by default) then:
|
40
50
|
|
41
51
|
```ruby
|
@@ -52,7 +62,7 @@ Parameters for all of **flapjack-diner**'s functions are organised into three ca
|
|
52
62
|
|
53
63
|
While these can be passed in in any order, the convention is that they will be ordered as listed above.
|
54
64
|
|
55
|
-
If any operation fails, `Flapjack::Diner.last_error` will contain an error message regarding the failure.
|
65
|
+
If any operation fails (returning nil), `Flapjack::Diner.last_error` will contain an error message regarding the failure.
|
56
66
|
|
57
67
|
### Contacts
|
58
68
|
|
@@ -86,6 +96,7 @@ If any operation fails, `Flapjack::Diner.last_error` will contain an error messa
|
|
86
96
|
|
87
97
|
* [create_entities](#create_entities)
|
88
98
|
* [entities](#entities)
|
99
|
+
* [entities_matching](#entities_matching)
|
89
100
|
* [update_entities](#update_entities)
|
90
101
|
|
91
102
|
* [create_scheduled_maintenances_entities](#create_scheduled_maintenances_entities)
|
@@ -98,7 +109,9 @@ If any operation fails, `Flapjack::Diner.last_error` will contain an error messa
|
|
98
109
|
|
99
110
|
### Checks
|
100
111
|
|
112
|
+
* [create_checks](#create_checks)
|
101
113
|
* [checks](#checks)
|
114
|
+
* [update_checks](#update_checks)
|
102
115
|
|
103
116
|
* [create_scheduled_maintenances_checks](#create_scheduled_maintenances_checks)
|
104
117
|
* [delete_scheduled_maintenances_checks](#delete_scheduled_maintenances_checks)
|
@@ -144,7 +157,7 @@ CONTACT
|
|
144
157
|
}
|
145
158
|
```
|
146
159
|
|
147
|
-
Returns
|
160
|
+
Returns an array of contact ids if creation succeeded, or false if creation failed.
|
148
161
|
|
149
162
|
<a name="contacts"> </a>
|
150
163
|
#### contacts
|
@@ -172,18 +185,18 @@ Flapjack::Diner.update_contacts(ID1, ID2, ..., :key => value, ...)
|
|
172
185
|
|
173
186
|
Acceptable update field keys are
|
174
187
|
|
175
|
-
`:first_name`, `:last_name`, `:email
|
188
|
+
`:first_name`, `:last_name`, `:email`
|
176
189
|
|
177
190
|
as well as the linkage operations
|
178
191
|
|
179
192
|
`:add_entity`, `:remove_entity`
|
180
193
|
`:add_notification_rule`, `:remove_notification_rule`
|
181
194
|
|
182
|
-
which take the id of the relevant resource as the value.
|
195
|
+
which take the id (for entity and notification rule) of the relevant resource as the value.
|
183
196
|
|
184
|
-
(NB: `:add_medium` and `:remove_medium` are not supported in Flapjack v1.
|
197
|
+
(NB: `:add_medium` and `:remove_medium` are not supported in Flapjack v1.x but will be in future versions.)
|
185
198
|
|
186
|
-
Returns true if updating succeeded
|
199
|
+
Returns true if updating succeeded, false if updating failed.
|
187
200
|
|
188
201
|
<a name="delete_contacts"> </a>
|
189
202
|
#### delete_contacts
|
@@ -221,12 +234,12 @@ MEDIUM
|
|
221
234
|
}
|
222
235
|
```
|
223
236
|
|
224
|
-
Returns
|
237
|
+
Returns an array of media ids if creation succeeded, or false if creation failed. (Ids cannot be passed in for media records in Flapjack v1.x.)
|
225
238
|
|
226
239
|
<a name="media"> </a>
|
227
240
|
#### media
|
228
241
|
|
229
|
-
Return data for one, some or all notification media. Notification media ids are formed by compounding their linked contact's ID and their type in a string (e.g. '23_sms')
|
242
|
+
Return data for one, some or all notification media. Notification media ids are formed by compounding their linked contact's ID and their type in a string (e.g. '23_sms').
|
230
243
|
|
231
244
|
```ruby
|
232
245
|
medium = Flapjack::Diner.media(ID)
|
@@ -271,7 +284,7 @@ Returns true if deletion succeeded or false if deletion failed.
|
|
271
284
|
---
|
272
285
|
|
273
286
|
<a name="create_contact_pagerduty_credentials"> </a>
|
274
|
-
####
|
287
|
+
#### create_contact_pagerduty_credentials
|
275
288
|
|
276
289
|
Create pagerduty credentials for a contact.
|
277
290
|
|
@@ -289,7 +302,7 @@ PAGERDUTY_CREDENTIALS
|
|
289
302
|
}
|
290
303
|
```
|
291
304
|
|
292
|
-
Returns
|
305
|
+
Returns an array of contact ids if creation succeeded, or false if creation failed. (As contacts may only have one set of pagerduty credentials, Flapjack v1.x does not store a separate data model, thus theses objects have no separate ids.)
|
293
306
|
|
294
307
|
<a name="pagerduty_credentials"> </a>
|
295
308
|
#### pagerduty_credentials
|
@@ -365,7 +378,7 @@ NOTIFICATION_RULE
|
|
365
378
|
}
|
366
379
|
```
|
367
380
|
|
368
|
-
Returns
|
381
|
+
Returns an array of notification rule ids if creation succeeded, or false if creation failed.
|
369
382
|
|
370
383
|
<a name="notification_rules"> </a>
|
371
384
|
#### notification_rules
|
@@ -398,7 +411,7 @@ Acceptable update field keys are
|
|
398
411
|
Returns true if updating succeeded or false if updating failed.
|
399
412
|
|
400
413
|
<a name="delete_notification_rules"> </a>
|
401
|
-
####
|
414
|
+
#### delete_notification_rules
|
402
415
|
|
403
416
|
Delete one or more notification rules.
|
404
417
|
|
@@ -432,7 +445,7 @@ ENTITY
|
|
432
445
|
}
|
433
446
|
```
|
434
447
|
|
435
|
-
Returns
|
448
|
+
Returns an array of entity ids if creation succeeded, or false if creation failed.
|
436
449
|
|
437
450
|
<a name="entities"> </a>
|
438
451
|
### entities
|
@@ -445,6 +458,15 @@ some_entities = Flapjack::Diner.entities(ID1, ID2, ...)
|
|
445
458
|
all_entities = Flapjack::Diner.entities
|
446
459
|
```
|
447
460
|
|
461
|
+
<a name="entities_matching"> </a>
|
462
|
+
### entities_matching
|
463
|
+
|
464
|
+
Returns an array of entities matching a given regular expression
|
465
|
+
|
466
|
+
```ruby
|
467
|
+
entities = Flapjack::Diner.entities_matching(/^db-app-01/)
|
468
|
+
```
|
469
|
+
|
448
470
|
<a name="update_entities"> </a>
|
449
471
|
### update_entities
|
450
472
|
|
@@ -458,15 +480,14 @@ Flapjack::Diner.update_entities(ID, :key => value, ...)
|
|
458
480
|
Flapjack::Diner.update_entities(ID1, ID2, ..., :key => value, ...)
|
459
481
|
```
|
460
482
|
|
461
|
-
|
462
|
-
|
463
|
-
`:name` and `:tags`
|
483
|
+
There are no valid update field keys yet.
|
464
484
|
|
465
|
-
|
485
|
+
The linkage operations
|
466
486
|
|
467
487
|
`:add_contact` and `:remove_contact`
|
488
|
+
`:add_tag` and `:remove_tag`
|
468
489
|
|
469
|
-
|
490
|
+
take the id (for contact) or the name (for tag) of the relevant resource as the value.
|
470
491
|
|
471
492
|
Returns true if updating succeeded or false if updating failed.
|
472
493
|
|
@@ -552,17 +573,62 @@ Returns true if creation succeeded or false if creation failed.
|
|
552
573
|
|
553
574
|
---
|
554
575
|
|
576
|
+
<a name="create_checks"> </a>
|
577
|
+
### create_checks
|
578
|
+
|
579
|
+
Create one or more checks.
|
580
|
+
|
581
|
+
```ruby
|
582
|
+
Flapjack::Diner.create_checks([CHECK, ...])
|
583
|
+
```
|
584
|
+
|
585
|
+
```
|
586
|
+
CHECK
|
587
|
+
{
|
588
|
+
:entity_id => STRING,
|
589
|
+
:name => STRING,
|
590
|
+
:tags => [STRING, ...]
|
591
|
+
}
|
592
|
+
```
|
593
|
+
|
594
|
+
Returns an array of check ids if creation succeeded, or false if creation failed. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
|
595
|
+
|
555
596
|
<a name="checks"> </a>
|
556
597
|
### checks
|
557
598
|
|
558
599
|
Return basic identity data for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
|
559
600
|
|
560
601
|
```ruby
|
561
|
-
check = Flapjack::Diner.
|
602
|
+
check = Flapjack::Diner.checks(ID)
|
562
603
|
some_checks = Flapjack::Diner.checks(ID1, ID2, ...)
|
563
604
|
all_checks = Flapjack::Diner.checks
|
564
605
|
```
|
565
606
|
|
607
|
+
<a name="update_checks"> </a>
|
608
|
+
### update_checks
|
609
|
+
|
610
|
+
Update data for one or more checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
|
611
|
+
|
612
|
+
```ruby
|
613
|
+
# update values for one checks
|
614
|
+
Flapjack::Diner.update_checks(ID, :key => value, ...)
|
615
|
+
|
616
|
+
# update values for multiple checks
|
617
|
+
Flapjack::Diner.update_checks(ID1, ID2, ..., :key => value, ...)
|
618
|
+
```
|
619
|
+
|
620
|
+
Acceptable update field keys are
|
621
|
+
|
622
|
+
`:enabled`
|
623
|
+
|
624
|
+
as well as the linkage operations
|
625
|
+
|
626
|
+
`:add_tag` and `:remove_tag`
|
627
|
+
|
628
|
+
which take the name of the tag as the value.
|
629
|
+
|
630
|
+
Returns true if updating succeeded or false if updating failed.
|
631
|
+
|
566
632
|
---
|
567
633
|
|
568
634
|
<a name="create_scheduled_maintenances_checks"> </a>
|
@@ -737,7 +803,7 @@ report_all = Flapjack::Diner.unscheduled_maintenance_report_checks
|
|
737
803
|
<a name="downtime_report_checks"> </a>
|
738
804
|
### downtime_report_checks
|
739
805
|
|
740
|
-
Return a report on
|
806
|
+
Return a report on downtime data for one, some or all checks. (Check ids are composed by joining together the check's entity's name, the character ':' and the check's name.)
|
741
807
|
|
742
808
|
```ruby
|
743
809
|
report = Flapjack::Diner.downtime_report_checks(CHECK_ID)
|
data/flapjack-diner.gemspec
CHANGED
@@ -2,25 +2,21 @@
|
|
2
2
|
require File.expand_path('../lib/flapjack-diner/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = [
|
6
|
-
gem.email = [
|
7
|
-
gem.summary =
|
8
|
-
gem.description =
|
5
|
+
gem.authors = ['Ali Graham']
|
6
|
+
gem.email = ['ali.graham@bulletproof.net']
|
7
|
+
gem.summary = 'Access the API of a Flapjack system monitoring server'
|
8
|
+
gem.description = 'Wraps raw API calls to a Flapjack server API with ' \
|
9
|
+
'friendlier ruby methods.'
|
9
10
|
gem.homepage = 'https://github.com/flapjack/flapjack-diner'
|
10
11
|
|
11
|
-
gem.files = `git ls-files`.split(
|
12
|
-
|
13
|
-
gem.
|
14
|
-
gem.
|
15
|
-
gem.
|
12
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR) -
|
13
|
+
['Gemfile.lock']
|
14
|
+
gem.executables = gem.files.grep(/^bin\//).map {|f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
16
|
+
gem.name = 'flapjack-diner'
|
17
|
+
gem.require_paths = ['lib']
|
16
18
|
gem.version = Flapjack::Diner::VERSION
|
17
19
|
|
18
20
|
gem.add_dependency('httparty', '>= 0.10')
|
19
21
|
gem.add_dependency('json', '>= 1.7.7')
|
20
|
-
|
21
|
-
gem.add_development_dependency('bundler')
|
22
|
-
gem.add_development_dependency('rake')
|
23
|
-
gem.add_development_dependency('rspec', '~> 2.0')
|
24
|
-
gem.add_development_dependency('simplecov')
|
25
|
-
gem.add_development_dependency('webmock')
|
26
22
|
end
|