flapjack-diner 2.0.0.pre.alpha.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -10
- data/README.md +165 -272
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner.rb +54 -25
- data/lib/flapjack-diner/argument_validator.rb +0 -17
- data/lib/flapjack-diner/configuration.rb +417 -0
- data/lib/flapjack-diner/log_formatter.rb +22 -0
- data/lib/flapjack-diner/query.rb +114 -0
- data/lib/flapjack-diner/relationships.rb +180 -0
- data/lib/flapjack-diner/request.rb +280 -0
- data/lib/flapjack-diner/resources.rb +64 -0
- data/lib/flapjack-diner/response.rb +91 -0
- data/lib/flapjack-diner/tools.rb +46 -456
- data/lib/flapjack-diner/utility.rb +16 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/spec/flapjack-diner_spec.rb +9 -18
- data/spec/{resources/relationships_spec.rb → relationships_spec.rb} +75 -29
- data/spec/resources/checks_spec.rb +7 -7
- data/spec/resources/contacts_spec.rb +21 -19
- data/spec/resources/events_spec.rb +13 -13
- data/spec/resources/maintenance_periods_spec.rb +3 -3
- data/spec/resources/media_spec.rb +3 -3
- data/spec/resources/metrics_spec.rb +1 -1
- data/spec/resources/rules_spec.rb +278 -0
- data/spec/resources/states_spec.rb +1 -1
- data/spec/resources/statistics_spec.rb +1 -1
- data/spec/resources/tags_spec.rb +75 -19
- data/spec/support/fixture_data.rb +57 -98
- metadata +21 -29
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -135
- data/lib/flapjack-diner/resources/acceptors.rb +0 -77
- data/lib/flapjack-diner/resources/checks.rb +0 -52
- data/lib/flapjack-diner/resources/contacts.rb +0 -54
- data/lib/flapjack-diner/resources/events.rb +0 -54
- data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -76
- data/lib/flapjack-diner/resources/media.rb +0 -75
- data/lib/flapjack-diner/resources/metrics.rb +0 -23
- data/lib/flapjack-diner/resources/rejectors.rb +0 -77
- data/lib/flapjack-diner/resources/relationships.rb +0 -314
- data/lib/flapjack-diner/resources/states.rb +0 -24
- data/lib/flapjack-diner/resources/statistics.rb +0 -24
- data/lib/flapjack-diner/resources/tags.rb +0 -47
- data/spec/resources/acceptors_spec.rb +0 -278
- data/spec/resources/rejectors_spec.rb +0 -278
data/.rubocop.yml
DELETED
@@ -1,21 +0,0 @@
|
|
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
DELETED
@@ -1,135 +0,0 @@
|
|
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
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
require 'flapjack-diner/version'
|
6
|
-
require 'flapjack-diner/argument_validator'
|
7
|
-
|
8
|
-
module Flapjack
|
9
|
-
module Diner
|
10
|
-
module Resources
|
11
|
-
module Acceptors
|
12
|
-
|
13
|
-
def create_acceptors(*args)
|
14
|
-
data = unwrap_data(*args)
|
15
|
-
validate_params(data) do
|
16
|
-
validate :query => :id, :as => :uuid
|
17
|
-
validate :query => :name, :as => :string
|
18
|
-
validate :query => :all, :as => :boolean
|
19
|
-
validate :query => :conditions_list, :as => :string
|
20
|
-
# TODO proper validation of time_restrictions field
|
21
|
-
validate :query => :contact, :as => [:singular_link_uuid, :required]
|
22
|
-
validate :query => :media, :as => :multiple_link_uuid
|
23
|
-
validate :query => :tags, :as => :multiple_link
|
24
|
-
end
|
25
|
-
_acceptors_validate_association(data)
|
26
|
-
perform_post(:acceptors, '/acceptors', data)
|
27
|
-
end
|
28
|
-
|
29
|
-
def acceptors(*args)
|
30
|
-
ids, data = unwrap_uuids(*args), unwrap_data(*args)
|
31
|
-
validate_params(data) do
|
32
|
-
validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
|
33
|
-
validate :query => :filter, :as => :hash
|
34
|
-
validate :query => [:page, :per_page], :as => :positive_integer
|
35
|
-
end
|
36
|
-
perform_get('/acceptors', ids, data)
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_acceptors(*args)
|
40
|
-
data = unwrap_data(*args)
|
41
|
-
validate_params(data) do
|
42
|
-
validate :query => :id, :as => [:uuid, :required]
|
43
|
-
validate :query => :name, :as => :string
|
44
|
-
validate :query => :all, :as => :boolean
|
45
|
-
validate :query => :conditions_list, :as => :string
|
46
|
-
# TODO proper validation of time_restrictions field
|
47
|
-
validate :query => :media, :as => :multiple_link_uuid
|
48
|
-
validate :query => :tags, :as => :multiple_link
|
49
|
-
end
|
50
|
-
perform_patch(:acceptors, "/acceptors", data)
|
51
|
-
end
|
52
|
-
|
53
|
-
def delete_acceptors(*ids)
|
54
|
-
raise "'delete_acceptors' requires at least one acceptor id parameter" if ids.nil? || ids.empty?
|
55
|
-
perform_delete(:acceptors, '/acceptors', *ids)
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def _acceptors_validate_association(data)
|
61
|
-
case data
|
62
|
-
when Array
|
63
|
-
data.each do |d|
|
64
|
-
unless d.has_key?(:contact)
|
65
|
-
raise ArgumentError.new("Contact association must be provided for all acceptors")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
when Hash
|
69
|
-
unless data.has_key?(:contact)
|
70
|
-
raise ArgumentError.new("Contact association must be provided for acceptor")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
require 'flapjack-diner/version'
|
6
|
-
require 'flapjack-diner/argument_validator'
|
7
|
-
|
8
|
-
module Flapjack
|
9
|
-
module Diner
|
10
|
-
module Resources
|
11
|
-
module Checks
|
12
|
-
def create_checks(*args)
|
13
|
-
data = unwrap_data(*args)
|
14
|
-
validate_params(data) do
|
15
|
-
validate :query => :id, :as => :uuid
|
16
|
-
validate :query => :name, :as => [:required, :non_empty_string]
|
17
|
-
validate :query => :enabled, :as => :boolean
|
18
|
-
validate :query => :tags, :as => :multiple_link
|
19
|
-
end
|
20
|
-
perform_post(:checks, '/checks', data)
|
21
|
-
end
|
22
|
-
|
23
|
-
def checks(*args)
|
24
|
-
ids, data = unwrap_uuids(*args), unwrap_data(*args)
|
25
|
-
validate_params(data) do
|
26
|
-
validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
|
27
|
-
validate :query => :filter, :as => :hash
|
28
|
-
validate :query => [:page, :per_page], :as => :positive_integer
|
29
|
-
end
|
30
|
-
perform_get('/checks', ids, data)
|
31
|
-
end
|
32
|
-
|
33
|
-
def update_checks(*args)
|
34
|
-
data = unwrap_data(*args)
|
35
|
-
validate_params(data) do
|
36
|
-
validate :query => :id, :as => [:required, :uuid]
|
37
|
-
validate :query => :name, :as => :non_empty_string
|
38
|
-
validate :query => :enabled, :as => :boolean
|
39
|
-
validate :query => :tags, :as => :multiple_link
|
40
|
-
end
|
41
|
-
perform_patch(:checks, "/checks", data)
|
42
|
-
end
|
43
|
-
|
44
|
-
def delete_checks(*ids)
|
45
|
-
raise "'delete_checks' requires at least one check id " \
|
46
|
-
'parameter' if ids.nil? || ids.empty?
|
47
|
-
perform_delete(:checks, '/checks', *ids)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
require 'flapjack-diner/version'
|
6
|
-
require 'flapjack-diner/argument_validator'
|
7
|
-
|
8
|
-
module Flapjack
|
9
|
-
module Diner
|
10
|
-
module Resources
|
11
|
-
module Contacts
|
12
|
-
def create_contacts(*args)
|
13
|
-
data = unwrap_data(*args)
|
14
|
-
validate_params(data) do
|
15
|
-
validate :query => :id, :as => :uuid
|
16
|
-
validate :query => :name, :as => [:required, :non_empty_string]
|
17
|
-
validate :query => :timezone, :as => :non_empty_string
|
18
|
-
end
|
19
|
-
# FIXME validate timezone string, if it's possible to do
|
20
|
-
# this without an extra gem dependency
|
21
|
-
perform_post(:contacts, '/contacts', data)
|
22
|
-
end
|
23
|
-
|
24
|
-
def contacts(*args)
|
25
|
-
ids, data = unwrap_uuids(*args), unwrap_data(*args)
|
26
|
-
validate_params(data) do
|
27
|
-
validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
|
28
|
-
validate :query => :filter, :as => :hash
|
29
|
-
validate :query => [:page, :per_page], :as => :positive_integer
|
30
|
-
end
|
31
|
-
perform_get('/contacts', ids, data)
|
32
|
-
end
|
33
|
-
|
34
|
-
def update_contacts(*args)
|
35
|
-
data = unwrap_data(*args)
|
36
|
-
validate_params(data) do
|
37
|
-
validate :query => :id, :as => [:required, :uuid]
|
38
|
-
validate :query => [:name, :timezone], :as => :non_empty_string
|
39
|
-
end
|
40
|
-
# FIXME validate timezone string, if it's possible to do
|
41
|
-
# this without an extra gem dependency
|
42
|
-
perform_patch(:contacts, "/contacts", data)
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete_contacts(*ids)
|
46
|
-
raise "'delete_contacts' requires at least one contact id " \
|
47
|
-
'parameter' if ids.nil? || ids.empty?
|
48
|
-
perform_delete(:contacts, '/contacts', *ids)
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
require 'flapjack-diner/version'
|
6
|
-
require 'flapjack-diner/argument_validator'
|
7
|
-
|
8
|
-
module Flapjack
|
9
|
-
module Diner
|
10
|
-
module Resources
|
11
|
-
module Events
|
12
|
-
def create_acknowledgements(*args)
|
13
|
-
data = unwrap_data(*args)
|
14
|
-
validate_params(data) do
|
15
|
-
validate :query => :duration, :as => :positive_integer
|
16
|
-
validate :query => :summary, :as => :non_empty_string
|
17
|
-
validate :query => :check, :as => :singular_link_uuid
|
18
|
-
validate :query => :tag, :as => :singular_link
|
19
|
-
end
|
20
|
-
_events_validate_association(data, 'acknowledgement')
|
21
|
-
perform_post(:acknowledgements, "/acknowledgements", data)
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_test_notifications(*args)
|
25
|
-
data = unwrap_data(*args)
|
26
|
-
validate_params(data) do
|
27
|
-
validate :query => :summary, :as => :non_empty_string
|
28
|
-
validate :query => :check, :as => :singular_link_uuid
|
29
|
-
validate :query => :tag, :as => :singular_link
|
30
|
-
end
|
31
|
-
_events_validate_association(data, 'test notification')
|
32
|
-
perform_post(:test_notifications, "/test_notifications", data)
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def _events_validate_association(data, type)
|
38
|
-
case data
|
39
|
-
when Array
|
40
|
-
data.each do |d|
|
41
|
-
unless d.has_key?(:check) || d.has_key?(:tag)
|
42
|
-
raise ArgumentError.new("Check or tag association must be provided for all #{type}s")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
when Hash
|
46
|
-
unless data.has_key?(:check) || data.has_key?(:tag)
|
47
|
-
raise ArgumentError.new("Check or tag association must be provided for #{type}")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
require 'flapjack-diner/version'
|
6
|
-
require 'flapjack-diner/argument_validator'
|
7
|
-
|
8
|
-
module Flapjack
|
9
|
-
module Diner
|
10
|
-
module Resources
|
11
|
-
module MaintenancePeriods
|
12
|
-
|
13
|
-
def create_scheduled_maintenances(*args)
|
14
|
-
data = unwrap_data(*args)
|
15
|
-
validate_params(data) do
|
16
|
-
validate :query => :id, :as => :uuid
|
17
|
-
validate :query => :start_time, :as => [:required, :time]
|
18
|
-
validate :query => :end_time, :as => [:required, :time]
|
19
|
-
validate :query => :summary, :as => :non_empty_string
|
20
|
-
validate :query => :check, :as => :singular_link_uuid
|
21
|
-
validate :query => :tag, :as => :singular_link
|
22
|
-
end
|
23
|
-
_maintenance_periods_validate_association(data, 'scheduled maintenance period')
|
24
|
-
perform_post(:scheduled_maintenances, '/scheduled_maintenances', data)
|
25
|
-
end
|
26
|
-
|
27
|
-
def update_scheduled_maintenances(*args)
|
28
|
-
data = unwrap_data(*args)
|
29
|
-
validate_params(data) do
|
30
|
-
validate :query => :id, :as => [:required, :uuid]
|
31
|
-
validate :query => [:start_time, :end_time], :as => :time
|
32
|
-
end
|
33
|
-
perform_patch(:scheduled_maintenances, '/scheduled_maintenances',
|
34
|
-
data)
|
35
|
-
end
|
36
|
-
|
37
|
-
def update_unscheduled_maintenances(*args)
|
38
|
-
data = unwrap_data(*args)
|
39
|
-
validate_params(data) do
|
40
|
-
validate :query => :id, :as => [:required, :uuid]
|
41
|
-
validate :query => :end_time, :as => :time
|
42
|
-
end
|
43
|
-
perform_patch(:unscheduled_maintenances, '/unscheduled_maintenances',
|
44
|
-
data)
|
45
|
-
end
|
46
|
-
|
47
|
-
def delete_scheduled_maintenances(*ids)
|
48
|
-
if ids.nil? || ids.empty?
|
49
|
-
raise "'delete_scheduled_maintenances' requires " \
|
50
|
-
"at least one scheduled maintenance id parameter"
|
51
|
-
end
|
52
|
-
perform_delete(:scheduled_maintenances, '/scheduled_maintenances',
|
53
|
-
*ids)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def _maintenance_periods_validate_association(data, type)
|
59
|
-
case data
|
60
|
-
when Array
|
61
|
-
data.each do |d|
|
62
|
-
unless d.has_key?(:check) || d.has_key?(:tag)
|
63
|
-
raise ArgumentError.new("Check or tag association must be provided for all #{type}s")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
when Hash
|
67
|
-
unless data.has_key?(:check) || data.has_key?(:tag)
|
68
|
-
raise ArgumentError.new("Check or tag association must be provided for #{type}")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|