rackspace-monitoring 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -0,0 +1,37 @@
1
+ require 'fog/core/model'
2
+ require 'rackspace-monitoring/monitoring/models/base'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class Rackspace
7
+ class AgentToken < Fog::Monitoring::Rackspace::Base
8
+
9
+ identity :id
10
+
11
+ attribute :label
12
+ attribute :token
13
+
14
+ def prep
15
+ options = {
16
+ 'label' => label,
17
+ 'token' => token
18
+ }
19
+ options = options.reject {|key, value| value.nil?}
20
+ options
21
+ end
22
+
23
+ def save
24
+ options = prep
25
+ if identity then
26
+ data = connection.update_agent_token(identity, options)
27
+ else
28
+ data = connection.create_agent_token(options)
29
+ end
30
+ true
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ require 'fog/core/collection'
2
+ require 'rackspace-monitoring/monitoring/models/agent_token'
3
+
4
+ module Fog
5
+ module Monitoring
6
+ class Rackspace
7
+ class AgentTokens < Fog::Collection
8
+
9
+ model Fog::Monitoring::Rackspace::AgentToken
10
+
11
+ def all
12
+ data = connection.list_agent_tokens.body['values']
13
+ load(data)
14
+ end
15
+
16
+ def get(id)
17
+ data = connection.get_agent_token(id).body
18
+ new(data)
19
+ rescue Fog::Monitoring::Rackspace::NotFound
20
+ nil
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ 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 :criteria
@@ -15,18 +16,26 @@ module Fog
15
16
  attribute :check_id
16
17
  attribute :notification_plan_id
17
18
 
18
- def save
19
- raise Fog::Errors::Error.new('Update not implemented yet.') if identity
20
- requires :notification_plan_id
21
- requires :entity
19
+ def prep
22
20
  options = {
23
- 'label' => label,
24
- 'criteria' => criteria,
25
- 'check_type' => check_type,
26
- 'check_id' => check_id,
21
+ 'label' => label,
22
+ 'criteria' => criteria,
23
+ 'notification_plan_id' => notification_plan_id,
27
24
  }
28
25
  options = options.reject {|key, value| value.nil?}
29
- data = connection.create_alarm(entity.identity, notification_plan_id, options)
26
+ options
27
+ end
28
+
29
+ def save
30
+ requires :notification_plan_id
31
+ options = prep
32
+ if identity then
33
+ data = connection.update_alarm(get_entity_id, identity, options)
34
+ else
35
+ options['check_type'] = check_type if check_type
36
+ options['check_id'] = check_id if check_id
37
+ data = connection.create_alarm(get_entity_id, options)
38
+ end
30
39
  true
31
40
  end
32
41
 
@@ -25,6 +25,17 @@ module Fog
25
25
  remain.empty?
26
26
  end
27
27
 
28
+ def get_entity_id
29
+ requires :entity
30
+ begin
31
+ requires :entity
32
+ entity_id = entity.identity
33
+ rescue
34
+ requires :entity_id
35
+ end
36
+ entity_id
37
+ end
38
+
28
39
  end
29
40
  end
30
41
  end
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def create_agent_token(options = {})
7
+ data = options.dup
8
+ request(
9
+ :body => MultiJson.encode(data),
10
+ :expects => [201],
11
+ :method => 'POST',
12
+ :path => 'agent_tokens'
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -3,22 +3,10 @@ module Fog
3
3
  class Rackspace
4
4
  class Real
5
5
 
6
- # attribute :label
7
- # attribute :criteria
8
- # attribute :check_type
9
- # attribute :check_id
10
- # attribute :notification_plan_id
11
-
12
-
13
- def create_alarm(entity_id, notification_plan_id, options = {})
14
- data = {}
15
- data['label'] = options['label'] if options['label']
16
- data['criteria'] = options['criteria'] if options['criteria']
17
- data['check_type'] = options['check_type'] if options['check_type']
18
- data['check_id'] = options['check_id'] if options['check_id']
19
- data['notification_plan_id'] = notification_plan_id
6
+ def create_alarm(entity_id, options = {})
7
+ data = options.dup
20
8
  request(
21
- :body => MultiJson.encode(options),
9
+ :body => MultiJson.encode(data),
22
10
  :expects => [201],
23
11
  :method => 'POST',
24
12
  :path => "entities/#{entity_id}/alarms"
@@ -4,6 +4,7 @@ module Fog
4
4
  class Real
5
5
 
6
6
  def evaluate_alarm_example(id, options = {})
7
+ options ||= {}
7
8
  data = {:values => options.dup}
8
9
  request(
9
10
  :body => MultiJson.encode(data),
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Monitoring
3
+ class Rackspace
4
+ class Real
5
+
6
+ def get_agent_token(id)
7
+ request(
8
+ :expects => [200, 203],
9
+ :method => 'GET',
10
+ :path => "agent_tokens/#{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_agent_tokens
7
+ request(
8
+ :expects => [200, 203],
9
+ :method => 'GET',
10
+ :path => "agent_tokens"
11
+ )
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -21,19 +21,24 @@ module Fog
21
21
  collection :alarms
22
22
  model :alarm_example
23
23
  collection :alarm_examples
24
+ model :agent_token
25
+ collection :agent_tokens
24
26
 
25
27
  request_path 'rackspace-monitoring/monitoring/requests'
28
+ request :list_agent_tokens
26
29
  request :list_alarms
27
30
  request :list_alarm_examples
28
31
  request :list_checks
29
32
  request :list_entities
30
33
  request :list_overview
31
34
 
35
+ request :get_agent_token
32
36
  request :get_alarm
33
37
  request :get_alarm_example
34
38
  request :get_check
35
39
  request :get_entity
36
40
 
41
+ request :create_agent_token
37
42
  request :create_alarm
38
43
  request :create_check
39
44
  request :create_entity
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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-10 00:00:00.000000000 Z
12
+ date: 2012-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -106,6 +106,8 @@ files:
106
106
  - Rakefile
107
107
  - VERSION
108
108
  - lib/rackspace-monitoring.rb
109
+ - lib/rackspace-monitoring/monitoring/models/agent_token.rb
110
+ - lib/rackspace-monitoring/monitoring/models/agent_tokens.rb
109
111
  - lib/rackspace-monitoring/monitoring/models/alarm.rb
110
112
  - lib/rackspace-monitoring/monitoring/models/alarm_example.rb
111
113
  - lib/rackspace-monitoring/monitoring/models/alarm_examples.rb
@@ -115,16 +117,19 @@ files:
115
117
  - lib/rackspace-monitoring/monitoring/models/checks.rb
116
118
  - lib/rackspace-monitoring/monitoring/models/entities.rb
117
119
  - lib/rackspace-monitoring/monitoring/models/entity.rb
120
+ - lib/rackspace-monitoring/monitoring/requests/create_agent_token.rb
118
121
  - lib/rackspace-monitoring/monitoring/requests/create_alarm.rb
119
122
  - lib/rackspace-monitoring/monitoring/requests/create_check.rb
120
123
  - lib/rackspace-monitoring/monitoring/requests/create_entity.rb
121
124
  - lib/rackspace-monitoring/monitoring/requests/delete_check.rb
122
125
  - lib/rackspace-monitoring/monitoring/requests/delete_entity.rb
123
126
  - lib/rackspace-monitoring/monitoring/requests/evaluate_alarm_example.rb
127
+ - lib/rackspace-monitoring/monitoring/requests/get_agent_token.rb
124
128
  - lib/rackspace-monitoring/monitoring/requests/get_alarm.rb
125
129
  - lib/rackspace-monitoring/monitoring/requests/get_alarm_example.rb
126
130
  - lib/rackspace-monitoring/monitoring/requests/get_check.rb
127
131
  - lib/rackspace-monitoring/monitoring/requests/get_entity.rb
132
+ - lib/rackspace-monitoring/monitoring/requests/list_agent_tokens.rb
128
133
  - lib/rackspace-monitoring/monitoring/requests/list_alarm_examples.rb
129
134
  - lib/rackspace-monitoring/monitoring/requests/list_alarms.rb
130
135
  - lib/rackspace-monitoring/monitoring/requests/list_checks.rb
@@ -149,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
154
  version: '0'
150
155
  segments:
151
156
  - 0
152
- hash: -4565954568018538761
157
+ hash: -2125588216297176347
153
158
  required_rubygems_version: !ruby/object:Gem::Requirement
154
159
  none: false
155
160
  requirements: