rackspace-monitoring 0.1.2 → 0.1.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -19,21 +19,33 @@ module Fog
19
19
  collection :checks
20
20
  model :alarm
21
21
  collection :alarms
22
+ model :alarm_example
23
+ collection :alarm_examples
22
24
 
23
25
  request_path 'rackspace-monitoring/monitoring/requests'
24
- request :list_entities
25
- request :list_checks
26
26
  request :list_alarms
27
+ request :list_alarm_examples
28
+ request :list_checks
29
+ request :list_entities
27
30
  request :list_overview
28
- request :get_entity
29
- request :get_check
31
+
30
32
  request :get_alarm
31
- request :create_entity
32
- request :create_check
33
+ request :get_alarm_example
34
+ request :get_check
35
+ request :get_entity
36
+
33
37
  request :create_alarm
38
+ request :create_check
39
+ request :create_entity
40
+
41
+ request :update_check
34
42
  request :update_entity
43
+
44
+ request :delete_check
35
45
  request :delete_entity
36
46
 
47
+ request :evaluate_alarm_example
48
+
37
49
 
38
50
  class Mock
39
51
 
@@ -0,0 +1,26 @@
1
+ require 'fog/core/model'
2
+ require 'rackspace-monitoring/monitoring/models/base'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class Rackspace
7
+ class AlarmExample < Fog::Monitoring::Rackspace::Base
8
+
9
+ identity :id
10
+
11
+ attribute :label
12
+ attribute :description
13
+ attribute :check_type
14
+ attribute :criteria
15
+ attribute :fields
16
+
17
+
18
+ attribute :bound_criteria
19
+
20
+ def bound?
21
+ !bound_criteria.nil?
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ require 'fog/core/collection'
2
+ require 'rackspace-monitoring/monitoring/models/alarm_example'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class Rackspace
7
+ class AlarmExamples < Fog::Collection
8
+
9
+ model Fog::Monitoring::Rackspace::AlarmExample
10
+
11
+ def all
12
+ data = connection.list_alarm_examples.body['values']
13
+ load(data)
14
+ end
15
+
16
+ def get(alarm_example_id)
17
+ data = connection.get_alarm_example(alarm_example_id).body
18
+ new(data)
19
+ rescue Fog::Monitoring::Rackspace::NotFound
20
+ nil
21
+ end
22
+
23
+ def evaluate(alarm_example_id, options={})
24
+ data = connection.evaluate_alarm_example(alarm_example_id, options).body
25
+ new(data)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -8,6 +8,7 @@ module Fog
8
8
  attribute :created_at
9
9
  attribute :updated_at
10
10
 
11
+ # Back to drawing board on this one I think
11
12
  def hash
12
13
  attrs = attributes.dup
13
14
  attrs.delete_if {|key, value| [:created_at, :updated_at, :id].include?(key)}
@@ -16,6 +17,14 @@ module Fog
16
17
  values = attrs.values.map{|sym| sym.to_s}.sort.join ''
17
18
  Digest::MD5.hexdigest(keys + values)
18
19
  end
20
+
21
+ def compare?(b)
22
+ a_o = prep
23
+ b_o = b.prep
24
+ remain = a_o.reject {|key, value| b_o[key] === value}
25
+ remain.empty?
26
+ end
27
+
19
28
  end
20
29
  end
21
30
  end
@@ -8,6 +8,7 @@ module Fog
8
8
 
9
9
  identity :id
10
10
  attribute :entity
11
+ attribute :entity_id
11
12
 
12
13
  attribute :label
13
14
  attribute :metadata
@@ -21,10 +22,7 @@ module Fog
21
22
  attribute :disabled
22
23
  attribute :monitoring_zones_poll
23
24
 
24
- def save
25
- raise Fog::Errors::Error.new('Update not implemented yet.') if identity
26
- requires :type
27
- requires :entity
25
+ def prep
28
26
  options = {
29
27
  'label' => label,
30
28
  'metadata' => metadata,
@@ -38,7 +36,24 @@ module Fog
38
36
  'disabled'=> disabled
39
37
  }
40
38
  options = options.reject {|key, value| value.nil?}
41
- data = connection.create_check(entity.identity, type, options)
39
+ options
40
+ end
41
+
42
+ def save
43
+ begin
44
+ requires :entity
45
+ entity_id = entity.identity
46
+ rescue
47
+ requires :entity_id
48
+ end
49
+ options = prep
50
+ if identity then
51
+ data = connection.update_check(entity_id, identity, options)
52
+ else
53
+ requires :type
54
+ options['type'] = type
55
+ data = connection.create_check(entity_id, options)
56
+ end
42
57
  true
43
58
  end
44
59
 
@@ -59,12 +59,6 @@ module Fog
59
59
  connection.delete_entity(id)
60
60
  end
61
61
 
62
- def compare?(b)
63
- a_o = prep
64
- b_o = b.prep
65
- remain = a_o.reject {|key, value| b_o[key] === value}
66
- remain.empty?
67
- end
68
62
  end
69
63
  end
70
64
  end
@@ -3,55 +3,8 @@ module Fog
3
3
  class Rackspace
4
4
  class Real
5
5
 
6
-
7
- def process_options(options)
8
- data = {}
9
- if options['label'] then
10
- data['label'] = options['label']
11
- end
12
- if options['metadata'] then
13
- data['metadata'] = options['metadata']
14
- end
15
- if options['target_alias'] then
16
- data['target_alias'] = options['target_alias']
17
- end
18
- if options['target_resolver'] then
19
- data['target_resolver'] = options['target_resolver']
20
- end
21
- if options['target_hostname'] then
22
- data['target_hostname'] = options['target_hostname']
23
- end
24
- if options['period'] then
25
- data['period'] = options['period']
26
- end
27
- if options['timeout'] then
28
- data['timeout'] = options['timeout']
29
- end
30
- if options['details'] then
31
- data['details'] = options['details']
32
- end
33
- if options['monitoring_zones_poll'] then
34
- data['monitoring_zones_poll'] = options['monitoring_zones_poll']
35
- end
36
- if options['disabled'] then
37
- data['disabled'] = options['disabled']
38
- end
39
- data
40
- end
41
-
42
- def update_check(id, entity_id, options = {})
43
- data = process_options options
44
- request(
45
- :body => MultiJson.encode(data),
46
- :expects => [201],
47
- :method => 'PUT',
48
- :path => "entities/#{entity_id}/checks/#{id}"
49
- )
50
- end
51
-
52
- def create_check(entity_id, type, options = {})
53
- data = process_options options
54
- data['type'] = type
6
+ def create_check(entity_id, options = {})
7
+ data = options.dup
55
8
  request(
56
9
  :body => MultiJson.encode(data),
57
10
  :expects => [201],
@@ -0,0 +1,17 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def delete_check(entity_id, check_id)
7
+ request(
8
+ :expects => [204],
9
+ :method => 'DELETE',
10
+ :path => "entities/#{entity_id}/checks/#{check_id}"
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def evaluate_alarm_example(id, options = {})
7
+ data = {:values => options.dup}
8
+ request(
9
+ :body => MultiJson.encode(data),
10
+ :expects => [200],
11
+ :method => 'POST',
12
+ :path => "alarm_examples/#{id}"
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def get_alarm_example(id)
7
+ request(
8
+ :expects => [200, 203],
9
+ :method => 'GET',
10
+ :path => "alarm_examples/#{id}"
11
+ )
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def list_alarm_examples
7
+ request(
8
+ :expects => [200, 203],
9
+ :method => 'GET',
10
+ :path => 'alarm_examples'
11
+ )
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def update_check(entity_id, id, options)
7
+ request(
8
+ :body => MultiJson.encode(options),
9
+ :expects => [204],
10
+ :method => 'PUT',
11
+ :path => "entities/#{entity_id}/checks/#{id}"
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -3,12 +3,12 @@ module Fog
3
3
  class Rackspace
4
4
  class Real
5
5
 
6
- def update_entity(entity_id, options)
6
+ def update_entity(id, options)
7
7
  request(
8
8
  :body => MultiJson.encode(options),
9
9
  :expects => [204],
10
10
  :method => 'PUT',
11
- :path => "entities/#{entity_id}"
11
+ :path => "entities/#{id}"
12
12
  )
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackspace-monitoring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,6 +107,8 @@ files:
107
107
  - VERSION
108
108
  - lib/rackspace-monitoring.rb
109
109
  - lib/rackspace-monitoring/monitoring/models/alarm.rb
110
+ - lib/rackspace-monitoring/monitoring/models/alarm_example.rb
111
+ - lib/rackspace-monitoring/monitoring/models/alarm_examples.rb
110
112
  - lib/rackspace-monitoring/monitoring/models/alarms.rb
111
113
  - lib/rackspace-monitoring/monitoring/models/base.rb
112
114
  - lib/rackspace-monitoring/monitoring/models/check.rb
@@ -116,14 +118,19 @@ files:
116
118
  - lib/rackspace-monitoring/monitoring/requests/create_alarm.rb
117
119
  - lib/rackspace-monitoring/monitoring/requests/create_check.rb
118
120
  - lib/rackspace-monitoring/monitoring/requests/create_entity.rb
121
+ - lib/rackspace-monitoring/monitoring/requests/delete_check.rb
119
122
  - lib/rackspace-monitoring/monitoring/requests/delete_entity.rb
123
+ - lib/rackspace-monitoring/monitoring/requests/evaluate_alarm_example.rb
120
124
  - lib/rackspace-monitoring/monitoring/requests/get_alarm.rb
125
+ - lib/rackspace-monitoring/monitoring/requests/get_alarm_example.rb
121
126
  - lib/rackspace-monitoring/monitoring/requests/get_check.rb
122
127
  - lib/rackspace-monitoring/monitoring/requests/get_entity.rb
128
+ - lib/rackspace-monitoring/monitoring/requests/list_alarm_examples.rb
123
129
  - lib/rackspace-monitoring/monitoring/requests/list_alarms.rb
124
130
  - lib/rackspace-monitoring/monitoring/requests/list_checks.rb
125
131
  - lib/rackspace-monitoring/monitoring/requests/list_entities.rb
126
132
  - lib/rackspace-monitoring/monitoring/requests/list_overview.rb
133
+ - lib/rackspace-monitoring/monitoring/requests/update_check.rb
127
134
  - lib/rackspace-monitoring/monitoring/requests/update_entity.rb
128
135
  - test/helper.rb
129
136
  - test/test_rackspace-monitoring.rb
@@ -142,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
149
  version: '0'
143
150
  segments:
144
151
  - 0
145
- hash: 1039074049877710307
152
+ hash: -4565954568018538761
146
153
  required_rubygems_version: !ruby/object:Gem::Requirement
147
154
  none: false
148
155
  requirements: