Class: Fog::Rackspace::Monitoring::Real

Inherits:
Service
  • Object
show all
Defined in:
lib/fog/rackspace/monitoring.rb,
lib/fog/rackspace/requests/monitoring/get_alarm.rb,
lib/fog/rackspace/requests/monitoring/get_check.rb,
lib/fog/rackspace/requests/monitoring/get_entity.rb,
lib/fog/rackspace/requests/monitoring/list_alarms.rb,
lib/fog/rackspace/requests/monitoring/list_checks.rb,
lib/fog/rackspace/requests/monitoring/create_alarm.rb,
lib/fog/rackspace/requests/monitoring/create_check.rb,
lib/fog/rackspace/requests/monitoring/delete_alarm.rb,
lib/fog/rackspace/requests/monitoring/delete_check.rb,
lib/fog/rackspace/requests/monitoring/list_metrics.rb,
lib/fog/rackspace/requests/monitoring/update_alarm.rb,
lib/fog/rackspace/requests/monitoring/update_check.rb,
lib/fog/rackspace/requests/monitoring/create_entity.rb,
lib/fog/rackspace/requests/monitoring/delete_entity.rb,
lib/fog/rackspace/requests/monitoring/list_entities.rb,
lib/fog/rackspace/requests/monitoring/list_overview.rb,
lib/fog/rackspace/requests/monitoring/update_entity.rb,
lib/fog/rackspace/requests/monitoring/get_agent_token.rb,
lib/fog/rackspace/requests/monitoring/list_check_types.rb,
lib/fog/rackspace/requests/monitoring/list_data_points.rb,
lib/fog/rackspace/requests/monitoring/get_alarm_example.rb,
lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb,
lib/fog/rackspace/requests/monitoring/create_agent_token.rb,
lib/fog/rackspace/requests/monitoring/delete_agent_token.rb,
lib/fog/rackspace/requests/monitoring/list_alarm_examples.rb,
lib/fog/rackspace/requests/monitoring/evaluate_alarm_example.rb,
lib/fog/rackspace/requests/monitoring/list_notification_plans.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fog/rackspace/monitoring.rb', line 98

def initialize(options={})
  @rackspace_api_key = options[:rackspace_api_key]
  @rackspace_username = options[:rackspace_username]
  @rackspace_auth_url = options[:rackspace_auth_url]
  @connection_options = options[:connection_options] || {}
  @rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_monitoring_url])

  authenticate

  @persistent = options[:persistent] || false
  @connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end

Instance Method Details

#create_agent_token(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/rackspace/requests/monitoring/create_agent_token.rb', line 6

def create_agent_token(options = {})
  data = options.dup
  request(
    :body     => JSON.encode(data),
    :expects  => [201],
    :method   => 'POST',
    :path     => 'agent_tokens'
  )
end

#create_alarm(entity_id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/rackspace/requests/monitoring/create_alarm.rb', line 6

def create_alarm(entity_id, options = {})
  data = options.dup
  request(
    :body     => JSON.encode(data),
    :expects  => [201],
    :method   => 'POST',
    :path     => "entities/#{entity_id}/alarms"
  )
end

#create_check(entity_id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/rackspace/requests/monitoring/create_check.rb', line 6

def create_check(entity_id, options = {})
  data = options.dup
  request(
    :body     => JSON.encode(data),
    :expects  => [201],
    :method   => 'POST',
    :path     => "entities/#{entity_id}/checks"
  )
end

#create_entity(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/rackspace/requests/monitoring/create_entity.rb', line 6

def create_entity(options = {})
  data = options.dup
  request(
    :body     => JSON.encode(data),
    :expects  => [201],
    :method   => 'POST',
    :path     => 'entities'
  )
end

#delete_agent_token(token_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/delete_agent_token.rb', line 6

def delete_agent_token(token_id)
  request(
    :expects  => [204],
    :method   => 'DELETE',
    :path     => "agent_tokens/#{token_id}"
  )
end

#delete_alarm(entity_id, alarm_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/delete_alarm.rb', line 6

def delete_alarm(entity_id, alarm_id)
  request(
    :expects  => [204],
    :method   => 'DELETE',
    :path     => "entities/#{entity_id}/alarms/#{alarm_id}"
  )
end

#delete_check(entity_id, check_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/delete_check.rb', line 6

def delete_check(entity_id, check_id)
  request(
    :expects  => [204],
    :method   => 'DELETE',
    :path     => "entities/#{entity_id}/checks/#{check_id}"
  )
end

#delete_entity(entity_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/delete_entity.rb', line 6

def delete_entity(entity_id)
  request(
    :expects  => [204],
    :method   => 'DELETE',
    :path     => "entities/#{entity_id}"
  )
end

#endpoint_uri(service_endpoint_url = nil) ⇒ Object



115
116
117
# File 'lib/fog/rackspace/monitoring.rb', line 115

def endpoint_uri(service_endpoint_url=nil)
  @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_monitoring_url)
end

#evaluate_alarm_example(id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/rackspace/requests/monitoring/evaluate_alarm_example.rb', line 6

def evaluate_alarm_example(id, options = {})
  options ||= {}
  data = {:values => options.dup}
  request(
    :body     => JSON.encode(data),
    :expects  => [200],
    :method   => 'POST',
    :path     => "alarm_examples/#{id}"
  )
end

#get_agent_token(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/get_agent_token.rb', line 6

def get_agent_token(id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "agent_tokens/#{id}"
  )
end

#get_alarm(entity_id, alarm_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/get_alarm.rb', line 6

def get_alarm(entity_id, alarm_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}/alarms/#{alarm_id}"
  )
end

#get_alarm_example(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/get_alarm_example.rb', line 6

def get_alarm_example(id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "alarm_examples/#{id}"
  )
end

#get_check(entity_id, check_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/get_check.rb', line 6

def get_check(entity_id, check_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}/checks/#{check_id}"
  )
end

#get_entity(entity_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/get_entity.rb', line 6

def get_entity(entity_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}"
  )
end

#list_agent_tokens(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb', line 6

def list_agent_tokens(options={})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'agent_tokens',
    :query    => options
  )
end

#list_alarm_examplesObject



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/list_alarm_examples.rb', line 6

def list_alarm_examples
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'alarm_examples'
  )
end

#list_alarms(entity_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/list_alarms.rb', line 6

def list_alarms(entity_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}/alarms"
  )
end

#list_check_typesObject



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/list_check_types.rb', line 6

def list_check_types
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "check_types"
  )
end

#list_checks(entity_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/list_checks.rb', line 6

def list_checks(entity_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}/checks"
  )
end

#list_data_points(entity_id, check_id, metric_name, options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/list_data_points.rb', line 6

def list_data_points(entity_id, check_id, metric_name, options)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}/checks/#{check_id}/metrics/#{metric_name}/plot",
    :query    => options
  )
end

#list_entities(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/list_entities.rb', line 6

def list_entities(options={})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'entities',
    :query    => options
  )
end

#list_metrics(entity_id, check_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/list_metrics.rb', line 6

def list_metrics(entity_id, check_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "entities/#{entity_id}/checks/#{check_id}/metrics"
  )
end

#list_notification_plansObject



6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/monitoring/list_notification_plans.rb', line 6

def list_notification_plans
  request(
    :expects  => [200],
    :method   => 'GET',
    :path     => "notification_plans"
  )
end

#list_overview(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/list_overview.rb', line 6

def list_overview(options={})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "views/overview",
    :query    => options
  )
end

#regionObject



94
95
96
# File 'lib/fog/rackspace/monitoring.rb', line 94

def region
  @rackspace_region
end

#reloadObject



111
112
113
# File 'lib/fog/rackspace/monitoring.rb', line 111

def reload
  @connection.reset
end

#service_nameObject



90
91
92
# File 'lib/fog/rackspace/monitoring.rb', line 90

def service_name
  :cloudMonitoring
end

#update_alarm(entity_id, id, options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/update_alarm.rb', line 6

def update_alarm(entity_id, id, options)
  request(
    :body     => JSON.encode(options),
    :expects  => [204],
    :method   => 'PUT',
    :path     => "entities/#{entity_id}/alarms/#{id}"
  )
end

#update_check(entity_id, id, options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/update_check.rb', line 6

def update_check(entity_id, id, options)
  request(
    :body     => JSON.encode(options),
    :expects  => [204],
    :method   => 'PUT',
    :path     => "entities/#{entity_id}/checks/#{id}"
  )
end

#update_entity(id, options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/rackspace/requests/monitoring/update_entity.rb', line 6

def update_entity(id, options)
  request(
    :body     => JSON.encode(options),
    :expects  => [204],
    :method   => 'PUT',
    :path     => "entities/#{id}"
  )
end