gooddata 0.5.11 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -88,6 +88,22 @@ module GoodData
88
88
  threaded[:connection] = Connection.new user, password, url, options
89
89
  end
90
90
 
91
+ # This method is aimed at creating an authenticated connection in case you do not hae pass/login but you have SST
92
+ # === Parameters
93
+ #
94
+ # * +options+ - :server => optional GD server uri. If nil it secure will be used
95
+ # * +options+ - :cookies => you can specify a hash of cookies
96
+ #
97
+ def create_authenticated_connection(options={})
98
+ url = options[:server]
99
+
100
+ connect("", "", url, options)
101
+ server_cookies = options[:cookies]
102
+ connection.merge_cookies!(server_cookies)
103
+ connection.status = :logged_in
104
+ connection
105
+ end
106
+
91
107
  # Returns the active GoodData connection earlier initialized via
92
108
  # GoodData.connect call
93
109
  #
@@ -35,6 +35,8 @@ module GoodData
35
35
  STAGE_PATH = '/uploads/'
36
36
 
37
37
  attr_reader(:auth_token)
38
+ attr_accessor :status
39
+
38
40
 
39
41
  # Options:
40
42
  # * :tries - Number of retries to perform. Defaults to 1.
@@ -75,6 +77,15 @@ module GoodData
75
77
  @url = url || DEFAULT_URL
76
78
  @auth_token = options.delete(:auth_token)
77
79
  @options = options
80
+
81
+ @server = RestClient::Resource.new @url,
82
+ :timeout => @options[:timeout],
83
+ :headers => {
84
+ :content_type => :json,
85
+ :accept => [ :json, :zip ],
86
+ :user_agent => GoodData.gem_version_string,
87
+ }
88
+
78
89
  end
79
90
 
80
91
  # Returns the user JSON object of the currently logged in GoodData user account.
@@ -279,14 +290,6 @@ module GoodData
279
290
  }
280
291
  }
281
292
 
282
- @server = RestClient::Resource.new @url,
283
- :timeout => @options[:timeout],
284
- :headers => {
285
- :content_type => :json,
286
- :accept => [ :json, :zip ],
287
- :user_agent => GoodData.gem_version_string,
288
- }
289
-
290
293
  GoodData.logger.debug "Logging in..."
291
294
  @user = post(LOGIN_PATH, credentials, :dont_reauth => true)['userLogin']
292
295
  refresh_token :dont_reauth => true # avoid infinite loop if refresh_token fails with 401
@@ -9,7 +9,7 @@ module GoodData
9
9
  def [](id)
10
10
  raise "Cannot search for nil #{self.class}" unless id
11
11
  uri = if id.is_a? Integer or id =~ /^\d+$/
12
- "#{GoodData.project.md.link(MD_OBJ_CTG)}/#{id}"
12
+ "#{GoodData.project.md[MD_OBJ_CTG]}/#{id}"
13
13
  elsif id !~ /\//
14
14
  identifier_to_uri id
15
15
  elsif id =~ /^\//
@@ -33,15 +33,36 @@ module GoodData
33
33
  end
34
34
 
35
35
  def execute
36
- # puts "Executing report #{uri}"
37
36
  result = GoodData.post '/gdc/xtab2/executor3', {"report_req" => {"report" => uri}}
38
- dataResultUri = result["execResult"]["dataResult"]
39
- result = GoodData.get dataResultUri
37
+ data_result_uri = result["execResult"]["dataResult"]
38
+ result = GoodData.get data_result_uri
40
39
  while result["taskState"] && result["taskState"]["status"] == "WAIT" do
41
40
  sleep 10
42
- result = GoodData.get dataResultUri
41
+ result = GoodData.get data_result_uri
43
42
  end
44
- ReportDataResult.new(GoodData.get dataResultUri)
43
+ ReportDataResult.new(GoodData.get data_result_uri)
44
+ end
45
+
46
+ def export(format)
47
+ result = GoodData.post('/gdc/xtab2/executor3', {"report_req" => {"report" => uri}})
48
+ result1 = GoodData.post('/gdc/exporter/executor', {:result_req => {:format => format, :result => result}})
49
+ png = GoodData.get(result1['uri'], :process => false)
50
+ while (png.code == 202) do
51
+ sleep(1)
52
+ png = GoodData.get(result1['uri'], :process => false)
53
+ end
54
+ png
55
+ end
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
45
66
  end
46
67
  end
47
68
  end
@@ -1,3 +1,3 @@
1
1
  module GoodData
2
- VERSION = "0.5.11"
2
+ VERSION = "0.5.12"
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.11
4
+ version: 0.5.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: