gooddata 0.5.12 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,93 @@
1
1
  = GoodData Ruby wrapper and CLI
2
2
 
3
- A convenient Ruby wrapper around the GoodData RESTful API.
3
+ A convenient Ruby wrapper around the GoodData RESTful API. The gem comes in two flavors. It has a CLI client and it is a library whch you can integrate into your application.
4
4
 
5
- Use the Gooddata::Client class to integrate GoodData into your own application
6
- or use the CLI to work with GoodData directly from the command line.
7
-
8
- The best documentation for the API can be found using these resources:
5
+ The best documentation for the GoodData API can be found using these resources:
6
+ * http://docs.gooddata.apiary.io/
9
7
  * http://developer.gooddata.com/api
10
8
  * https://secure.gooddata.com/gdc
11
9
 
12
- == Usage
10
+ == Install
11
+
12
+ If you are using bundler. Add
13
+
14
+ gem "gooddata"
15
+
16
+ into Gemfile
17
+
18
+ and run
19
+
20
+ bundle install
21
+
22
+ If you are using gems just
23
+
24
+ gem install gooddata
25
+
26
+ === Library usage
27
+
28
+
29
+ In its most simple form GoodData gem just cares about the logging in and juggling the tokens that are needed for you to retrive information. It provides you the usual HTTP methods that you are used to. Couple of examples.
30
+
31
+ ==== Authentiacation
32
+
33
+ GoodData.connect("login", "pass")
13
34
 
14
- Since this project is in its early stages, no gem have been released to rubygems.org yet.
15
- To install the gooddata gem, you instead have to first checkout this repository. Then install
16
- the gem using the rake task:
35
+ # Different server than the usual secure.gooddata.com
36
+ GoodData.connect("login", "pass", "https://different.server.gooddata.com")
17
37
 
18
- rake install
38
+ # the last argument is passed to underlying RestClient so you can specify other useful stuff there
39
+ GoodData.connect("login", "pass", "https://different.server.gooddata.com", :timeout => 0)
19
40
 
20
- Now you are ready to use either the Ruby wrapper class or the CLI.
41
+ ==== Basic requests
21
42
 
22
- Alternatively you can run the source code directly. For details about this approach, see {the
23
- Development Wiki page}[http://github.com/gooddata/gooddata-ruby/wiki/Development].
43
+ GoodData.get("/gdc/md")
24
44
 
25
- === Wrapper class usage
45
+ # This post will not actually work it is just for the illustration
46
+ GoodData.post("/gdc/md/#{project_id}", {:my_object => "some_date"})
26
47
 
27
- For details of how to use the Ruby wrapper class, see the Gooddata::Client RDoc.
48
+ # and the same goes for put delete
49
+ # By default the response is decoded for you as json but sometimes you do not want that png or other stuff.
50
+ # you will get the response object and you can query it further
51
+ response = GoodData.get("/gdc/md", :process => false)
52
+ response.code == 400
53
+ pp response.body
54
+
55
+ ==== Loading of data
56
+
57
+ This library is able to load data but it is not used that much if at all. Since there is some data processing needed on the client side we rely on faster implementations in Java usually. Let us know if you would be interested. As the APIs improve we could bring it back.
58
+
59
+ ==== Other stuff
60
+ The API is currently a little fragmented and we never had the guts to actually deal with all the ugliness and present nice object oriented API. Usually it is just better to deal with the ugly json as hashes. But there are couple of exceptions where we needed something better and we thought providing an abstraction is worth the hassle.
61
+
62
+ ==== Working with obj
63
+
64
+ obj is a resource that is probably the oldest in all GoodData. Obj are all the objects that have something to do with the analytical engine (metrics, attributes, reports etc). You can find the docs here (Add link to apiary). There are coule of convenience methods to work with these
65
+
66
+ GoodData.connect("svarovsky@gooddata.com", "just_testing")
67
+ GoodData.project="fill_in_your_project_pid"
68
+
69
+ obj = GoodData::MdObject[obj_number]
70
+ # bunch of useful methods are defined on these
71
+ obj.title
72
+ obj.get_used_by
73
+ obj.get_using
74
+ obj.delete
75
+
76
+ ==== Working with reports
77
+ Sometimes it is useful to compute reports outside of UI so there are couple of convenience methods for that.
78
+
79
+ require 'pp'
80
+
81
+ GoodData.connect("svarovsky@gooddata.com", "just_testing")
82
+ GoodData.project="fill_in_your_project_pid"
83
+
84
+ report = GoodData::Report[1231]
85
+ result = report.execute
86
+ pp result
87
+
88
+ File.open('png.png', 'w') do |f|
89
+ f.write(report.export(:png))
90
+ end
28
91
 
29
92
  === CLI Usage
30
93
 
@@ -60,9 +123,9 @@ To get a list of projects available to your GoodData user account, run:
60
123
 
61
124
  The output from the above command will look similar to this:
62
125
 
63
- 521 Some project
64
- 3521 Some other project
65
- 3642 Some third project
126
+ 521 Some project
127
+ 3521 Some other project
128
+ 3642 Some third project
66
129
 
67
130
  The first column contains the project-key. You need this if you wan't to either
68
131
  see more details about the project using the <tt>projects:show</tt> comamnd or
@@ -89,7 +152,9 @@ You will then be asked about the desired project name and summary before it's cr
89
152
  == Credits
90
153
 
91
154
  This project is developed and maintained by Pavel Kolesnikov [ mailto:pavel@gooddata.com
92
- / {@koles}[http:/twitter.com/koles] ] and Thomas Watson Steen [ mailto:w@tson.dk /
155
+ / {@koles}[http:/twitter.com/koles] ] and Tomas Svarovsky [mailto:svarovsky.tomas@gmail.com]
156
+
157
+ Special thanks to Thomas Watson Steen [ mailto:w@tson.dk /
93
158
  {@wa7son}[http://twitter.com/wa7son] ]
94
159
 
95
160
  == Copyright
@@ -0,0 +1,36 @@
1
+ module GoodData
2
+ class Dashboard < GoodData::MdObject
3
+
4
+ class << self
5
+ def [](id)
6
+ if id == :all
7
+ GoodData.get(GoodData.project.md['query'] + '/projectDashboard/')['query']['entries']
8
+ else
9
+ super
10
+ end
11
+ end
12
+ end
13
+
14
+ def export(format, options={})
15
+ supported_formats = [:pdf]
16
+ fail "Wrong format provied \"#{format}\". Only supports formats #{supported_formats.join(', ')}" unless supported_formats.include?(format)
17
+ tab = options[:tab] || ""
18
+ x = GoodData.post("/gdc/projects/lbhjnmbwa07f9g46hnjp3l5c9hphnev9/clientexport", {"clientExport" => {"url" => "https://secure.gooddata.com/dashboard.html#project=#{GoodData.project.uri}&dashboard=#{uri}&tab=#{tab}&export=1", "name" => title}}, :process => false)
19
+ while (x.code == 202) do
20
+ sleep(1)
21
+ uri = JSON.parse(x.body)["asyncTask"]["link"]["poll"]
22
+ x = GoodData.get(uri, :process => false)
23
+ end
24
+ x
25
+ end
26
+
27
+ def tabs
28
+ content["tabs"]
29
+ end
30
+
31
+ def tabs_ids
32
+ tabs.map {|t| t["identifier"]}
33
+ end
34
+
35
+ end
36
+ end
@@ -54,15 +54,5 @@ module GoodData
54
54
  png
55
55
  end
56
56
 
57
- def execute_report
58
- result = GoodData.post '/gdc/xtab2/executor3', {"report_req" => {"report" => uri}}
59
- data_result_uri = result["execResult"]["dataResult"]
60
- result = GoodData.get data_result_uri
61
- while result["taskState"] && result["taskState"]["status"] == "WAIT" do
62
- sleep 10
63
- result = GoodData.get data_result_uri
64
- end
65
- data_result_uri
66
- end
67
57
  end
68
58
  end
@@ -1,3 +1,3 @@
1
1
  module GoodData
2
- VERSION = "0.5.12"
2
+ VERSION = "0.5.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.12
4
+ version: 0.5.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -162,6 +162,7 @@ files:
162
162
  - lib/gooddata/extract.rb
163
163
  - lib/gooddata/helpers.rb
164
164
  - lib/gooddata/model.rb
165
+ - lib/gooddata/models/dashboard.rb
165
166
  - lib/gooddata/models/data_result.rb
166
167
  - lib/gooddata/models/links.rb
167
168
  - lib/gooddata/models/metadata.rb