gooddata 0.6.26 → 0.6.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gooddata.gemspec +3 -4
- data/lib/gooddata/cli/shared.rb +5 -0
- data/lib/gooddata/commands/project.rb +2 -4
- data/lib/gooddata/core/logging.rb +48 -29
- data/lib/gooddata/core/nil_logger.rb +6 -0
- data/lib/gooddata/helpers/global_helpers.rb +3 -3
- data/lib/gooddata/models/domain.rb +5 -4
- data/lib/gooddata/models/metadata.rb +2 -1
- data/lib/gooddata/models/metadata/report.rb +5 -1
- data/lib/gooddata/models/model.rb +1 -1
- data/lib/gooddata/models/process.rb +2 -0
- data/lib/gooddata/models/project.rb +30 -9
- data/lib/gooddata/models/project_metadata.rb +8 -2
- data/lib/gooddata/rest/connection.rb +19 -17
- data/lib/gooddata/version.rb +1 -1
- data/spec/environment/develop.rb +4 -4
- data/spec/environment/environment.rb +9 -2
- data/spec/integration/clients_spec.rb +5 -6
- data/spec/integration/full_process_schedule_spec.rb +1 -1
- data/spec/integration/project_spec.rb +3 -3
- data/spec/integration/schedule_spec.rb +2 -2
- data/spec/integration/user_filters_spec.rb +2 -1
- data/spec/integration/user_group_spec.rb +8 -8
- data/spec/integration/variables_spec.rb +2 -1
- data/spec/unit/core/logging_spec.rb +11 -3
- data/spec/unit/helpers_spec.rb +0 -1
- data/spec/unit/models/domain_spec.rb +0 -9
- data/spec/unit/models/from_wire_spec.rb +0 -4
- data/spec/unit/models/metric_spec.rb +0 -4
- data/spec/unit/models/profile_spec.rb +3 -2
- data/spec/unit/models/project_role_spec.rb +7 -8
- data/spec/unit/models/to_manifest_spec.rb +2 -4
- metadata +30 -81
- data/lib/gooddata/rest/connections/rest_client_connection.rb +0 -181
- data/spec/unit/cli/commands/cmd_api_spec.rb +0 -40
- data/spec/unit/cli/commands/cmd_domain_spec.rb +0 -112
- data/spec/unit/cli/commands/cmd_process_spec.rb +0 -47
- data/spec/unit/cli/commands/cmd_project_spec.rb +0 -85
- data/spec/unit/cli/commands/cmd_role_spec.rb +0 -59
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +0 -17
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +0 -64
- data/spec/unit/cli/commands/cmd_user_spec.rb +0 -35
- data/spec/unit/commands/command_api_spec.rb +0 -18
- data/spec/unit/commands/command_auth_spec.rb +0 -171
- data/spec/unit/commands/command_dataset_spec.rb +0 -50
- data/spec/unit/commands/command_process_spec.rb +0 -97
- data/spec/unit/commands/command_scaffold_spec.rb +0 -67
- data/spec/unit/commands/command_user_spec.rb +0 -28
- data/spec/unit/data/guesser_spec.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c722429b61df1bed1aaded70e6965395e0fca4
|
4
|
+
data.tar.gz: 053753b93d712a9b425f78ffe01d2d79073f2b40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a779370b66fdba96c47a2d56af28a71223b383765a52f4452c6736dd10646fe8296605aa3426e315d67f2af199fce33e3cff6a7ddaaa652734e267749e4571d8
|
7
|
+
data.tar.gz: 176dff8b1c9691c537a43cc7e1cb9c316cee0a9a7efb9d24fa57cc55e211a3b67cdbb4a7193a6988983924bf09fac67371f4eb450c9157441ef062c266ffd782
|
data/gooddata.gemspec
CHANGED
@@ -29,13 +29,12 @@ Gem::Specification.new do |s|
|
|
29
29
|
|
30
30
|
s.add_development_dependency 'bundler'
|
31
31
|
s.add_development_dependency 'debase', '~> 0.1', '>= 0.1.7' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
|
32
|
-
s.add_development_dependency 'guard', '~> 2.13', '>= 2.13.0'
|
33
|
-
s.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6.4'
|
34
32
|
s.add_development_dependency 'license_finder', '~> 2.0', '>= 2.0.4'
|
35
|
-
s.add_development_dependency 'rake', '~>
|
33
|
+
s.add_development_dependency 'rake', '~> 11.1', '>= 11.1.1'
|
36
34
|
s.add_development_dependency 'rake-notes', '~> 0.2', '>= 0.2.0'
|
37
35
|
s.add_development_dependency 'redcarpet', '~> 3.1', '>= 3.1.1' if RUBY_PLATFORM != 'java'
|
38
|
-
s.add_development_dependency 'rspec', '~> 3.
|
36
|
+
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
37
|
+
s.add_development_dependency 'rspec-expectations', '~> 3.4', '>= 3.4.0'
|
39
38
|
s.add_development_dependency 'rubocop', '~> 0.34', '>= 0.34.0'
|
40
39
|
s.add_development_dependency 'ruby-debug-ide', '~> 0.4' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
|
41
40
|
s.add_development_dependency 'simplecov', '~> 0.10', '>= 0.10.0'
|
data/lib/gooddata/cli/shared.rb
CHANGED
@@ -40,6 +40,11 @@ module GoodData
|
|
40
40
|
arg_name 'server'
|
41
41
|
flag [:s, :server]
|
42
42
|
|
43
|
+
desc 'Verify SSL certificate'
|
44
|
+
default_value true
|
45
|
+
arg_name 'verify-ssl'
|
46
|
+
switch [:'verify-ssl', :verify_ssl]
|
47
|
+
|
43
48
|
desc 'WEBDAV Server. Used for uploads of files'
|
44
49
|
default_value nil
|
45
50
|
arg_name 'web dav server'
|
@@ -106,7 +106,7 @@ module GoodData
|
|
106
106
|
def jack_in(options)
|
107
107
|
goodfile_path = GoodData::Helpers.find_goodfile(Pathname('.'))
|
108
108
|
|
109
|
-
spin_session = proc do |goodfile
|
109
|
+
spin_session = proc do |goodfile|
|
110
110
|
project_id = options[:project_id] || goodfile[:project_id]
|
111
111
|
|
112
112
|
begin
|
@@ -125,10 +125,8 @@ module GoodData
|
|
125
125
|
|
126
126
|
if goodfile_path
|
127
127
|
goodfile = MultiJson.load(File.read(goodfile_path), :symbolize_keys => true)
|
128
|
-
model_key = goodfile[:model]
|
129
|
-
blueprint = GoodData::Model::ProjectBlueprint.new(eval(File.read(model_key)).to_hash) if File.exist?(model_key) && !File.directory?(model_key)
|
130
128
|
FileUtils.cd(goodfile_path.dirname) do
|
131
|
-
spin_session.call(goodfile
|
129
|
+
spin_session.call(goodfile)
|
132
130
|
end
|
133
131
|
else
|
134
132
|
spin_session.call({}, nil)
|
@@ -4,33 +4,40 @@
|
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
6
6
|
|
7
|
+
require 'rest-client'
|
8
|
+
|
7
9
|
require_relative 'nil_logger'
|
8
10
|
|
9
11
|
module GoodData
|
12
|
+
DEFAULT_LOG_LEVEL = Logger::INFO
|
13
|
+
DEFAULT_LOG_OUTPUT = STDOUT
|
14
|
+
DEFAULT_LOGGER_CLASS = Logger
|
15
|
+
|
16
|
+
DEFAULT_RESTLOG_LEVEL = Logger::INFO
|
17
|
+
DEFAULT_RESTLOG_OUTPUT = STDOUT
|
18
|
+
DEFAULT_RESTLOGGER_CLASS = Logger
|
19
|
+
|
10
20
|
class << self
|
11
|
-
|
21
|
+
attr_accessor :logger, :rest_logger
|
12
22
|
attr_writer :stats
|
13
23
|
|
14
24
|
# Turn logging on
|
15
25
|
#
|
16
26
|
# ### Example
|
17
27
|
#
|
28
|
+
# # Turn of default logging
|
18
29
|
# GoodData.logging_on
|
19
30
|
#
|
20
|
-
|
21
|
-
|
22
|
-
@logger.level = level if level
|
23
|
-
@logger
|
24
|
-
end
|
25
|
-
|
26
|
-
# Turn logging on with HTTP included
|
31
|
+
# # Log only WARN and higher
|
32
|
+
# GoodData.logging_on(Logger::WARN)
|
27
33
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# GoodData.logging_http_on
|
34
|
+
# # Log DEBUG and above to file
|
35
|
+
# GoodData.logging_on(Logger::DEBUG, 'log.txt')
|
31
36
|
#
|
32
|
-
def
|
33
|
-
|
37
|
+
def logging_on(level = DEFAULT_LOG_LEVEL, output = DEFAULT_LOG_OUTPUT, klass = DEFAULT_LOGGER_CLASS)
|
38
|
+
@logger = klass.new(output)
|
39
|
+
@logger.level = level
|
40
|
+
@logger
|
34
41
|
end
|
35
42
|
|
36
43
|
# Turn logging on
|
@@ -47,18 +54,30 @@ module GoodData
|
|
47
54
|
!@logger.instance_of?(NilLogger)
|
48
55
|
end
|
49
56
|
|
50
|
-
#
|
51
|
-
# is a logger to stdout on INFO level
|
52
|
-
# For some serious logging, set the logger instance using
|
53
|
-
# the logger= method
|
57
|
+
# Turn logging on with HTTP included
|
54
58
|
#
|
55
59
|
# ### Example
|
56
60
|
#
|
57
|
-
#
|
58
|
-
# GoodData.logger = Logger.new(STDOUT)
|
61
|
+
# GoodData.logging_http_on
|
59
62
|
#
|
60
|
-
def
|
61
|
-
@logger
|
63
|
+
def logging_http_on(level = DEFAULT_RESTLOG_LEVEL, output = DEFAULT_RESTLOG_OUTPUT, klass = DEFAULT_RESTLOGGER_CLASS)
|
64
|
+
@logger = klass.new(output)
|
65
|
+
@logger.level = level
|
66
|
+
@logger
|
67
|
+
end
|
68
|
+
|
69
|
+
# Turn logging on
|
70
|
+
#
|
71
|
+
# ### Example
|
72
|
+
#
|
73
|
+
# GoodData.logging_http_off
|
74
|
+
#
|
75
|
+
def logging_http_off
|
76
|
+
@rest_client = NilLogger.new
|
77
|
+
end
|
78
|
+
|
79
|
+
def logging_http_on?
|
80
|
+
!@rest_client.instance_of?(NilLogger)
|
62
81
|
end
|
63
82
|
|
64
83
|
def stats_on
|
@@ -73,14 +92,14 @@ module GoodData
|
|
73
92
|
@stats = false
|
74
93
|
end
|
75
94
|
|
76
|
-
|
95
|
+
# Initial setup of logger
|
96
|
+
GoodData.logger = GoodData.logging_on
|
77
97
|
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
98
|
+
# Initial setup of rest logger
|
99
|
+
GoodData.rest_logger = GoodData.logging_http_on(
|
100
|
+
nil,
|
101
|
+
DEFAULT_RESTLOG_OUTPUT,
|
102
|
+
NilLogger
|
103
|
+
)
|
85
104
|
end
|
86
105
|
end
|
@@ -28,10 +28,10 @@ module GoodData
|
|
28
28
|
root = Pathname(options[:root] || '/')
|
29
29
|
pwd = Pathname(pwd).expand_path
|
30
30
|
loop do
|
31
|
-
gf = pwd + '
|
32
|
-
return gf if
|
31
|
+
gf = pwd + '.gooddata'
|
32
|
+
return gf if File.exist?(gf)
|
33
33
|
pwd = pwd.parent
|
34
|
-
break
|
34
|
+
break if root == pwd
|
35
35
|
end
|
36
36
|
nil
|
37
37
|
end
|
@@ -14,6 +14,8 @@ module GoodData
|
|
14
14
|
class Domain < Rest::Resource
|
15
15
|
attr_reader :name
|
16
16
|
|
17
|
+
ProvisioningResult = Struct.new('ProvisioningResult', :id, :status, :project_uri, :error)
|
18
|
+
|
17
19
|
class << self
|
18
20
|
# Looks for domain
|
19
21
|
#
|
@@ -230,11 +232,11 @@ module GoodData
|
|
230
232
|
domain = client.domain(default_domain_name)
|
231
233
|
|
232
234
|
# Prepare cache for domain users
|
233
|
-
domain_users_cache = Hash[domain.users.map { |u| [u.login, u] }]
|
235
|
+
domain_users_cache = Hash[domain.users.map { |u| [u.login.downcase, u] }]
|
234
236
|
|
235
237
|
list.pmapcat do |user|
|
236
238
|
begin
|
237
|
-
user_data = user.to_hash
|
239
|
+
user_data = user.to_hash.tap { |uh| uh[:login].downcase }
|
238
240
|
domain_user = domain_users_cache[user_data[:login]]
|
239
241
|
if !domain_user
|
240
242
|
added_user = domain.add_user(user_data, opts)
|
@@ -387,7 +389,6 @@ module GoodData
|
|
387
389
|
def provision_client_projects
|
388
390
|
res = client.post(segments_uri + '/provisionClientProjects', nil)
|
389
391
|
res = client.poll_on_code(res['asyncTask']['links']['poll'])
|
390
|
-
klass = Struct.new('ProvisioningResult', :id, :status, :project_uri, :error)
|
391
392
|
failed_count = GoodData::Helpers.get_path(res, %w(clientProjectProvisioningResult failed count), 0)
|
392
393
|
created_count = GoodData::Helpers.get_path(res, %w(clientProjectProvisioningResult created count), 0)
|
393
394
|
return Enumerator.new([]) if failed_count + created_count == 0
|
@@ -396,7 +397,7 @@ module GoodData
|
|
396
397
|
loop do
|
397
398
|
result = client.get(uri)
|
398
399
|
(GoodData::Helpers.get_path(result, %w(clientProjectProvisioningResultDetails items)) || []).each do |item|
|
399
|
-
y <<
|
400
|
+
y << ProvisioningResult.new(item['id'], item['status'], item['project'], item['error'])
|
400
401
|
end
|
401
402
|
uri = GoodData::Helpers.get_path(res, %w(clientProjectProvisioningResultDetails paging next))
|
402
403
|
break if uri.nil?
|
@@ -194,7 +194,8 @@ module GoodData
|
|
194
194
|
explicit_identifier = meta['identifier']
|
195
195
|
# Pre-check to provide a user-friendly error rather than
|
196
196
|
# failing later
|
197
|
-
|
197
|
+
klass = self.class
|
198
|
+
if explicit_identifier && klass[explicit_identifier, opts]
|
198
199
|
fail "Identifier '#{explicit_identifier}' already in use"
|
199
200
|
end
|
200
201
|
|
@@ -27,7 +27,11 @@ module GoodData
|
|
27
27
|
title = options[:title]
|
28
28
|
fail 'Report needs a title specified' unless title
|
29
29
|
summary = options[:summary] || ''
|
30
|
-
|
30
|
+
|
31
|
+
options_rd = options.dup
|
32
|
+
options_rd.delete(:identifier)
|
33
|
+
|
34
|
+
rd = options[:rd] || ReportDefinition.create(options_rd)
|
31
35
|
rd.save
|
32
36
|
|
33
37
|
report = {
|
@@ -175,7 +175,7 @@ module GoodData
|
|
175
175
|
data.zip(manifest['dataSetSLIManifestList']).each do |item|
|
176
176
|
path = item[0][:data]
|
177
177
|
path = item[0][:data].path if item[0][:data].respond_to? :path
|
178
|
-
inline_data = path.is_a?(String)
|
178
|
+
inline_data = !path.is_a?(String)
|
179
179
|
csv_header = nil
|
180
180
|
|
181
181
|
filename = item[1]['dataSetSLIManifest']['file']
|
@@ -170,6 +170,7 @@ module GoodData
|
|
170
170
|
private
|
171
171
|
|
172
172
|
def with_zip(opts = {})
|
173
|
+
client = opts[:client]
|
173
174
|
Tempfile.open('deploy-graph-archive') do |temp|
|
174
175
|
zip_filename = temp.path
|
175
176
|
File.open(zip_filename, 'w') do |zip|
|
@@ -183,6 +184,7 @@ module GoodData
|
|
183
184
|
end
|
184
185
|
|
185
186
|
def zip_and_upload(path, files_to_exclude, opts = {})
|
187
|
+
client = opts[:client]
|
186
188
|
puts 'Creating package for upload'
|
187
189
|
if !path.directory? && (path.extname == '.grf' || path.extname == '.rb')
|
188
190
|
with_zip(opts) do |zipfile|
|
@@ -207,7 +207,11 @@ module GoodData
|
|
207
207
|
else
|
208
208
|
client.projects(to_project)
|
209
209
|
end
|
210
|
+
transfer_processes(from_project, to_project)
|
211
|
+
transfer_schedules(from_project, to_project)
|
212
|
+
end
|
210
213
|
|
214
|
+
def transfer_processes(from_project, to_project)
|
211
215
|
from_project.processes.each do |process|
|
212
216
|
Dir.mktmpdir('etl_transfer') do |dir|
|
213
217
|
dir = Pathname(dir)
|
@@ -224,7 +228,6 @@ module GoodData
|
|
224
228
|
.select { |_, procs| procs.length == 1 }
|
225
229
|
.flat_map { |_, procs| procs.select { |p| p[0].project.pid == to_project.pid }.map { |p| p[0] } }
|
226
230
|
.peach(&:delete)
|
227
|
-
transfer_schedules(from_project, to_project)
|
228
231
|
end
|
229
232
|
|
230
233
|
# Clones project along with etl and schedules.
|
@@ -352,8 +355,8 @@ module GoodData
|
|
352
355
|
# @param [options] Optional report options
|
353
356
|
# @return [GoodData::Report] Instance of new report
|
354
357
|
def add_report(options = {})
|
355
|
-
|
356
|
-
|
358
|
+
report = GoodData::Report.create(options.merge(client: client, project: self))
|
359
|
+
report.save
|
357
360
|
end
|
358
361
|
|
359
362
|
alias_method :create_report, :add_report
|
@@ -1283,7 +1286,7 @@ module GoodData
|
|
1283
1286
|
# Imports users
|
1284
1287
|
def import_users(new_users, options = {})
|
1285
1288
|
role_list = roles
|
1286
|
-
users_list = users
|
1289
|
+
users_list = users
|
1287
1290
|
new_users = new_users.map { |x| (x.is_a?(Hash) && x[:user] && x[:user].to_hash.merge(role: x[:role])) || x.to_hash }
|
1288
1291
|
|
1289
1292
|
GoodData.logger.warn("Importing users to project (#{pid})")
|
@@ -1305,6 +1308,11 @@ module GoodData
|
|
1305
1308
|
role && role.uri
|
1306
1309
|
end
|
1307
1310
|
|
1311
|
+
u[:role_title] = u[:role].map do |r|
|
1312
|
+
role = get_role(r, role_list)
|
1313
|
+
role && role.title
|
1314
|
+
end
|
1315
|
+
|
1308
1316
|
if u[:role].all?(&:nil?)
|
1309
1317
|
u[:type] = :error
|
1310
1318
|
u[:reason] = 'Invalid role(s) specified'
|
@@ -1321,6 +1329,18 @@ module GoodData
|
|
1321
1329
|
|
1322
1330
|
# Diff users. Only login and role is important for the diff
|
1323
1331
|
diff = GoodData::Helpers.diff(whitelisted_users, diffable_new, key: :login, fields: [:login, :role, :status])
|
1332
|
+
diff_results = diff.flat_map do |operation, users|
|
1333
|
+
if operation == :changed
|
1334
|
+
users.map { |u| u[:new_obj].merge(operation: operation) }
|
1335
|
+
else
|
1336
|
+
users.map { |u| u.merge(operation: operation) }
|
1337
|
+
end
|
1338
|
+
end
|
1339
|
+
diff_results = diff_results.map do |u|
|
1340
|
+
u[:login_uri] = "/gdc/account/profile/" + u[:login]
|
1341
|
+
u
|
1342
|
+
end
|
1343
|
+
return diff_results if options[:dry_run]
|
1324
1344
|
|
1325
1345
|
# Create new users
|
1326
1346
|
u = diff[:added].map { |x| { user: x, role: x[:role] } }
|
@@ -1337,7 +1357,7 @@ module GoodData
|
|
1337
1357
|
# Remove old users
|
1338
1358
|
to_remove = diff[:removed].reject { |user| user[:status] == 'DISABLED' || user[:status] == :disabled }
|
1339
1359
|
GoodData.logger.warn("Removing #{to_remove.count} users from project (#{pid})")
|
1340
|
-
results.concat(disable_users(to_remove))
|
1360
|
+
results.concat(disable_users(to_remove, roles: role_list, project_users: whitelisted_users))
|
1341
1361
|
|
1342
1362
|
# reassign to groups
|
1343
1363
|
mappings = new_users.map(&:to_hash).flat_map do |user|
|
@@ -1361,19 +1381,20 @@ module GoodData
|
|
1361
1381
|
g.set_members(whitelist_users(g.members.map(&:to_hash), [], options[:whitelists], :include).first.map { |x| x[:uri] })
|
1362
1382
|
end
|
1363
1383
|
end
|
1364
|
-
results
|
1384
|
+
GoodData::Helpers.join(results, diff_results, [:user], [:login_uri])
|
1365
1385
|
end
|
1366
1386
|
|
1367
|
-
def disable_users(list)
|
1387
|
+
def disable_users(list, options = {})
|
1368
1388
|
list = list.map(&:to_hash)
|
1369
1389
|
url = "#{uri}/users"
|
1370
1390
|
payloads = list.map do |u|
|
1371
|
-
|
1391
|
+
uri, = resolve_roles(u, [], options)
|
1392
|
+
generate_user_payload(uri, 'DISABLED')
|
1372
1393
|
end
|
1373
1394
|
|
1374
1395
|
payloads.each_slice(100).mapcat do |payload|
|
1375
1396
|
result = client.post(url, 'users' => payload)
|
1376
|
-
result['projectUsersUpdateResult'].mapcat { |k, v| v.map { |x| { type: k.to_sym,
|
1397
|
+
result['projectUsersUpdateResult'].mapcat { |k, v| v.map { |x| { type: k.to_sym, user: x } } }
|
1377
1398
|
end
|
1378
1399
|
end
|
1379
1400
|
|
@@ -14,16 +14,22 @@ module GoodData
|
|
14
14
|
def [](key, opts = { :client => GoodData.connection, :project => GoodData.project })
|
15
15
|
client, project = GoodData.get_client_and_project(opts)
|
16
16
|
|
17
|
+
get_opts = {
|
18
|
+
do_not_log: [
|
19
|
+
RestClient::ResourceNotFound
|
20
|
+
]
|
21
|
+
}
|
22
|
+
|
17
23
|
if key == :all
|
18
24
|
uri = "/gdc/projects/#{project.pid}/dataload/metadata"
|
19
|
-
res = client.get(uri)
|
25
|
+
res = client.get(uri, get_opts)
|
20
26
|
res['metadataItems']['items'].reduce({}) do |memo, i|
|
21
27
|
memo[i['metadataItem']['key']] = i['metadataItem']['value']
|
22
28
|
memo
|
23
29
|
end
|
24
30
|
else
|
25
31
|
uri = "/gdc/projects/#{project.pid}/dataload/metadata/#{key}"
|
26
|
-
res = client.get(uri)
|
32
|
+
res = client.get(uri, get_opts)
|
27
33
|
res['metadataItem']['value']
|
28
34
|
end
|
29
35
|
end
|
@@ -330,7 +330,7 @@ module GoodData
|
|
330
330
|
# @param uri [String] Target URI
|
331
331
|
def delete(uri, options = {})
|
332
332
|
options = log_info(options)
|
333
|
-
GoodData.
|
333
|
+
GoodData.rest_logger.info "DELETE: #{@server.url}#{uri}"
|
334
334
|
profile "DELETE #{uri}" do
|
335
335
|
b = proc do
|
336
336
|
params = fresh_request_params(options[:request_id])
|
@@ -338,7 +338,7 @@ module GoodData
|
|
338
338
|
@server[uri].delete(params)
|
339
339
|
rescue RestClient::Exception => e
|
340
340
|
# log the error if it happens
|
341
|
-
log_error(e, uri, params)
|
341
|
+
log_error(e, uri, params, options)
|
342
342
|
raise e
|
343
343
|
end
|
344
344
|
end
|
@@ -351,9 +351,12 @@ module GoodData
|
|
351
351
|
# @param e [RuntimeException] Exception to log
|
352
352
|
# @param uri [String] Uri on which the request failed
|
353
353
|
# @param uri [Hash] Additional params
|
354
|
-
def log_error(e, uri, params)
|
354
|
+
def log_error(e, uri, params, options = {})
|
355
355
|
return if e.response && e.response.code == 401 && !uri.include?('token') && !uri.include?('login')
|
356
|
-
|
356
|
+
|
357
|
+
if options[:do_not_log].nil? || options[:do_not_log].index(e.class).nil?
|
358
|
+
GoodData.logger.error(format_error(e, params))
|
359
|
+
end
|
357
360
|
end
|
358
361
|
|
359
362
|
# HTTP GET
|
@@ -361,7 +364,7 @@ module GoodData
|
|
361
364
|
# @param uri [String] Target URI
|
362
365
|
def get(uri, options = {}, &user_block)
|
363
366
|
options = log_info(options)
|
364
|
-
GoodData.
|
367
|
+
GoodData.rest_logger.info "GET: #{@server.url}#{uri}, #{options}"
|
365
368
|
profile "GET #{uri}" do
|
366
369
|
b = proc do
|
367
370
|
params = fresh_request_params(options[:request_id]).merge(options)
|
@@ -369,7 +372,7 @@ module GoodData
|
|
369
372
|
@server[uri].get(params, &user_block)
|
370
373
|
rescue RestClient::Exception => e
|
371
374
|
# log the error if it happens
|
372
|
-
log_error(e, uri, params)
|
375
|
+
log_error(e, uri, params, options)
|
373
376
|
raise e
|
374
377
|
end
|
375
378
|
end
|
@@ -383,7 +386,7 @@ module GoodData
|
|
383
386
|
def put(uri, data, options = {})
|
384
387
|
options = log_info(options)
|
385
388
|
payload = data.is_a?(Hash) ? data.to_json : data
|
386
|
-
GoodData.
|
389
|
+
GoodData.rest_logger.info "PUT: #{@server.url}#{uri}, #{scrub_params(data, KEYS_TO_SCRUB)}"
|
387
390
|
profile "PUT #{uri}" do
|
388
391
|
b = proc do
|
389
392
|
params = fresh_request_params(options[:request_id])
|
@@ -391,7 +394,7 @@ module GoodData
|
|
391
394
|
@server[uri].put(payload, params)
|
392
395
|
rescue RestClient::Exception => e
|
393
396
|
# log the error if it happens
|
394
|
-
log_error(e, uri, params)
|
397
|
+
log_error(e, uri, params, options)
|
395
398
|
raise e
|
396
399
|
end
|
397
400
|
end
|
@@ -404,7 +407,7 @@ module GoodData
|
|
404
407
|
# @param uri [String] Target URI
|
405
408
|
def post(uri, data = nil, options = {})
|
406
409
|
options = log_info(options)
|
407
|
-
GoodData.
|
410
|
+
GoodData.rest_logger.info "POST: #{@server.url}#{uri}, #{scrub_params(data, KEYS_TO_SCRUB)}"
|
408
411
|
profile "POST #{uri}" do
|
409
412
|
payload = data.is_a?(Hash) ? data.to_json : data
|
410
413
|
b = proc do
|
@@ -413,7 +416,7 @@ module GoodData
|
|
413
416
|
@server[uri].post(payload, params)
|
414
417
|
rescue RestClient::Exception => e
|
415
418
|
# log the error if it happens
|
416
|
-
log_error(e, uri, params)
|
419
|
+
log_error(e, uri, params, options)
|
417
420
|
raise e
|
418
421
|
end
|
419
422
|
end
|
@@ -506,7 +509,6 @@ module GoodData
|
|
506
509
|
return if webdav_dir_exists?(url)
|
507
510
|
|
508
511
|
method = :mkcol
|
509
|
-
GoodData.logger.debug "#{method}: #{url}"
|
510
512
|
b = proc do
|
511
513
|
raw = {
|
512
514
|
:method => method,
|
@@ -595,25 +597,25 @@ module GoodData
|
|
595
597
|
|
596
598
|
if content_type == 'application/json' || content_type == 'application/json;charset=UTF-8'
|
597
599
|
result = response.to_str == '""' ? {} : MultiJson.load(response.to_str)
|
598
|
-
GoodData.
|
600
|
+
GoodData.rest_logger.debug "Request ID: #{response.headers[:x_gdc_request]} - Response: #{result.inspect}"
|
599
601
|
elsif ['text/plain;charset=UTF-8', 'text/plain; charset=UTF-8', 'text/plain'].include?(content_type)
|
600
602
|
result = response
|
601
|
-
GoodData.
|
603
|
+
GoodData.rest_logger.debug 'Response: plain text'
|
602
604
|
elsif content_type == 'application/zip'
|
603
605
|
result = response
|
604
|
-
GoodData.
|
606
|
+
GoodData.rest_logger.debug 'Response: a zipped stream'
|
605
607
|
elsif response.headers[:content_length].to_s == '0'
|
606
608
|
result = nil
|
607
|
-
GoodData.
|
609
|
+
GoodData.rest_logger.debug 'Response: Empty response possibly 204'
|
608
610
|
elsif response.code == 204
|
609
611
|
result = nil
|
610
|
-
GoodData.
|
612
|
+
GoodData.rest_logger.debug 'Response: 204 no content'
|
611
613
|
else
|
612
614
|
fail "Unsupported response content type '%s':\n%s" % [content_type, response.to_str[0..127]]
|
613
615
|
end
|
614
616
|
result
|
615
617
|
rescue RestClient::Exception => e
|
616
|
-
GoodData.logger.
|
618
|
+
GoodData.logger.error "Response: #{e.response}"
|
617
619
|
raise $ERROR_INFO
|
618
620
|
end
|
619
621
|
|