Class: GoodData::Command::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata/commands/api.rb

Overview

Low level access to GoodData API

Class Method Summary collapse

Class Method Details

.delete(args, opts) ⇒ Object

Delete resource

Parameters:

  • path

    Resource path



49
50
51
52
53
54
55
# File 'lib/gooddata/commands/api.rb', line 49

def delete(args, opts)
  path = args.first
  fail(GoodData::CommandFailed, 'Specify the path you want to DELETE.') if path.nil?

  client = GoodData.connect(opts)
  client.delete path
end

.get(args, opts) ⇒ Object

Get resource

Parameters:

  • path

    Resource path



39
40
41
42
43
44
45
# File 'lib/gooddata/commands/api.rb', line 39

def get(args, opts)
  path = args.first
  fail(GoodData::CommandFailed, 'Specify the path you want to GET.') if path.nil?

  client = GoodData.connect(opts)
  client.get path
end

.infoObject Also known as: index



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gooddata/commands/api.rb', line 13

def info
  json = {
    'releaseName' => 'N/A',
    'releaseDate' => 'N/A',
    'releaseNotesUri' => 'N/A'
  }

  puts 'GoodData API'
  puts "  Version: #{json['releaseName']}"
  puts "  Released: #{json['releaseDate']}"
  puts "  For more info see #{json['releaseNotesUri']}"
end

.post(args, opts) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/gooddata/commands/api.rb', line 57

def post(args, opts)
  path = Array(args).shift
  fail(GoodData::CommandFailed, 'Specify the path you want to POST to.') if path.nil?

  payload = Array(args).shift
  json = payload && File.exist?(payload) ? JSON.parse(File.read(payload)) : {}
  client = GoodData.connect(opts)
  client.post path, json
end

.testObject

Test of login



29
30
31
32
33
34
35
# File 'lib/gooddata/commands/api.rb', line 29

def test
  if GoodData.
    puts "Succesfully logged in as #{GoodData.profile.user}"
  else
    puts 'Unable to log in to GoodData server!'
  end
end