flapjack-diner 1.4.0 → 2.0.0.a4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/README.md +620 -413
  5. data/flapjack-diner.gemspec +1 -1
  6. data/lib/flapjack-diner/argument_validator.rb +77 -7
  7. data/lib/flapjack-diner/configuration.rb +409 -0
  8. data/lib/flapjack-diner/index_range.rb +42 -0
  9. data/lib/flapjack-diner/log_formatter.rb +22 -0
  10. data/lib/flapjack-diner/query.rb +114 -0
  11. data/lib/flapjack-diner/relationships.rb +180 -0
  12. data/lib/flapjack-diner/request.rb +280 -0
  13. data/lib/flapjack-diner/resources.rb +64 -0
  14. data/lib/flapjack-diner/response.rb +91 -0
  15. data/lib/flapjack-diner/tools.rb +47 -251
  16. data/lib/flapjack-diner/utility.rb +16 -0
  17. data/lib/flapjack-diner/version.rb +1 -1
  18. data/lib/flapjack-diner.rb +54 -20
  19. data/spec/argument_validator_spec.rb +87 -28
  20. data/spec/flapjack-diner_spec.rb +42 -64
  21. data/spec/relationships_spec.rb +211 -0
  22. data/spec/resources/checks_spec.rb +219 -79
  23. data/spec/resources/contacts_spec.rb +179 -151
  24. data/spec/resources/events_spec.rb +208 -0
  25. data/spec/resources/maintenance_periods_spec.rb +177 -565
  26. data/spec/resources/media_spec.rb +157 -171
  27. data/spec/resources/metrics_spec.rb +45 -0
  28. data/spec/resources/rules_spec.rb +278 -0
  29. data/spec/resources/states_spec.rb +93 -0
  30. data/spec/resources/statistics_spec.rb +53 -0
  31. data/spec/resources/tags_spec.rb +243 -0
  32. data/spec/spec_helper.rb +16 -0
  33. data/spec/support/fixture_data.rb +541 -0
  34. metadata +33 -31
  35. data/.rubocop.yml +0 -21
  36. data/.rubocop_todo.yml +0 -135
  37. data/lib/flapjack-diner/resources/checks.rb +0 -64
  38. data/lib/flapjack-diner/resources/contacts.rb +0 -70
  39. data/lib/flapjack-diner/resources/entities.rb +0 -68
  40. data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -82
  41. data/lib/flapjack-diner/resources/media.rb +0 -61
  42. data/lib/flapjack-diner/resources/notification_rules.rb +0 -66
  43. data/lib/flapjack-diner/resources/notifications.rb +0 -28
  44. data/lib/flapjack-diner/resources/pagerduty_credentials.rb +0 -59
  45. data/lib/flapjack-diner/resources/reports.rb +0 -33
  46. data/spec/pacts/flapjack-diner-flapjack.json +0 -4515
  47. data/spec/resources/entities_spec.rb +0 -181
  48. data/spec/resources/notification_rules_spec.rb +0 -341
  49. data/spec/resources/notifications_spec.rb +0 -208
  50. data/spec/resources/pagerduty_credentials_spec.rb +0 -237
  51. data/spec/resources/reports_spec.rb +0 -255
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,64 +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_create_data(*args)
14
- validate_params(data) do
15
- validate :query => :entity_id, :as => [:required, :string]
16
- validate :query => :name, :as => [:required, :string]
17
- validate :query => :tags, :as => :array_of_strings
18
- end
19
- perform_post('/checks', nil, :checks => data)
20
- end
21
-
22
- def checks(*ids)
23
- perform_get('checks', '/checks', ids)
24
- end
25
-
26
- def checks_matching(name_re)
27
- raise "Must be a regexp: #{name_re.inspect}" unless
28
- name_re.is_a?(Regexp)
29
- checks.reject {|e| name_re.match(e[:name]).nil? }
30
- end
31
-
32
- def update_checks(*args)
33
- ids, params = unwrap_ids(*args), unwrap_params(*args)
34
- raise "'update_checks' requires at least one check id " \
35
- 'parameter' if ids.nil? || ids.empty?
36
- validate_params(params) do
37
- validate :query => :enabled, :as => :boolean
38
- validate :query => :tags, :as => :array_of_strings
39
- end
40
- perform_patch("/checks/#{escaped_ids(ids)}", nil,
41
- update_checks_ops(params))
42
- end
43
-
44
- private
45
-
46
- def update_checks_ops(params)
47
- ops = params.each_with_object([]) do |(k, v), memo|
48
- case k
49
- when :enabled
50
- memo << patch_replace('checks', k, v)
51
- when :add_tag
52
- memo << patch_add('checks', 'tags', v)
53
- when :remove_tag
54
- memo << patch_remove('checks', 'tags', v)
55
- end
56
- end
57
- raise "'update_checks' did not find any valid update " \
58
- 'fields' if ops.empty?
59
- ops
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,70 +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_create_data(*args)
14
- validate_params(data) do
15
- validate :query => [:first_name, :last_name, :email],
16
- :as => [:required, :string]
17
- validate :query => :timezone, :as => :string
18
- validate :query => :tags, :as => :array_of_strings
19
- end
20
- perform_post('/contacts', nil, :contacts => data)
21
- end
22
-
23
- def contacts(*ids)
24
- perform_get('contacts', '/contacts', ids)
25
- end
26
-
27
- def update_contacts(*args)
28
- ids, params = unwrap_ids(*args), unwrap_params(*args)
29
- raise "'update_contacts' requires at least one contact id " \
30
- 'parameter' if ids.nil? || ids.empty?
31
- validate_params(params) do
32
- validate :query => [:first_name, :last_name,
33
- :email, :timezone], :as => :string
34
- validate :query => :tags, :as => :array_of_strings
35
- end
36
- perform_patch("/contacts/#{escaped_ids(ids)}", nil,
37
- update_contacts_ops(params))
38
- end
39
-
40
- def delete_contacts(*ids)
41
- raise "'delete_contacts' requires at least one contact id " \
42
- 'parameter' if ids.nil? || ids.empty?
43
- perform_delete('/contacts', ids)
44
- end
45
-
46
- private
47
-
48
- def update_contacts_ops(params)
49
- ops = params.each_with_object([]) do |(k, v), memo|
50
- case k
51
- when :add_entity
52
- memo << patch_add('contacts', 'entities', v)
53
- when :remove_entity
54
- memo << patch_remove('contacts', 'entities', v)
55
- when :add_notification_rule
56
- memo << patch_add('contacts', 'notification_rules', v)
57
- when :remove_notification_rule
58
- memo << patch_remove('contacts', 'notification_rules', v)
59
- when :first_name, :last_name, :email, :timezone
60
- memo << patch_replace('contacts', k, v)
61
- end
62
- end
63
- raise "'update_contacts' did not find any valid update " \
64
- 'fields' if ops.empty?
65
- ops
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,68 +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 Entities
12
- def create_entities(*args)
13
- data = unwrap_create_data(*args)
14
- validate_params(data) do
15
- validate :query => :id, :as => [:required, :string]
16
- validate :query => :name, :as => :string
17
- validate :query => :tags, :as => :array_of_strings
18
- end
19
- perform_post('/entities', nil, :entities => data)
20
- end
21
-
22
- def entities(*ids)
23
- perform_get('entities', '/entities', ids)
24
- end
25
-
26
- def entities_matching(name_re)
27
- raise "Must be a regexp: #{name_re.inspect}" unless
28
- name_re.is_a?(Regexp)
29
- entities.reject {|e| name_re.match(e[:name]).nil? }
30
- end
31
-
32
- def update_entities(*args)
33
- ids, params = unwrap_ids(*args), unwrap_params(*args)
34
- raise "'update_entities' requires at least one entity id " \
35
- ' parameter' if ids.nil? || ids.empty?
36
- validate_params(params) do
37
- validate :query => :name, :as => :string
38
- validate :query => :tags, :as => :array_of_strings
39
- end
40
- perform_patch("/entities/#{escaped_ids(ids)}", nil,
41
- update_entities_ops(params))
42
- end
43
-
44
- private
45
-
46
- def update_entities_ops(params)
47
- ops = params.each_with_object([]) do |(k, v), memo|
48
- case k
49
- when :name
50
- memo << patch_replace('entities', k, v)
51
- when :add_contact
52
- memo << patch_add('entities', 'contacts', v)
53
- when :remove_contact
54
- memo << patch_remove('entities', 'contacts', v)
55
- when :add_tag
56
- memo << patch_add('entities', 'tags', v)
57
- when :remove_tag
58
- memo << patch_remove('entities', 'tags', v)
59
- end
60
- end
61
- raise "'update_entities' did not find any valid update " \
62
- 'fields' if ops.empty?
63
- ops
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,82 +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
- %w(entities checks).each do |data_type|
13
- define_method("create_scheduled_maintenances_#{data_type}") do |*args|
14
- ids, data = unwrap_ids(*args), unwrap_create_data(*args)
15
- if ids.nil? || ids.empty?
16
- raise "'create_scheduled_maintenances_#{data_type}' requires " \
17
- "at least one #{data_type} id parameter"
18
- end
19
- validate_params(data) do
20
- validate :query => :start_time, :as => [:required, :time]
21
- validate :query => :duration, :as => [:required, :integer]
22
- validate :query => :summary, :as => :string
23
- end
24
- perform_post("/scheduled_maintenances/#{data_type}", ids,
25
- :scheduled_maintenances => data)
26
- end
27
-
28
- define_method("create_unscheduled_maintenances_#{data_type}") do |*a|
29
- ids, data = unwrap_ids(*a), unwrap_create_data(*a)
30
- if ids.nil? || ids.empty?
31
- raise "'create_unscheduled_maintenances_#{data_type}' requires " \
32
- "at least one #{data_type} id parameter"
33
- end
34
- validate_params(data) do
35
- validate :query => :duration, :as => [:required, :integer]
36
- validate :query => :summary, :as => :string
37
- end
38
- perform_post("/unscheduled_maintenances/#{data_type}", ids,
39
- :unscheduled_maintenances => data)
40
- end
41
-
42
- define_method("update_unscheduled_maintenances_#{data_type}") do |*a|
43
- ids, params = unwrap_ids(*a), unwrap_params(*a)
44
- if ids.nil? || ids.empty?
45
- raise "'update_unscheduled_maintenances_#{data_type}' requires " \
46
- "at least one #{data_type} id parameter"
47
- end
48
- validate_params(params) do
49
- validate :query => :end_time, :as => :time
50
- end
51
- ops = update_unscheduled_maintenances_ops(data_type, params)
52
- perform_patch("/unscheduled_maintenances/#{data_type}", ids, ops)
53
- end
54
-
55
- define_method("delete_scheduled_maintenances_#{data_type}") do |*args|
56
- ids, params = unwrap_ids(*args), unwrap_params(*args)
57
- if ids.nil? || ids.empty?
58
- raise "'delete_scheduled_maintenances_#{data_type}' requires " \
59
- "at least one #{data_type} id parameter"
60
- end
61
- validate_params(params) do
62
- validate :query => :start_time, :as => [:required, :time]
63
- end
64
- perform_delete("/scheduled_maintenances/#{data_type}", ids, params)
65
- end
66
- end
67
-
68
- private
69
-
70
- def update_unscheduled_maintenances_ops(data_type, params)
71
- ops = params.each_with_object([]) do |(k, v), memo|
72
- next unless :end_time.eql?(k)
73
- memo << patch_replace('unscheduled_maintenances', k, v)
74
- end
75
- raise "'update_unscheduled_maintenances_#{data_type}' did not " \
76
- 'find any valid update fields' if ops.empty?
77
- ops
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,61 +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 Media
12
- def create_contact_media(*args)
13
- ids, data = unwrap_ids(*args), unwrap_create_data(*args)
14
- raise "'create_contact_media' requires at least one contact id " \
15
- 'parameter' if ids.nil? || ids.empty?
16
- validate_params(data) do
17
- validate :query => [:type, :address], :as => [:required, :string]
18
- validate :query => [:interval, :rollup_threshold],
19
- :as => [:required, :integer]
20
- end
21
- perform_post("/contacts/#{escaped_ids(ids)}/media", nil,
22
- :media => data)
23
- end
24
-
25
- def media(*ids)
26
- perform_get('media', '/media', ids)
27
- end
28
-
29
- def update_media(*args)
30
- ids, params = unwrap_ids(*args), unwrap_params(*args)
31
- raise "'update_media' requires at least one media id " \
32
- 'parameter' if ids.nil? || ids.empty?
33
- validate_params(params) do
34
- validate :query => :address, :as => :string
35
- validate :query => [:interval, :rollup_threshold], :as => :integer
36
- end
37
- perform_patch("/media/#{escaped_ids(ids)}", nil,
38
- update_media_ops(params))
39
- end
40
-
41
- def delete_media(*ids)
42
- raise "'delete_media' requires at least one media id " \
43
- 'parameter' if ids.nil? || ids.empty?
44
- perform_delete('/media', ids)
45
- end
46
-
47
- private
48
-
49
- def update_media_ops(params)
50
- ops = params.each_with_object([]) do |(k, v), memo|
51
- next unless [:address, :interval, :rollup_threshold].include?(k)
52
- memo << patch_replace('media', k, v)
53
- end
54
- raise "'update_media' did not find any valid update " \
55
- 'fields' if ops.empty?
56
- ops
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,66 +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 NotificationRules
12
- def create_contact_notification_rules(*args)
13
- ids, data = unwrap_ids(*args), unwrap_create_data(*args)
14
- raise "'create_contact_notification_rules' requires at least one " \
15
- 'contact id parameter' if ids.nil? || ids.empty?
16
- validate_params(data) do
17
- validate :query => STRING_PARAMS, :as => :array_of_strings
18
- validate :query => BOOLEAN_PARAMS, :as => :boolean
19
- end
20
- perform_post("/contacts/#{escaped_ids(ids)}/notification_rules",
21
- nil, :notification_rules => data)
22
- end
23
-
24
- def notification_rules(*ids)
25
- perform_get('notification_rules', '/notification_rules', ids)
26
- end
27
-
28
- def update_notification_rules(*args)
29
- ids, params = unwrap_ids(*args), unwrap_params(*args)
30
- raise "'update_notification_rules' requires at least one " \
31
- 'notification rule id parameter' if ids.nil? || ids.empty?
32
- validate_params(params) do
33
- validate :query => STRING_PARAMS, :as => :array_of_strings
34
- validate :query => BOOLEAN_PARAMS, :as => :boolean
35
- end
36
- perform_patch("/notification_rules/#{escaped_ids(ids)}", nil,
37
- update_notification_rules_ops(params))
38
- end
39
-
40
- def delete_notification_rules(*ids)
41
- raise "'delete_notification_rules' requires at least one " \
42
- 'notification rule id parameter' if ids.nil? || ids.empty?
43
- perform_delete('/notification_rules', ids)
44
- end
45
-
46
- private
47
-
48
- STRING_PARAMS = [:entities, :regex_entities, :tags, :regex_tags,
49
- :unknown_media, :warning_media, :critical_media]
50
- BOOLEAN_PARAMS = [:unknown_blackhole, :warning_blackhole,
51
- :critical_blackhole]
52
- OTHER_PARAMS = [:time_restrictions]
53
-
54
- def update_notification_rules_ops(params)
55
- ops = params.each_with_object([]) do |(k, v), memo|
56
- next unless (STRING_PARAMS + BOOLEAN_PARAMS + OTHER_PARAMS).include?(k)
57
- memo << patch_replace('notification_rules', k, v)
58
- end
59
- raise "'update_notification_rules' did not find any valid update " \
60
- 'fields' if ops.empty?
61
- ops
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,28 +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 Notifications
12
- %w(entities checks).each do |data_type|
13
- define_method("create_test_notifications_#{data_type}") do |*args|
14
- ids, data = unwrap_ids(*args), unwrap_create_data(*args)
15
- raise "'create_test_notifications_#{data_type}' requires at " \
16
- "least one #{data_type} id parameter" if ids.nil? || ids.empty?
17
- raise "No notification data provided" if data.nil?
18
- validate_params(data) do
19
- validate :query => :summary, :as => :string
20
- end
21
- perform_post("/test_notifications/#{data_type}", ids,
22
- :test_notifications => data)
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,59 +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 PagerdutyCredentials
12
- def create_contact_pagerduty_credentials(*args)
13
- ids, data = unwrap_ids(*args), unwrap_create_data(*args)
14
- raise "'create_contact_pagerduty_credentials' requires at least " \
15
- 'one contact id parameter' if ids.nil? || ids.empty?
16
- validate_params(data) do
17
- validate :query => [:service_key], :as => [:required, :string]
18
- end
19
- perform_post("/contacts/#{escaped_ids(ids)}/pagerduty_credentials",
20
- nil, :pagerduty_credentials => data)
21
- end
22
-
23
- def pagerduty_credentials(*ids)
24
- perform_get('pagerduty_credentials', '/pagerduty_credentials', ids)
25
- end
26
-
27
- def update_pagerduty_credentials(*args)
28
- ids, params = unwrap_ids(*args), unwrap_params(*args)
29
- raise "'update_pagerduty_credentials' requires at least one " \
30
- ' pagerduty_credentials id parameter' if ids.nil? || ids.empty?
31
- validate_params(params) do
32
- validate :query => [:service_key, :subdomain,
33
- :token], :as => :string
34
- end
35
- perform_patch("/pagerduty_credentials/#{escaped_ids(ids)}",
36
- nil, update_pagerduty_credentials_ops(params))
37
- end
38
-
39
- def delete_pagerduty_credentials(*ids)
40
- raise "'delete_pagerduty_credentials' requires at least one " \
41
- 'pagerduty_credentials id parameter' if ids.nil? || ids.empty?
42
- perform_delete('/pagerduty_credentials', ids)
43
- end
44
-
45
- private
46
-
47
- def update_pagerduty_credentials_ops(params)
48
- ops = params.each_with_object([]) do |(k, v), memo|
49
- next unless [:service_key, :subdomain, :token].include?(k)
50
- memo << patch_replace('pagerduty_credentials', k, v)
51
- end
52
- raise "'update_pagerduty_credentials' did not find any valid " \
53
- 'update fields' if ops.empty?
54
- ops
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,33 +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 Reports
12
- %w(entities checks).each do |data_type|
13
- define_method("status_report_#{data_type}") do |*ids|
14
- perform_get('status_reports', "/status_report/#{data_type}", ids)
15
- end
16
-
17
- %w(scheduled_maintenance unscheduled_maintenance
18
- downtime outage).each do |report_type|
19
- define_method("#{report_type}_report_#{data_type}") do |*args|
20
- ids, params = unwrap_ids(*args), unwrap_params(*args)
21
- validate_params(params) do
22
- validate :query => [:start_time, :end_time], :as => :time
23
- end
24
- perform_get("#{report_type}_reports",
25
- "/#{report_type}_report/#{data_type}",
26
- ids, params)
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end