gooddata 0.6.20 → 0.6.22
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/DEPENDENCIES.md +816 -0
- data/LICENSE +1 -1
- data/LICENSE.rb +5 -0
- data/Rakefile +74 -22
- data/dependency_decisions.yml +102 -0
- data/gooddata.gemspec +39 -38
- data/lib/gooddata.rb +4 -0
- data/lib/gooddata/app/app.rb +4 -0
- data/lib/gooddata/bricks/base_downloader.rb +5 -1
- data/lib/gooddata/bricks/brick.rb +4 -0
- data/lib/gooddata/bricks/bricks.rb +5 -0
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/base_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/decode_params_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/fs_download_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +4 -0
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/undot_params_middleware.rb +4 -0
- data/lib/gooddata/bricks/pipeline.rb +4 -0
- data/lib/gooddata/bricks/utils.rb +4 -0
- data/lib/gooddata/cli/cli.rb +4 -0
- data/lib/gooddata/cli/commands/api_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/auth_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/console_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/domain_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/process_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/project_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/projects_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/user_cmd.rb +4 -0
- data/lib/gooddata/cli/hooks.rb +4 -0
- data/lib/gooddata/cli/shared.rb +4 -0
- data/lib/gooddata/cli/terminal.rb +4 -0
- data/lib/gooddata/client.rb +4 -0
- data/lib/gooddata/commands/api.rb +4 -0
- data/lib/gooddata/commands/auth.rb +4 -0
- data/lib/gooddata/commands/base.rb +4 -0
- data/lib/gooddata/commands/commands.rb +5 -0
- data/lib/gooddata/commands/datasets.rb +5 -1
- data/lib/gooddata/commands/datawarehouse.rb +4 -0
- data/lib/gooddata/commands/domain.rb +4 -0
- data/lib/gooddata/commands/process.rb +4 -0
- data/lib/gooddata/commands/project.rb +7 -9
- data/lib/gooddata/commands/projects.rb +4 -0
- data/lib/gooddata/commands/role.rb +4 -0
- data/lib/gooddata/commands/runners.rb +4 -0
- data/lib/gooddata/commands/scaffold.rb +4 -0
- data/lib/gooddata/commands/user.rb +4 -0
- data/lib/gooddata/connection.rb +83 -0
- data/lib/gooddata/core/core.rb +4 -0
- data/lib/gooddata/core/logging.rb +4 -0
- data/lib/gooddata/core/nil_logger.rb +4 -0
- data/lib/gooddata/core/project.rb +4 -0
- data/lib/gooddata/core/rest.rb +14 -16
- data/lib/gooddata/core/user.rb +4 -0
- data/lib/gooddata/data/data.rb +4 -0
- data/lib/gooddata/data/guesser.rb +4 -0
- data/lib/gooddata/exceptions/attr_element_not_found.rb +4 -0
- data/lib/gooddata/exceptions/command_failed.rb +4 -0
- data/lib/gooddata/exceptions/exceptions.rb +4 -0
- data/lib/gooddata/exceptions/execution_limit_exceeded.rb +4 -0
- data/lib/gooddata/exceptions/filter_maqlization.rb +16 -0
- data/lib/gooddata/exceptions/malformed_user.rb +15 -0
- data/lib/gooddata/exceptions/no_project_error.rb +4 -0
- data/lib/gooddata/exceptions/object_migration.rb +28 -0
- data/lib/gooddata/exceptions/project_not_found.rb +5 -0
- data/lib/gooddata/exceptions/uncomputable_report.rb +5 -0
- data/lib/gooddata/exceptions/user_in_different_domain.rb +4 -0
- data/lib/gooddata/exceptions/validation_error.rb +4 -0
- data/lib/gooddata/extensions/big_decimal.rb +4 -0
- data/lib/gooddata/extensions/enumerable.rb +4 -0
- data/lib/gooddata/extensions/extensions.rb +4 -0
- data/lib/gooddata/extensions/false.rb +4 -0
- data/lib/gooddata/extensions/hash.rb +4 -0
- data/lib/gooddata/extensions/nil.rb +4 -0
- data/lib/gooddata/extensions/numeric.rb +4 -0
- data/lib/gooddata/extensions/object.rb +4 -0
- data/lib/gooddata/extensions/symbol.rb +4 -0
- data/lib/gooddata/extensions/true.rb +4 -0
- data/lib/gooddata/extract.rb +4 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +87 -77
- data/lib/gooddata/helpers/auth_helpers.rb +6 -2
- data/lib/gooddata/helpers/csv_helper.rb +4 -0
- data/lib/gooddata/helpers/data_helper.rb +4 -0
- data/lib/gooddata/helpers/global_helpers.rb +35 -6
- data/lib/gooddata/helpers/global_helpers_params.rb +34 -7
- data/lib/gooddata/helpers/helpers.rb +4 -0
- data/lib/gooddata/mixins/author.rb +4 -0
- data/lib/gooddata/mixins/content_getter.rb +4 -0
- data/lib/gooddata/mixins/content_property_reader.rb +4 -0
- data/lib/gooddata/mixins/content_property_writer.rb +4 -0
- data/lib/gooddata/mixins/contributor.rb +4 -0
- data/lib/gooddata/mixins/data_getter.rb +4 -0
- data/lib/gooddata/mixins/data_property_reader.rb +4 -0
- data/lib/gooddata/mixins/data_property_writer.rb +4 -0
- data/lib/gooddata/mixins/inspector.rb +4 -0
- data/lib/gooddata/mixins/is_attribute.rb +4 -0
- data/lib/gooddata/mixins/is_dimension.rb +4 -0
- data/lib/gooddata/mixins/is_fact.rb +4 -0
- data/lib/gooddata/mixins/is_label.rb +4 -0
- data/lib/gooddata/mixins/links.rb +4 -0
- data/lib/gooddata/mixins/md_finders.rb +4 -0
- data/lib/gooddata/mixins/md_id_to_uri.rb +4 -0
- data/lib/gooddata/mixins/md_json.rb +4 -0
- data/lib/gooddata/mixins/md_lock.rb +4 -0
- data/lib/gooddata/mixins/md_object_id.rb +5 -1
- data/lib/gooddata/mixins/md_object_indexer.rb +4 -0
- data/lib/gooddata/mixins/md_object_query.rb +4 -0
- data/lib/gooddata/mixins/md_relations.rb +4 -0
- data/lib/gooddata/mixins/meta_getter.rb +4 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +4 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +4 -0
- data/lib/gooddata/mixins/mixins.rb +4 -0
- data/lib/gooddata/mixins/not_attribute.rb +4 -0
- data/lib/gooddata/mixins/not_exportable.rb +4 -0
- data/lib/gooddata/mixins/not_fact.rb +4 -0
- data/lib/gooddata/mixins/not_label.rb +4 -0
- data/lib/gooddata/mixins/not_metric.rb +6 -0
- data/lib/gooddata/mixins/obj_id.rb +4 -0
- data/lib/gooddata/mixins/rest_getters.rb +4 -0
- data/lib/gooddata/mixins/rest_resource.rb +4 -0
- data/lib/gooddata/mixins/root_key_getter.rb +4 -0
- data/lib/gooddata/mixins/root_key_setter.rb +4 -0
- data/lib/gooddata/mixins/timestamps.rb +4 -0
- data/lib/gooddata/models/blueprint/anchor_field.rb +4 -0
- data/lib/gooddata/models/blueprint/attribute_field.rb +4 -0
- data/lib/gooddata/models/blueprint/blueprint.rb +4 -0
- data/lib/gooddata/models/blueprint/blueprint_field.rb +4 -0
- data/lib/gooddata/models/blueprint/dashboard_builder.rb +4 -0
- data/lib/gooddata/models/blueprint/dataset_blueprint.rb +6 -0
- data/lib/gooddata/models/blueprint/date_dimension.rb +4 -0
- data/lib/gooddata/models/blueprint/fact_field.rb +4 -0
- data/lib/gooddata/models/blueprint/label_field.rb +4 -0
- data/lib/gooddata/models/blueprint/project_blueprint.rb +6 -0
- data/lib/gooddata/models/blueprint/project_builder.rb +4 -0
- data/lib/gooddata/models/blueprint/reference_field.rb +4 -0
- data/lib/gooddata/models/blueprint/schema_blueprint.rb +4 -0
- data/lib/gooddata/models/blueprint/schema_builder.rb +4 -0
- data/lib/gooddata/models/blueprint/to_manifest.rb +17 -1
- data/lib/gooddata/models/blueprint/to_wire.rb +4 -0
- data/lib/gooddata/models/datawarehouse.rb +5 -0
- data/lib/gooddata/models/domain.rb +25 -7
- data/lib/gooddata/models/execution.rb +4 -0
- data/lib/gooddata/models/execution_detail.rb +4 -0
- data/lib/gooddata/models/from_wire.rb +4 -0
- data/lib/gooddata/models/invitation.rb +4 -0
- data/lib/gooddata/models/links.rb +4 -0
- data/lib/gooddata/models/membership.rb +4 -0
- data/lib/gooddata/models/metadata.rb +37 -10
- data/lib/gooddata/models/metadata/attribute.rb +6 -0
- data/lib/gooddata/models/metadata/dashboard.rb +54 -16
- data/lib/gooddata/models/metadata/dashboard/dashboard_item.rb +60 -0
- data/lib/gooddata/models/metadata/dashboard/filter_item.rb +15 -0
- data/lib/gooddata/models/metadata/dashboard/report_item.rb +51 -0
- data/lib/gooddata/models/metadata/dashboard_tab.rb +88 -0
- data/lib/gooddata/models/metadata/dataset.rb +4 -0
- data/lib/gooddata/models/metadata/dimension.rb +4 -0
- data/lib/gooddata/models/metadata/fact.rb +6 -0
- data/lib/gooddata/models/metadata/label.rb +15 -0
- data/lib/gooddata/models/metadata/metadata.rb +4 -0
- data/lib/gooddata/models/metadata/metric.rb +5 -4
- data/lib/gooddata/models/metadata/report.rb +62 -16
- data/lib/gooddata/models/metadata/report_definition.rb +44 -47
- data/lib/gooddata/models/metadata/variable.rb +4 -0
- data/lib/gooddata/models/model.rb +85 -36
- data/lib/gooddata/models/models.rb +4 -0
- data/lib/gooddata/models/module_constants.rb +4 -0
- data/lib/gooddata/models/process.rb +4 -0
- data/lib/gooddata/models/profile.rb +13 -0
- data/lib/gooddata/models/project.rb +173 -92
- data/lib/gooddata/models/project_creator.rb +18 -10
- data/lib/gooddata/models/project_metadata.rb +4 -0
- data/lib/gooddata/models/project_role.rb +4 -0
- data/lib/gooddata/models/report_data_result.rb +217 -125
- data/lib/gooddata/models/schedule.rb +140 -65
- data/lib/gooddata/models/tab_builder.rb +4 -0
- data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +4 -0
- data/lib/gooddata/models/user_filters/user_filter.rb +4 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +98 -56
- data/lib/gooddata/models/user_filters/user_filters.rb +4 -0
- data/lib/gooddata/models/user_filters/variable_user_filter.rb +4 -0
- data/lib/gooddata/rest/client.rb +41 -38
- data/lib/gooddata/rest/connection.rb +91 -20
- data/lib/gooddata/rest/connections/rest_client_connection.rb +5 -1
- data/lib/gooddata/rest/object.rb +9 -1
- data/lib/gooddata/rest/object_factory.rb +5 -1
- data/lib/gooddata/rest/resource.rb +5 -1
- data/lib/gooddata/rest/rest.rb +4 -0
- data/lib/gooddata/version.rb +5 -1
- data/spec/bricks/bricks_spec.rb +4 -0
- data/spec/data/blueprints/test_project_model_spec.json +2 -2
- data/spec/data/gooddata_version_process/gooddata_version.rb +6 -0
- data/spec/data/hello_world_process/hello_world.rb +6 -0
- data/spec/data/manifests/test_project.json +5 -5
- data/spec/data/reports/left_attr_report.json +108 -0
- data/spec/data/reports/metric_only_one_line.json +83 -0
- data/spec/data/reports/report_1.json +197 -0
- data/spec/data/reports/top_attr_report.json +108 -0
- data/spec/data/ruby_params_process/ruby_params.rb +6 -0
- data/spec/data/ruby_process/process.rb +6 -0
- data/spec/environment/default.rb +5 -0
- data/spec/environment/develop.rb +10 -5
- data/spec/environment/environment.rb +4 -0
- data/spec/environment/hotfix.rb +5 -1
- data/spec/environment/production.rb +4 -0
- data/spec/environment/release.rb +4 -0
- data/spec/environment/staging.rb +30 -0
- data/spec/environment/staging_3.rb +37 -0
- data/spec/helpers/blueprint_helper.rb +4 -0
- data/spec/helpers/cli_helper.rb +4 -0
- data/spec/helpers/connection_helper.rb +24 -17
- data/spec/helpers/crypto_helper.rb +6 -0
- data/spec/helpers/csv_helper.rb +4 -0
- data/spec/helpers/process_helper.rb +5 -1
- data/spec/helpers/project_helper.rb +34 -29
- data/spec/helpers/schedule_helper.rb +4 -0
- data/spec/helpers/spec_helper.rb +4 -0
- data/spec/integration/blueprint_updates_spec.rb +28 -20
- data/spec/integration/command_datawarehouse_spec.rb +6 -0
- data/spec/integration/command_projects_spec.rb +6 -4
- data/spec/integration/create_from_template_spec.rb +6 -0
- data/spec/integration/create_project_spec.rb +6 -0
- data/spec/integration/deprecated_load_spec.rb +58 -0
- data/spec/integration/full_process_schedule_spec.rb +9 -0
- data/spec/integration/full_project_spec.rb +63 -9
- data/spec/integration/over_to_user_filters_spec.rb +7 -2
- data/spec/integration/partial_md_export_import_spec.rb +6 -0
- data/spec/integration/project_spec.rb +12 -6
- data/spec/integration/rest_spec.rb +6 -2
- data/spec/integration/schedule_spec.rb +627 -0
- data/spec/integration/user_filters_spec.rb +122 -21
- data/spec/integration/variables_spec.rb +8 -15
- data/spec/logging_in_logging_out_spec.rb +58 -0
- data/spec/spec_helper.rb +10 -5
- data/spec/unit/bricks/bricks_spec.rb +4 -0
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +4 -0
- data/spec/unit/cli/cli_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_api_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_auth_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_domain_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_process_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_project_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_role_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +6 -0
- data/spec/unit/cli/commands/cmd_user_spec.rb +6 -0
- data/spec/unit/commands/command_api_spec.rb +6 -0
- data/spec/unit/commands/command_auth_spec.rb +6 -0
- data/spec/unit/commands/command_dataset_spec.rb +10 -4
- data/spec/unit/commands/command_process_spec.rb +6 -0
- data/spec/unit/commands/command_projects_spec.rb +6 -0
- data/spec/unit/commands/command_scaffold_spec.rb +6 -0
- data/spec/unit/commands/command_user_spec.rb +6 -0
- data/spec/unit/core/connection_spec.rb +6 -0
- data/spec/unit/core/logging_spec.rb +4 -0
- data/spec/unit/core/nil_logger_spec.rb +4 -0
- data/spec/unit/core/project_spec.rb +4 -0
- data/spec/unit/data/guesser_spec.rb +6 -2
- data/spec/unit/extensions/hash_spec.rb +4 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +4 -0
- data/spec/unit/helpers/csv_helper_spec.rb +4 -0
- data/spec/unit/helpers/data_helper_spec.rb +4 -0
- data/spec/unit/helpers/global_helpers_spec.rb +54 -0
- data/spec/unit/helpers_spec.rb +6 -1
- data/spec/unit/models/blueprint/attributes_spec.rb +5 -0
- data/spec/unit/models/blueprint/dataset_spec.rb +5 -0
- data/spec/unit/models/blueprint/labels_spec.rb +5 -0
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +5 -0
- data/spec/unit/models/blueprint/reference_spec.rb +5 -0
- data/spec/unit/models/blueprint/schema_builder_spec.rb +4 -0
- data/spec/unit/models/blueprint/to_wire_spec.rb +5 -0
- data/spec/unit/models/domain_spec.rb +9 -7
- data/spec/unit/models/execution_spec.rb +6 -0
- data/spec/unit/models/from_wire_spec.rb +4 -0
- data/spec/unit/models/invitation_spec.rb +4 -0
- data/spec/unit/models/membership_spec.rb +4 -0
- data/spec/unit/models/metadata_spec.rb +46 -0
- data/spec/unit/models/metric_spec.rb +4 -0
- data/spec/unit/models/model_spec.rb +4 -0
- data/spec/unit/models/params_spec.rb +4 -0
- data/spec/unit/models/profile_spec.rb +4 -0
- data/spec/unit/models/project_creator_spec.rb +127 -0
- data/spec/unit/models/project_role_spec.rb +4 -0
- data/spec/unit/models/project_spec.rb +4 -0
- data/spec/unit/models/report_result_data_spec.rb +193 -0
- data/spec/unit/models/schedule_spec.rb +241 -386
- data/spec/unit/models/to_manifest_spec.rb +21 -0
- data/spec/unit/models/{unit_project.rb → unit_project_spec.rb} +21 -18
- data/spec/unit/models/user_filters_spec.rb +7 -1
- data/spec/unit/models/variable_spec.rb +6 -0
- data/spec/unit/rest/polling_spec.rb +8 -5
- data/spec/unit/rest/resource_spec.rb +4 -0
- metadata +190 -129
- data/.autotest +0 -2
- data/.travis.yml +0 -22
- data/examples.rb +0 -69
- data/lib/gooddata/models/data_result.rb +0 -38
- data/lib/gooddata/models/empty_result.rb +0 -57
- data/spec/unit/models/project_creator.rb +0 -73
data/lib/gooddata/rest/client.rb
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
require 'rest-client'
|
|
4
8
|
|
|
@@ -61,7 +65,7 @@ module GoodData
|
|
|
61
65
|
# @param username [String] Username to be used for authentication
|
|
62
66
|
# @param password [String] Password to be used for authentication
|
|
63
67
|
# @return [GoodData::Rest::Client] Client
|
|
64
|
-
def connect(username, password, opts = {
|
|
68
|
+
def connect(username, password = 'aaaa', opts = {})
|
|
65
69
|
if username.nil? && password.nil?
|
|
66
70
|
username = ENV['GD_GEM_USER']
|
|
67
71
|
password = ENV['GD_GEM_PASSWORD']
|
|
@@ -71,25 +75,35 @@ module GoodData
|
|
|
71
75
|
|
|
72
76
|
new_opts = opts.dup
|
|
73
77
|
if username.is_a?(Hash) && username.key?(:sst_token)
|
|
74
|
-
new_opts = username
|
|
78
|
+
new_opts = new_opts.merge(username)
|
|
75
79
|
elsif username.is_a? Hash
|
|
80
|
+
new_opts = new_opts.merge(username)
|
|
76
81
|
new_opts[:username] = username[:login] || username[:user] || username[:username]
|
|
77
82
|
new_opts[:password] = username[:password]
|
|
78
|
-
|
|
79
|
-
elsif username.nil? && password.nil? && (opts.nil? || opts.empty?)
|
|
83
|
+
elsif username.nil? && password.nil? && opts.blank?
|
|
80
84
|
new_opts = Helpers::AuthHelper.read_credentials
|
|
81
85
|
else
|
|
82
86
|
new_opts[:username] = username
|
|
83
87
|
new_opts[:password] = password
|
|
84
88
|
end
|
|
89
|
+
|
|
90
|
+
new_opts = { verify_ssl: true }.merge(new_opts)
|
|
91
|
+
if username.is_a?(Hash) && username[:cookies]
|
|
92
|
+
new_opts[:sst_token] = username[:cookies]['GDCAuthSST']
|
|
93
|
+
new_opts[:cookies] = username[:cookies]
|
|
94
|
+
end
|
|
95
|
+
|
|
85
96
|
unless new_opts[:sst_token]
|
|
86
97
|
fail ArgumentError, 'No username specified' if new_opts[:username].nil?
|
|
87
98
|
fail ArgumentError, 'No password specified' if new_opts[:password].nil?
|
|
88
99
|
end
|
|
100
|
+
|
|
89
101
|
if username.is_a?(Hash) && username.key?(:server)
|
|
90
102
|
new_opts[:server] = username[:server]
|
|
91
103
|
end
|
|
104
|
+
|
|
92
105
|
client = Client.new(new_opts)
|
|
106
|
+
GoodData.logger.info("Connected to server with webdav path #{client.user_webdav_path}")
|
|
93
107
|
|
|
94
108
|
if client
|
|
95
109
|
at_exit do
|
|
@@ -99,6 +113,10 @@ module GoodData
|
|
|
99
113
|
|
|
100
114
|
# HACK: This line assigns class instance # if not done yet
|
|
101
115
|
@@instance = client # rubocop:disable ClassVars
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def connect_sso(sso)
|
|
119
|
+
client = Client.new(sso)
|
|
102
120
|
client
|
|
103
121
|
end
|
|
104
122
|
|
|
@@ -157,7 +175,9 @@ module GoodData
|
|
|
157
175
|
end
|
|
158
176
|
|
|
159
177
|
def project_is_accessible?(id)
|
|
160
|
-
projects(id) && true
|
|
178
|
+
projects(id) && true
|
|
179
|
+
rescue
|
|
180
|
+
true
|
|
161
181
|
end
|
|
162
182
|
|
|
163
183
|
def projects(id = :all)
|
|
@@ -251,15 +271,14 @@ module GoodData
|
|
|
251
271
|
url
|
|
252
272
|
end
|
|
253
273
|
|
|
254
|
-
def user_webdav_path
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
URI.join(u.to_s.chomp(u.path.to_s), '/uploads/')
|
|
274
|
+
def user_webdav_path
|
|
275
|
+
uri = if opts[:webdav_server]
|
|
276
|
+
opts[:webdav_server]
|
|
277
|
+
else
|
|
278
|
+
links.find { |i| i['category'] == 'uploads' }['link']
|
|
279
|
+
end
|
|
280
|
+
res = uri.chomp('/') + '/'
|
|
281
|
+
res[0] == '/' ? "#{connection.server}#{res}" : res
|
|
263
282
|
end
|
|
264
283
|
|
|
265
284
|
# Generalizaton of poller. Since we have quite a variation of how async proceses are handled
|
|
@@ -298,9 +317,10 @@ module GoodData
|
|
|
298
317
|
def poll_on_response(link, options = {}, &bl)
|
|
299
318
|
sleep_interval = options[:sleep_interval] || DEFAULT_SLEEP_INTERVAL
|
|
300
319
|
time_limit = options[:time_limit] || DEFAULT_POLL_TIME_LIMIT
|
|
320
|
+
process = options[:process] == false ? false : true
|
|
301
321
|
|
|
302
322
|
# get the first status and start the timer
|
|
303
|
-
response = get(link,
|
|
323
|
+
response = get(link, process: process)
|
|
304
324
|
poll_start = Time.now
|
|
305
325
|
|
|
306
326
|
while bl.call(response)
|
|
@@ -310,7 +330,7 @@ module GoodData
|
|
|
310
330
|
end
|
|
311
331
|
sleep sleep_interval
|
|
312
332
|
GoodData::Rest::Client.retryable(:tries => 3, :refresh_token => proc { connection.refresh_token }) do
|
|
313
|
-
response = get(link,
|
|
333
|
+
response = get(link, process: process)
|
|
314
334
|
end
|
|
315
335
|
end
|
|
316
336
|
response
|
|
@@ -349,37 +369,20 @@ module GoodData
|
|
|
349
369
|
|
|
350
370
|
def download_from_user_webdav(source_relative_path, target_file_path, options = { client: GoodData.client, project: project })
|
|
351
371
|
download(source_relative_path, target_file_path, options.merge(:directory => options[:directory],
|
|
352
|
-
:staging_url =>
|
|
372
|
+
:staging_url => user_webdav_path))
|
|
353
373
|
end
|
|
354
374
|
|
|
355
375
|
def upload_to_user_webdav(file, options = {})
|
|
356
376
|
upload(file, options.merge(:directory => options[:directory],
|
|
357
|
-
:staging_url =>
|
|
377
|
+
:staging_url => user_webdav_path))
|
|
358
378
|
end
|
|
359
379
|
|
|
360
380
|
def with_project(pid, &block)
|
|
361
381
|
GoodData.with_project(pid, client: self, &block)
|
|
362
382
|
end
|
|
363
383
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
private
|
|
367
|
-
|
|
368
|
-
def get_user_webdav_url(options = {})
|
|
369
|
-
p = options[:project]
|
|
370
|
-
fail ArgumentError, 'No :project specified' if p.nil?
|
|
371
|
-
|
|
372
|
-
project = options[:project] || GoodData::Project[p, options]
|
|
373
|
-
fail ArgumentError, 'Wrong :project specified' if project.nil?
|
|
374
|
-
|
|
375
|
-
u = URI(project.links['uploads'])
|
|
376
|
-
us = u.to_s
|
|
377
|
-
ws = options[:client].opts[:webdav_server]
|
|
378
|
-
if !us.empty? && !us.downcase.start_with?('http') && !ws.empty?
|
|
379
|
-
u = URI.join(ws, us)
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
URI.join(u.to_s.chomp(u.path.to_s), '/uploads/')
|
|
384
|
+
def links
|
|
385
|
+
GoodData::Helpers.get_path(get('/gdc'), %w(about links))
|
|
383
386
|
end
|
|
384
387
|
end
|
|
385
388
|
end
|
|
@@ -1,13 +1,59 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
require 'terminal-table'
|
|
4
8
|
require 'securerandom'
|
|
5
9
|
require 'monitor'
|
|
6
10
|
require 'thread_safe'
|
|
11
|
+
require 'rest-client'
|
|
7
12
|
|
|
8
13
|
require_relative '../version'
|
|
9
14
|
require_relative '../exceptions/exceptions'
|
|
10
15
|
|
|
16
|
+
module RestClient
|
|
17
|
+
module AbstractResponse
|
|
18
|
+
alias_method :old_follow_redirection, :follow_redirection
|
|
19
|
+
def follow_redirection(request = nil, result = nil, &block)
|
|
20
|
+
fail 'Using monkey patched version of RestClient::AbstractResponse#follow_redirection which is guaranteed to be compatible only with RestClient 1.8.0' if RestClient::VERSION != '1.8.0'
|
|
21
|
+
|
|
22
|
+
# @args[:cookies] = request.cookies
|
|
23
|
+
# old_follow_redirection(request, result, &block)
|
|
24
|
+
|
|
25
|
+
new_args = @args.dup
|
|
26
|
+
|
|
27
|
+
url = headers[:location]
|
|
28
|
+
url = URI.parse(request.url).merge(url).to_s if url !~ /^http/
|
|
29
|
+
|
|
30
|
+
new_args[:url] = url
|
|
31
|
+
if request
|
|
32
|
+
fail MaxRedirectsReached if request.max_redirects == 0
|
|
33
|
+
new_args[:password] = request.password
|
|
34
|
+
new_args[:user] = request.user
|
|
35
|
+
new_args[:headers] = request.headers
|
|
36
|
+
new_args[:max_redirects] = request.max_redirects - 1
|
|
37
|
+
|
|
38
|
+
# TODO: figure out what to do with original :cookie, :cookies values
|
|
39
|
+
new_args[:cookies] = get_redirection_cookies(request, result, new_args)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Request.execute(new_args, &block)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Returns cookies which should be passed when following redirect
|
|
46
|
+
#
|
|
47
|
+
# @param request [RestClient::Request] Original request
|
|
48
|
+
# @param result [Net::HTTPResponse] Response
|
|
49
|
+
# @param args [Hash] Original arguments
|
|
50
|
+
# @return [Hash] Cookies to be passsed when following redirect
|
|
51
|
+
def get_redirection_cookies(request, _result, _args)
|
|
52
|
+
request.cookies
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
11
57
|
module GoodData
|
|
12
58
|
module Rest
|
|
13
59
|
# Wrapper of low-level HTTP/REST client/library
|
|
@@ -19,6 +65,8 @@ module GoodData
|
|
|
19
65
|
TOKEN_PATH = '/gdc/account/token'
|
|
20
66
|
KEYS_TO_SCRUB = [:password, :verifyPassword, :authorizationToken]
|
|
21
67
|
|
|
68
|
+
ID_LENGTH = 16
|
|
69
|
+
|
|
22
70
|
DEFAULT_HEADERS = {
|
|
23
71
|
:content_type => :json,
|
|
24
72
|
:accept => [:json, :zip],
|
|
@@ -42,7 +90,7 @@ module GoodData
|
|
|
42
90
|
Timeout::Error
|
|
43
91
|
]
|
|
44
92
|
|
|
45
|
-
RETRIES_ON_TOO_MANY_REQUESTS_ERROR =
|
|
93
|
+
RETRIES_ON_TOO_MANY_REQUESTS_ERROR = 12
|
|
46
94
|
RETRY_TIME_INITIAL_VALUE = 1
|
|
47
95
|
RETRY_TIME_COEFFICIENT = 1.5
|
|
48
96
|
RETRYABLE_ERRORS << Net::ReadTimeout if Net.const_defined?(:ReadTimeout)
|
|
@@ -59,6 +107,15 @@ module GoodData
|
|
|
59
107
|
res
|
|
60
108
|
end
|
|
61
109
|
|
|
110
|
+
# Generate random string with URL safe base64 encoding
|
|
111
|
+
#
|
|
112
|
+
# @param [String] length Length of random string to be generated
|
|
113
|
+
#
|
|
114
|
+
# @return [String] Generated random string
|
|
115
|
+
def generate_string(length = ID_LENGTH)
|
|
116
|
+
SecureRandom.urlsafe_base64(length)
|
|
117
|
+
end
|
|
118
|
+
|
|
62
119
|
# Retry block if exception thrown
|
|
63
120
|
def retryable(options = {}, &_block)
|
|
64
121
|
opts = { :tries => 1, :on => RETRYABLE_ERRORS }.merge(options)
|
|
@@ -125,7 +182,6 @@ module GoodData
|
|
|
125
182
|
headers = options[:headers] || {}
|
|
126
183
|
|
|
127
184
|
options = options.merge(headers)
|
|
128
|
-
|
|
129
185
|
@server = RestClient::Resource.new server, options
|
|
130
186
|
|
|
131
187
|
# Install at_exit handler first
|
|
@@ -142,17 +198,29 @@ module GoodData
|
|
|
142
198
|
# Reset old cookies first
|
|
143
199
|
if options[:sst_token]
|
|
144
200
|
merge_cookies!('GDCAuthSST' => options[:sst_token])
|
|
201
|
+
get('/gdc/account/token', @request_params)
|
|
202
|
+
|
|
145
203
|
@user = get(get('/gdc/app/account/bootstrap')['bootstrapResource']['accountSetting']['links']['self'])
|
|
204
|
+
GoodData.logger.info("Connected using SST to server #{@server.url} to profile \"#{@user['accountSetting']['login']}\"")
|
|
146
205
|
@auth = {}
|
|
147
206
|
refresh_token :dont_reauth => true
|
|
148
207
|
else
|
|
208
|
+
GoodData.logger.info("Connected using username \"#{username}\" to server #{@server.url}")
|
|
149
209
|
credentials = Connection.construct_login_payload(username, password)
|
|
150
210
|
generate_session_id
|
|
151
|
-
@auth = post(LOGIN_PATH, credentials)['userLogin']
|
|
211
|
+
@auth = post(LOGIN_PATH, credentials, :dont_reauth => true)['userLogin']
|
|
152
212
|
|
|
153
213
|
refresh_token :dont_reauth => true
|
|
154
214
|
@user = get(@auth['profile'])
|
|
155
215
|
end
|
|
216
|
+
GoodData.logger.info('Connection successful')
|
|
217
|
+
rescue RestClient::Unauthorized => e
|
|
218
|
+
GoodData.logger.info('Bad Login or Password')
|
|
219
|
+
GoodData.logger.info('Connection failed')
|
|
220
|
+
raise e
|
|
221
|
+
rescue RestClient::Forbidden => e
|
|
222
|
+
GoodData.logger.info('Connection failed')
|
|
223
|
+
raise e
|
|
156
224
|
end
|
|
157
225
|
|
|
158
226
|
# Disconnect
|
|
@@ -270,7 +338,7 @@ module GoodData
|
|
|
270
338
|
@server[uri].delete(params)
|
|
271
339
|
rescue RestClient::Exception => e
|
|
272
340
|
# log the error if it happens
|
|
273
|
-
|
|
341
|
+
log_error(e, uri, params)
|
|
274
342
|
raise e
|
|
275
343
|
end
|
|
276
344
|
end
|
|
@@ -278,6 +346,16 @@ module GoodData
|
|
|
278
346
|
end
|
|
279
347
|
end
|
|
280
348
|
|
|
349
|
+
# Helper for logging error
|
|
350
|
+
#
|
|
351
|
+
# @param e [RuntimeException] Exception to log
|
|
352
|
+
# @param uri [String] Uri on which the request failed
|
|
353
|
+
# @param uri [Hash] Additional params
|
|
354
|
+
def log_error(e, uri, params)
|
|
355
|
+
return if e.response && e.response.code == 401 && !uri.include?('token') && !uri.include?('login')
|
|
356
|
+
GoodData.logger.error(format_error(e, params))
|
|
357
|
+
end
|
|
358
|
+
|
|
281
359
|
# HTTP GET
|
|
282
360
|
#
|
|
283
361
|
# @param uri [String] Target URI
|
|
@@ -291,7 +369,7 @@ module GoodData
|
|
|
291
369
|
@server[uri].get(params, &user_block)
|
|
292
370
|
rescue RestClient::Exception => e
|
|
293
371
|
# log the error if it happens
|
|
294
|
-
|
|
372
|
+
log_error(e, uri, params)
|
|
295
373
|
raise e
|
|
296
374
|
end
|
|
297
375
|
end
|
|
@@ -313,7 +391,7 @@ module GoodData
|
|
|
313
391
|
@server[uri].put(payload, params)
|
|
314
392
|
rescue RestClient::Exception => e
|
|
315
393
|
# log the error if it happens
|
|
316
|
-
|
|
394
|
+
log_error(e, uri, params)
|
|
317
395
|
raise e
|
|
318
396
|
end
|
|
319
397
|
end
|
|
@@ -335,7 +413,7 @@ module GoodData
|
|
|
335
413
|
@server[uri].post(payload, params)
|
|
336
414
|
rescue RestClient::Exception => e
|
|
337
415
|
# log the error if it happens
|
|
338
|
-
|
|
416
|
+
log_error(e, uri, params)
|
|
339
417
|
raise e
|
|
340
418
|
end
|
|
341
419
|
end
|
|
@@ -379,7 +457,6 @@ module GoodData
|
|
|
379
457
|
dir = options[:directory] || ''
|
|
380
458
|
staging_uri = options[:staging_url].to_s
|
|
381
459
|
url = dir.empty? ? staging_uri : URI.join(staging_uri, "#{dir}/").to_s
|
|
382
|
-
|
|
383
460
|
# Make a directory, if needed
|
|
384
461
|
create_webdav_dir_if_needed url unless dir.empty?
|
|
385
462
|
|
|
@@ -393,8 +470,6 @@ module GoodData
|
|
|
393
470
|
|
|
394
471
|
private
|
|
395
472
|
|
|
396
|
-
ID_LENGTH = 16
|
|
397
|
-
|
|
398
473
|
def create_webdav_dir_if_needed(url)
|
|
399
474
|
return if webdav_dir_exists?(url)
|
|
400
475
|
|
|
@@ -438,22 +513,18 @@ module GoodData
|
|
|
438
513
|
"#{params[:x_gdc_request]} #{e.inspect}"
|
|
439
514
|
end
|
|
440
515
|
|
|
441
|
-
def generate_string
|
|
442
|
-
SecureRandom.urlsafe_base64(ID_LENGTH)
|
|
443
|
-
end
|
|
444
|
-
|
|
445
516
|
# generate session id to be passed as the first part to
|
|
446
517
|
# x_gdc_request header
|
|
447
518
|
def session_id
|
|
448
|
-
@session_id ||= generate_string
|
|
519
|
+
@session_id ||= Connection.generate_string
|
|
449
520
|
end
|
|
450
521
|
|
|
451
522
|
def call_id
|
|
452
|
-
generate_string
|
|
523
|
+
Connection.generate_string
|
|
453
524
|
end
|
|
454
525
|
|
|
455
526
|
def generate_session_id
|
|
456
|
-
@session_id = generate_string
|
|
527
|
+
@session_id = Connection.generate_string
|
|
457
528
|
end
|
|
458
529
|
|
|
459
530
|
def clear_session_id
|
|
@@ -481,8 +552,8 @@ module GoodData
|
|
|
481
552
|
|
|
482
553
|
def process_response(options = {}, &block)
|
|
483
554
|
retries = options[:tries] || 3
|
|
484
|
-
|
|
485
|
-
response = GoodData::Rest::Connection.retryable(
|
|
555
|
+
opts = { tries: retries, refresh_token: proc { refresh_token unless options[:dont_reauth] } }.merge(options)
|
|
556
|
+
response = GoodData::Rest::Connection.retryable(opts) do
|
|
486
557
|
block.call
|
|
487
558
|
end
|
|
488
559
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
require_relative '../connection'
|
|
4
8
|
|
data/lib/gooddata/rest/object.rb
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
module GoodData
|
|
4
8
|
module Rest
|
|
@@ -19,6 +23,10 @@ module GoodData
|
|
|
19
23
|
@client || GoodData::Rest::Object.client(opts)
|
|
20
24
|
end
|
|
21
25
|
|
|
26
|
+
def saved?
|
|
27
|
+
!uri.blank?
|
|
28
|
+
end
|
|
29
|
+
|
|
22
30
|
class << self
|
|
23
31
|
def default_client
|
|
24
32
|
end
|