Class: Smartdc::Cli::Analytic

Inherits:
Thor
  • Object
show all
Includes:
Smartdc::CliHelper
Defined in:
lib/smartdc/cli/analytic.rb

Instance Method Summary collapse

Methods included from Smartdc::CliHelper

#describe, #horizontal, #output, #use_machine, #vertical

Instance Method Details

#addObject



42
43
44
45
# File 'lib/smartdc/cli/analytic.rb', line 42

def add
  body = {module: options[:module], stat: options[:stat]}
  output Smartdc.create_analytic(body), options.merge(table: :vertical, exclude: %i[uris])
end

#descObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/smartdc/cli/analytic.rb', line 9

def desc
  if options['raw']
    puts Smartdc.describe_analytics.body
  else
    content = Smartdc.describe_analytics.content
    describe('modules', content, options.merge(cols: %w[key label]))
    describe('fields', content, options.merge(cols: %w[key label type]))
    describe('types', content, options.merge(cols: %w[key name arity unit abbr base power]))
    describe('metrics', content, options.merge(cols: :all, exclude: %i[fields]))
    describe('transformations', content, options.merge(cols: %w[key label]))
  end
end

#destroy(id) ⇒ Object



48
49
50
# File 'lib/smartdc/cli/analytic.rb', line 48

def destroy(id)
  output Smartdc.destroy_analytic(id), options.merge(message: "Analytic #{id} destroy.")
end

#listObject



23
24
25
26
27
# File 'lib/smartdc/cli/analytic.rb', line 23

def list
  output Smartdc.analytics, options.merge(table: :horizontal, include: %i[
    id module stat decomposition
  ])
end

#show(id) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/smartdc/cli/analytic.rb', line 31

def show(id)
  if options[:value]
    output Smartdc.value_analytic(id), options.merge({table: :vertical})
  else
    output Smartdc.analytic(id), options.merge(table: :vertical, exclude: %i[uris])
  end
end