sysdig 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 0584253cc25878e18a5933ce1b8462474c5816dc
4
- data.tar.gz: a6860512f09060d382985131bb1cd8553cbb5ba6
3
+ metadata.gz: 976ab5bf9c0d56e508aabe8cce280db889904138
4
+ data.tar.gz: 951c22606a8f96b4d4f74d5d3590a15c038318dc
5
5
  SHA512:
6
- metadata.gz: 9cac5de1d482b9d7296e042a128286b706ed6fd4f977b269c68111d8738b2dd083fc72ef704248579aed8c3fe10b316a51e64e247d852ed04a36628c6fdceeda
7
- data.tar.gz: 978b39ec9831166510a94774ce82d3aa07004eef3e684fa554d5a2aadbfbd7425543f33e13aa498699f21fc9d0107944bb49770c8708ebb672093a2262f57465
6
+ metadata.gz: 41ae7f0e86f9717310d8b327531a594f5afc1ce593ee1171ab98f9f5729f8509681a44a7691bc25e3c7671478adfe9b0e63b81d101da75db398663d4e57b2393
7
+ data.tar.gz: 5d15fc64b7900fba201241aa6a43bba690102e5f129b89bf37cb9b91e71419f97a588a20b0f30fe55805f2248ed77658ab8281968a2b7edbffaefe0faa862eef
@@ -1,31 +1,38 @@
1
- class Sysdig::UserNotifications < Sysdig::Collection
1
+ class Sysdig::UserNotifications < Sysdig::Singular
2
2
 
3
- model Sysdig::UserNotification
3
+ attribute :sns_enabled, type: :boolean, squash: ["sns", "enabled"]
4
+ attribute :sns_topics, type: :array, squash: ["sns", "topics"]
4
5
 
5
- def all(options={})
6
- load(service.get_user_notifications.body.fetch("userNotification")).tap { |_| self.records.compact! }
7
- end
8
-
9
- def get(type)
10
- all.find { |r| r.identity == type.to_s }
11
- end
6
+ attribute :email_enabled, type: :boolean, squash: ["email", "enabled"]
7
+ attribute :email_recipients, type: :array, squash: ["email", "recipients"]
12
8
 
13
- def new(args)
14
- type, attributes = *args
9
+ attribute :pager_duty_enabled, type: :boolean, squash: ["pagerDuty", "enabled"]
10
+ attribute :pager_duty_integrated, type: :boolean, squash: ["pagerDuty", "integrated"]
11
+ attribute :pager_duty_bind_resolution, type: :boolean, squash: ["pagerDuty", "resolveOnOk"]
12
+ attribute :pager_duty_connect_url, squash: ["pagerDuty", "connectUrl"]
15
13
 
16
- unless attributes.is_a?(::Hash)
17
- raise(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
18
- end
14
+ def fetch_attributes(options={})
15
+ service.get_user_notifications.body.fetch("userNotification")
16
+ end
19
17
 
20
- concrete_model = model.types[type]
18
+ def save
19
+ data = service.update_user_notifications(
20
+ "sns" => {
21
+ "enabled" => self.sns_enabled,
22
+ "topics" => self.sns_topics,
23
+ },
24
+ "email" => {
25
+ "enabled" => self.email_enabled,
26
+ "recipients" => self.email_recipients,
27
+ },
28
+ "pagerDuty" => {
29
+ "enabled" => self.pager_duty_enabled,
30
+ "integrated" => self.pager_duty_integrated,
31
+ "resolveOnOk" => self.pager_duty_bind_resolution,
32
+ "connectUrl" => self.pager_duty_connect_url,
33
+ },
34
+ ).body.fetch("userNotification")
21
35
 
22
- if concrete_model
23
- concrete_model.new(
24
- {
25
- :collection => self,
26
- :service => service,
27
- }.merge(attributes)
28
- )
29
- end
36
+ merge_attributes(data)
30
37
  end
31
38
  end
@@ -1,3 +1,3 @@
1
1
  class Sysdig
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/sysdig.rb CHANGED
@@ -40,8 +40,4 @@ require 'sysdig/alert_notifications'
40
40
 
41
41
  require 'sysdig/get_user_notifications'
42
42
  require 'sysdig/update_user_notifications'
43
- require 'sysdig/user_notification'
44
43
  require 'sysdig/user_notifications'
45
- require 'sysdig/sns_notification'
46
- require 'sysdig/email_notification'
47
- require 'sysdig/pager_duty_notification'
data/sysdig.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec"
33
33
 
34
- spec.add_dependency "cistern", "~> 2.2"
34
+ spec.add_dependency "cistern", "~> 2.2", "> 2.2.1"
35
35
  spec.add_dependency "ey-logger", "~> 0.0"
36
36
  spec.add_dependency "faraday", "~> 0.9"
37
37
  spec.add_dependency "faraday_middleware", "~> 0.9"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sysdig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-22 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,6 +59,9 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.2'
62
+ - - ">"
63
+ - !ruby/object:Gem::Version
64
+ version: 2.2.1
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,6 +69,9 @@ dependencies:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
71
  version: '2.2'
72
+ - - ">"
73
+ - !ruby/object:Gem::Version
74
+ version: 2.2.1
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: ey-logger
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +156,6 @@ files:
150
156
  - lib/sysdig/create_alert.rb
151
157
  - lib/sysdig/create_user.rb
152
158
  - lib/sysdig/destroy_alert.rb
153
- - lib/sysdig/email_notification.rb
154
159
  - lib/sysdig/get_alert.rb
155
160
  - lib/sysdig/get_alert_notification.rb
156
161
  - lib/sysdig/get_alert_notifications.rb
@@ -159,13 +164,10 @@ files:
159
164
  - lib/sysdig/login.rb
160
165
  - lib/sysdig/mock.rb
161
166
  - lib/sysdig/model.rb
162
- - lib/sysdig/pager_duty_notification.rb
163
167
  - lib/sysdig/real.rb
164
168
  - lib/sysdig/response.rb
165
- - lib/sysdig/sns_notification.rb
166
169
  - lib/sysdig/update_alert.rb
167
170
  - lib/sysdig/update_user_notifications.rb
168
- - lib/sysdig/user_notification.rb
169
171
  - lib/sysdig/user_notifications.rb
170
172
  - lib/sysdig/version.rb
171
173
  - sysdig.gemspec
@@ -1,15 +0,0 @@
1
- class Sysdig::EmailNotification < Sysdig::UserNotification
2
-
3
- type :email
4
-
5
- attribute :recipients, type: :array
6
-
7
- def save
8
- notification = service.update_user_notifications("email" => {
9
- "enabled" => self.enabled,
10
- "recipients" => self.receipents,
11
- }).body.fetch("userNotification")
12
-
13
- merge_attributes(notification.fetch("email"))
14
- end
15
- end
@@ -1,20 +0,0 @@
1
- class Sysdig::PagerDutyNotification < Sysdig::UserNotification
2
-
3
- type :pagerDuty
4
-
5
- attribute :enabled, type: :boolean
6
- attribute :integrated, type: :boolean
7
- attribute :bind_resolution, type: :boolean, alias: "resolveOnOk"
8
- attribute :connect_url, alias: "connectUrl"
9
-
10
- def save
11
- notification = service.update_user_notifications("pagerDuty" => {
12
- "enabled" => self.enabled,
13
- "integrated" => self.integrated,
14
- "resolveOnOk" => self.bind_resolution,
15
- "connectUrl" => self.connect_url,
16
- }).body.fetch("userNotification")
17
-
18
- merge_attributes(notification.fetch("pagerDuty"))
19
- end
20
- end
@@ -1,15 +0,0 @@
1
- class Sysdig::SnsNotification < Sysdig::UserNotification
2
-
3
- type :sns
4
-
5
- attribute :topics, type: :array
6
-
7
- def save
8
- notification = service.update_user_notifications(self.identity => {
9
- "enabled" => self.enabled,
10
- "topics" => self.topics,
11
- }).body.fetch("userNotification")
12
-
13
- merge_attributes(notification.fetch(self.identity))
14
- end
15
- end
@@ -1,31 +0,0 @@
1
- class Sysdig::UserNotification < Sysdig::Model
2
-
3
- def self.types
4
- @_types ||= Hash.new
5
- end
6
-
7
- def self.type(k=nil)
8
- if k.nil?
9
- @key
10
- else
11
- key = k.to_s
12
- Sysdig::UserNotification.types[key] = self
13
- @key = key
14
- end
15
- end
16
-
17
- def self.inherited(klass)
18
- klass.identity :category
19
-
20
- super
21
- end
22
-
23
- attribute :enabled, type: :boolean
24
-
25
- def initialize(attributes={})
26
- self.identity = self.class.type
27
-
28
- super
29
- end
30
-
31
- end