class Fog::Joyent::Analytics::Mock

Public Class Methods

data() click to toggle source
# File lib/fog/joyent/analytics.rb, line 50
def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] =case key
               when :instrumentation
                 { 'module' => "cpu",
                   'stat' => "usage",
                   'predicate' => {},
                   'decomposition' => ["zonename"],
                   'value-dimension' => 2,
                   'value-arity' => "discrete-decomposition",
                   'enabled' => true,
                   'retention-time' => 86400,
                   'idle-max' => 86400,
                   'transformations' => [],
                   'nsources' => 3,
                   'granularity' => 30,
                   'persist-data' => false,
                   'crtime' => 1388690982000,
                   'value-scope' => "point",
                   'id' => "63",
                   'uris' =>
                       [{ "uri" => "/#{@joyent_username}/analytics/instrumentations/63/value/raw",
                          "name" => "value_raw" }] }
               when :values
                 {
                     'value' => { 'zoneid' => 0 },
                     'transformations' => {},
                     'start_time' => Time.now.utc - 600,
                     'duration' => 30,
                     'end_time' => Time.now.utc - 570,
                     'nsources' => 1,
                     'minreporting' => 1,
                     'requested_start_time' => Time.now.utc - 600,
                     'requested_duration' => 30,
                     'requested_end_time' => Time.now.utc - 570
                 }
               when :describe_analytics
                 {
                     'fields' => {
                         'zonename' => {
                             'label' => 'zone name',
                             'type' => 'string'
                         },
                         'pid' => {
                             'label' => 'process identifier',
                             'type' => 'string'
                         }
                     },
                     'modules' => {
                         'cpu' => {
                             'label' => 'CPU'
                         }
                     },
                     'transformations' => {
                         'geolocate' => {
                             'label' => 'geolocate IP addresses',
                             'fields' => ['raddr'] }
                     },
                     'metrics' => [{
                                       "module" => "cpu",
                                       "stat" => "thread_executions",
                                       "label" => "thread executions",
                                       "interval" => "interval",
                                       "fields" => ["hostname", "zonename", "runtime"],
                                       "unit" => "operations"
                                   }],
                     'types' => {
                         'string' => {
                             'arity' => "discrete",
                             'unit' => ""
                         }
                     }
                 }
               else
                 {}
               end
  end
end
new(options = {}) click to toggle source
# File lib/fog/joyent/analytics.rb, line 133
def initialize(options = {})
  @joyent_username = options[:joyent_username]
  @joyent_password = options[:joyent_password]
  @joyent_url = 'https://us-sw-1.api.joyentcloud.com'
  @joyent_version = '~7'
end

Public Instance Methods

create_instrumentation(values = {}) click to toggle source
# File lib/fog/joyent/requests/analytics/create_instrumentation.rb, line 16
def create_instrumentation(values = {})
  response = Excon::Response.new
  response.status = 201
  response.body = self.data[:instrumentation]
  response
end
data() click to toggle source
# File lib/fog/joyent/analytics.rb, line 129
def data
  self.class.data
end
delete_instrumentation(id) click to toggle source
# File lib/fog/joyent/requests/analytics/delete_instrumentation.rb, line 15
def delete_instrumentation(id)
  response = Excon::Response.new
  response.status = 204
  response
end
describe_analytics(force = false) click to toggle source
# File lib/fog/joyent/requests/analytics/describe_analytics.rb, line 17
def describe_analytics(force = false)
  response = Excon::Response.new
  response.status = 200
  response.body = self.data[:describe_analytics]
  response
end
get_instrumentation(id) click to toggle source
# File lib/fog/joyent/requests/analytics/get_instrumentation.rb, line 16
def get_instrumentation(id)
  raise Fog::Compute::Joyent::Errors::NotFound.new('not found') unless id == self.data[:instrumentation]['id']
  response = Excon::Response.new
  response.status = 200
  response.body = self.data[:instrumentation]
  response
end
get_instrumentation_value(url, requested_start_time, ndatapoints, duration) click to toggle source
# File lib/fog/joyent/requests/analytics/get_instrumentation_value.rb, line 21
def get_instrumentation_value(url, requested_start_time, ndatapoints, duration)
  response = Excon::Response.new
  response.status = 200
  response.body = [self.data[:values]]
  response
end
list_instrumentations() click to toggle source
# File lib/fog/joyent/requests/analytics/list_instrumentations.rb, line 16
def list_instrumentations
  response = Excon::Response.new
  response.status = 200
  response.body = [self.data[:instrumentation]]
  response
end
request(opts) click to toggle source
# File lib/fog/joyent/analytics.rb, line 140
def request(opts)
  raise "Not Implemented"
end