gooddata 0.6.51 → 0.6.52

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.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +13 -1
  4. data/CONTRIBUTING.md +25 -0
  5. data/PULL_REQUEST_TEMPLATE.md +5 -0
  6. data/README.md +7 -4
  7. data/gooddata.gemspec +2 -3
  8. data/lib/gooddata.rb +1 -0
  9. data/lib/gooddata/bricks/base_downloader.rb +6 -6
  10. data/lib/gooddata/bricks/middleware/aws_middleware.rb +15 -5
  11. data/lib/gooddata/bricks/middleware/dwh_middleware.rb +15 -3
  12. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +13 -4
  13. data/lib/gooddata/bricks/middleware/logger_middleware.rb +3 -0
  14. data/lib/gooddata/exceptions/no_project_error.rb +5 -1
  15. data/lib/gooddata/goodzilla/goodzilla.rb +7 -6
  16. data/lib/gooddata/helpers/data_helper.rb +4 -4
  17. data/lib/gooddata/helpers/global_helpers_params.rb +61 -39
  18. data/lib/gooddata/lcm/actions/apply_custom_maql.rb +9 -0
  19. data/lib/gooddata/lcm/actions/associate_clients.rb +23 -4
  20. data/lib/gooddata/lcm/actions/collect_attrs.rb +56 -0
  21. data/lib/gooddata/lcm/actions/collect_ca_metrics.rb +53 -0
  22. data/lib/gooddata/lcm/actions/collect_clients.rb +25 -3
  23. data/lib/gooddata/lcm/actions/collect_meta.rb +83 -0
  24. data/lib/gooddata/lcm/actions/collect_segment_clients.rb +12 -4
  25. data/lib/gooddata/lcm/actions/collect_segments.rb +4 -4
  26. data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +74 -0
  27. data/lib/gooddata/lcm/actions/create_segment_masters.rb +16 -30
  28. data/lib/gooddata/lcm/actions/ensure_release_table.rb +0 -3
  29. data/lib/gooddata/lcm/actions/ensure_segments.rb +1 -4
  30. data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +5 -5
  31. data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +8 -5
  32. data/lib/gooddata/lcm/actions/hello_world.rb +0 -3
  33. data/lib/gooddata/lcm/actions/import_object_collections.rb +60 -0
  34. data/lib/gooddata/lcm/actions/print_actions.rb +0 -3
  35. data/lib/gooddata/lcm/actions/print_modes.rb +0 -3
  36. data/lib/gooddata/lcm/actions/print_types.rb +1 -4
  37. data/lib/gooddata/lcm/actions/provision_clients.rb +5 -5
  38. data/lib/gooddata/lcm/actions/purge_clients.rb +4 -10
  39. data/lib/gooddata/lcm/actions/segments_filter.rb +0 -6
  40. data/lib/gooddata/lcm/actions/synchronize_attribute_drillpaths.rb +8 -4
  41. data/lib/gooddata/lcm/actions/synchronize_cas.rb +61 -0
  42. data/lib/gooddata/lcm/actions/synchronize_clients.rb +9 -3
  43. data/lib/gooddata/lcm/actions/synchronize_color_palette.rb +13 -5
  44. data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +71 -17
  45. data/lib/gooddata/lcm/actions/synchronize_label_types.rb +8 -5
  46. data/lib/gooddata/lcm/actions/synchronize_ldm.rb +17 -8
  47. data/lib/gooddata/lcm/actions/synchronize_meta.rb +0 -3
  48. data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +9 -4
  49. data/lib/gooddata/lcm/actions/synchronize_processes.rb +9 -5
  50. data/lib/gooddata/lcm/actions/synchronize_schedules.rb +15 -5
  51. data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +61 -0
  52. data/lib/gooddata/lcm/actions/update_release_table.rb +0 -3
  53. data/lib/gooddata/lcm/helpers/tags_helper.rb +35 -0
  54. data/lib/gooddata/lcm/lcm.rb +22 -4
  55. data/lib/gooddata/lcm/lcm2.rb +66 -13
  56. data/lib/gooddata/lcm/types/complex/update_preference.rb +1 -1
  57. data/lib/gooddata/mixins/md_finders.rb +4 -2
  58. data/lib/gooddata/mixins/md_object_indexer.rb +13 -3
  59. data/lib/gooddata/mixins/md_object_query.rb +8 -2
  60. data/lib/gooddata/models/blueprint/date_dimension.rb +6 -0
  61. data/lib/gooddata/models/blueprint/project_blueprint.rb +41 -11
  62. data/lib/gooddata/models/blueprint/project_builder.rb +20 -0
  63. data/lib/gooddata/models/blueprint/to_wire.rb +7 -0
  64. data/lib/gooddata/models/client.rb +6 -0
  65. data/lib/gooddata/models/domain.rb +6 -6
  66. data/lib/gooddata/models/from_wire.rb +5 -1
  67. data/lib/gooddata/models/metadata.rb +55 -9
  68. data/lib/gooddata/models/metadata/attribute.rb +19 -4
  69. data/lib/gooddata/models/metadata/dashboard.rb +15 -3
  70. data/lib/gooddata/models/metadata/dataset.rb +5 -2
  71. data/lib/gooddata/models/metadata/dimension.rb +4 -1
  72. data/lib/gooddata/models/metadata/fact.rb +9 -2
  73. data/lib/gooddata/models/metadata/folder.rb +4 -1
  74. data/lib/gooddata/models/metadata/metric.rb +11 -3
  75. data/lib/gooddata/models/metadata/report.rb +7 -2
  76. data/lib/gooddata/models/metadata/report_definition.rb +11 -4
  77. data/lib/gooddata/models/metadata/scheduled_mail.rb +4 -1
  78. data/lib/gooddata/models/metadata/variable.rb +7 -2
  79. data/lib/gooddata/models/model.rb +14 -3
  80. data/lib/gooddata/models/process.rb +10 -9
  81. data/lib/gooddata/models/project.rb +134 -36
  82. data/lib/gooddata/models/project_creator.rb +43 -20
  83. data/lib/gooddata/models/report_data_result.rb +6 -2
  84. data/lib/gooddata/models/schedule.rb +6 -3
  85. data/lib/gooddata/models/subscription.rb +8 -1
  86. data/lib/gooddata/models/user_filters/user_filter.rb +1 -0
  87. data/lib/gooddata/models/user_filters/user_filter_builder.rb +18 -4
  88. data/lib/gooddata/models/user_filters/variable_user_filter.rb +3 -1
  89. data/lib/gooddata/rest/client.rb +4 -6
  90. data/lib/gooddata/rest/connection.rb +10 -2
  91. data/lib/gooddata/version.rb +1 -1
  92. data/spec/data/blueprints/test_blueprint.json +1 -0
  93. data/spec/data/wire_models/test_blueprint.json +3 -0
  94. data/spec/data/workspace_table.csv +3 -0
  95. data/spec/environment/development.rb +4 -1
  96. data/spec/environment/environment.rb +1 -1
  97. data/spec/environment/staging.rb +5 -1
  98. data/spec/environment/testing.rb +5 -2
  99. data/spec/integration/blueprint_with_ca_spec.rb +56 -0
  100. data/spec/integration/clients_spec.rb +21 -0
  101. data/spec/integration/command_datawarehouse_spec.rb +7 -1
  102. data/spec/integration/create_from_template_spec.rb +9 -3
  103. data/spec/integration/project_spec.rb +7 -0
  104. data/spec/integration/segments_spec.rb +0 -53
  105. data/spec/integration/subscription_spec.rb +29 -4
  106. data/spec/integration/urn_date_dim_spec.rb +53 -0
  107. data/spec/integration/user_filters_spec.rb +6 -0
  108. data/spec/integration/variables_spec.rb +1 -2
  109. data/spec/spec_helper.rb +5 -30
  110. data/spec/unit/actions/collect_clients_spec.rb +38 -0
  111. data/spec/unit/actions/collect_meta_spec.rb +87 -0
  112. data/spec/unit/actions/collect_segment_clients_spec.rb +40 -0
  113. data/spec/unit/actions/collect_tagged_objects_spec.rb +110 -0
  114. data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +51 -0
  115. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +55 -1
  116. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +15 -0
  117. data/spec/unit/helpers/data_helper_spec.rb +3 -5
  118. data/spec/unit/helpers/global_helpers_spec.rb +29 -0
  119. data/spec/unit/helpers_spec.rb +18 -1
  120. data/spec/unit/models/blueprint/project_blueprint_spec.rb +1 -23
  121. data/spec/unit/models/domain_spec.rb +19 -0
  122. data/spec/unit/models/metadata_spec.rb +34 -0
  123. data/spec/unit/models/schedule_spec.rb +31 -0
  124. data/spec/unit/models/to_manifest_spec.rb +10 -2
  125. data/spec/unit/models/unit_project_spec.rb +6 -1
  126. data/spec/unit/rest/polling_spec.rb +13 -1
  127. metadata +49 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1715a4ba9d7203654418b0a275dd7eaf7e5e1dc
4
- data.tar.gz: 42547b8e7ccbef65b3a0c6b0cb276886c55adcd8
3
+ metadata.gz: 4b52bbc7d6883ecc03056e9bd3b8d40814b1c7e6
4
+ data.tar.gz: d9016a67965073aa35cc99d6285200b2217aafdb
5
5
  SHA512:
6
- metadata.gz: d8120afa7ca7037fbd372960fe2ad02e9d2dc92d2d9dd17ce614b3f8d2a9d4e12412fe6ee8c3c2bd9f1c67ffdbf7962c099f612ec10a625188e2dfe0b5f8f2c8
7
- data.tar.gz: a8485d9b645c943c91386111a4f4b6d12c66162d141bb747e4865761d2ca15ebdad92900d8ed6f3596ebdd55048af6c1ad3cf651049ccf04fb0e7b9edc2acfad
6
+ metadata.gz: 9c84503bccbc716e9a55fd77c2ceaa105ec3790fcf0af44282c01cc1704c0095bf65777a63ebea9e89d193806e349c4c081fdf8f235530c211f42716ae8da355
7
+ data.tar.gz: b8bd3acdca2aaac173bc92dbd9aef01c32a8b5f2a99267686b02e97d66d15521577e1cfedfa96814d5eb3cc3e7b42611945980871732eb5658e94cfcc4d3f531
@@ -35,7 +35,7 @@ HashSyntax:
35
35
  Enabled: false
36
36
 
37
37
  LineLength:
38
- Max: 323
38
+ Max: 180
39
39
 
40
40
  MethodLength:
41
41
  Enabled: false
@@ -1,6 +1,18 @@
1
1
  # GoodData Ruby SDK Changelog
2
2
 
3
3
  ## 0.6.52
4
+ - Add support for computed attribute in blueprint
5
+ - Fix bug with transfering schedules without their state
6
+ - Support segment-specific production tags (TMA-309)
7
+ - Rewrite deprecated schedule parameter "GRAPH" (TMA-453)
8
+ - Add parameter HTTP_LOGGING to LoggerMiddleware
9
+ - Resolve also hidden reference parameters (TMA-411)
10
+ - Support integer type id in Domain#clients (TMA-450)
11
+ - Support urn for date dimension (TMA-221)
12
+ - Implement "skip_actions" for LCM2
13
+ - Support MAQL DIFF API (TMA-219)
14
+ - Support for restricted flag
15
+ - Fix deployment via SDK on Windows
4
16
 
5
17
  ## 0.6.50
6
18
  - Add support for Email Notification Rules on Process
@@ -11,7 +23,7 @@
11
23
  - Handle export/import async task errors (TMA-231)
12
24
  - Support for custom color palette
13
25
  - Support for trasfering attribute drill paths
14
- - Implemented basic version of LCM2
26
+ - Implemented basic version of LCM2
15
27
  - Add more logging for user, user filter management
16
28
 
17
29
  ## 0.6.49
@@ -0,0 +1,25 @@
1
+ ### Contribution acceptance criteria
2
+
3
+ 1. The change is as small as possible. It fixes one specific issue or implements
4
+ one specific feature. Do not combine things, send separate pull requests if needed.
5
+ 1. Include proper tests and make all tests pass (unless it contains a test
6
+ exposing a bug in existing code). Every new class should have corresponding
7
+ unit tests, even if the class is exercised at a higher level, such as a feature test.
8
+ 1. Every bug-fix has a regression test.
9
+ 1. If you suspect a failing CI build is unrelated to your contribution, you may
10
+ try and restart the failing CI job or ask a developer to fix the
11
+ aforementioned failing test.
12
+ 1. Code conforms to this [style guide](https://github.com/bbatsov/ruby-style-guide).
13
+ 1. When writing tests, please follow [these guidelines](http://betterspecs.org/).
14
+ 1. Changes do not adversely degrade performance.
15
+ 1. Your PR contains a single commit (please use `git rebase -i` to squash commits)
16
+ 1. When writing commit messages, please follow
17
+ [these](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
18
+ [guidelines](http://chris.beams.io/posts/git-commit/).
19
+ 1. Your changes can merge without problems (if not please rebase if you're the
20
+ only one working on your feature branch, otherwise, merge `master`).
21
+ 1. If the pull request adds any new libraries, they should be in line with our
22
+ [license](/LICENSE).
23
+ 1. Use `GoodData.logger` for logging instead of `puts`.
24
+
25
+ _Based on [GitLab's contribution guide](https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md)._
@@ -0,0 +1,5 @@
1
+ ## Todos
2
+ - [ ] Tests
3
+ - [ ] Documentation
4
+ - [ ] Changelog
5
+ - [ ] Build passing
data/README.md CHANGED
@@ -36,7 +36,7 @@ If you are using gems just
36
36
  gem install gooddata
37
37
 
38
38
  ## Note on Patches/Pull Requests
39
-
39
+
40
40
  * Fork the project.
41
41
  * Make your feature addition or bug fix.
42
42
  * Add tests for it. This is important so I don't break it in a
@@ -47,15 +47,19 @@ If you are using gems just
47
47
  * run `rake cop` and make sure you did not introduce any new coding rules issues
48
48
  * Send us a pull request. Bonus points for topic branches.
49
49
 
50
+ ## Contributing
51
+
52
+ See our [contribution guidelines](/CONTRIBUTING.md).
53
+
50
54
  ## Credits
51
55
 
52
56
  **Originally started by**
53
57
 
54
- Pavel Kolesnikov [ <mailto:pavel@gooddata.com> / [@koles](http://twitter.com/koles) ]
58
+ Pavel Kolesnikov [ <mailto:pavel@gooddata.com> / [@koles](http://twitter.com/koles) ]
55
59
 
56
60
  **Actively developed and maintained by**
57
61
 
58
- - [Tomas Korcak](https://github.com/korczis) [ <mailto:korczis@gmail.com> / [@korczis](http://twitter.com/korczis) ]
62
+ - [Tomas Korcak](https://github.com/korczis) [ <mailto:korczis@gmail.com> / [@korczis](http://twitter.com/korczis) ]
59
63
  - [Tomas Svarovsky](https://github.com/fluke777) [ <mailto:svarovsky.tomas@gmail.com> / [@fluke777](http://twitter.com/fluke777) ]
60
64
 
61
65
  **Contributors**
@@ -72,4 +76,3 @@ For full contributor info see [contributors page](https://github.com/gooddata/go
72
76
  ## Copyright
73
77
 
74
78
  Copyright (c) 2010 - 2015 GoodData Corporation and Thomas Watson Steen. See LICENSE for details.
75
-
@@ -42,9 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.add_development_dependency 'ZenTest', '~> 4.11'
43
43
  s.add_development_dependency 'pry'
44
44
 
45
- s.add_dependency 'aws-sdk', '~> 2.7'
46
- s.add_dependency 'nokogiri', '~> 1.6.8'
47
- s.add_dependency 'aws-sdk-v1', '~> 1.45'
45
+ s.add_dependency 'aws-sdk', '~> 2.9', '>= 2.9.42'
48
46
  s.add_dependency 'docile', '~> 1.1'
49
47
  s.add_dependency 'erubis', '~> 2.7'
50
48
  s.add_dependency 'gli', '~> 2.15'
@@ -61,4 +59,5 @@ Gem::Specification.new do |s|
61
59
  s.add_dependency 'salesforce_bulk_query', '~> 0.2'
62
60
  s.add_dependency 'terminal-table', '~> 1.7'
63
61
  s.add_dependency 'thread_safe'
62
+ s.add_dependency 'backports'
64
63
  end
@@ -31,3 +31,4 @@ require_relative 'gooddata/version'
31
31
 
32
32
  # Extensions
33
33
  require_relative 'gooddata/extensions/extensions'
34
+ require 'backports/2.1.0/array/to_h'
@@ -5,7 +5,7 @@
5
5
  # LICENSE file in the root directory of this source tree.
6
6
 
7
7
  require 'pathname'
8
- require 'aws'
8
+ require 'aws-sdk'
9
9
 
10
10
  module GoodData
11
11
  module Bricks
@@ -33,19 +33,19 @@ module GoodData
33
33
 
34
34
  bucket_name = @params['s3_backup_bucket_name']
35
35
 
36
- s3 = AWS::S3.new(
36
+ s3 = Aws::S3::Resource.new(
37
37
  :access_key_id => @params['aws_access_key_id'],
38
38
  :secret_access_key => @params['aws_secret_access_key']
39
39
  )
40
40
 
41
- bucket = s3.buckets[bucket_name]
42
- bucket = s3.buckets.create(bucket_name) unless bucket.exists?
41
+ bucket = s3.bucket(bucket_name)
42
+ bucket = s3.create_bucket(bucket_name) unless bucket.exists?
43
43
 
44
44
  files.each do |file|
45
45
  file_path = Pathname.new(file)
46
46
  target_path = Pathname.new(@params['s3_backup_path'] || '') + file_path.basename
47
- obj = bucket.objects[target_path]
48
- obj.write(file_path)
47
+ obj = bucket.objects(target_path)
48
+ obj.upload_file(file_path)
49
49
  @logger.info "Backed up file #{file_path} to s3 #{target_path}" if @logger
50
50
  end
51
51
 
@@ -17,15 +17,25 @@ module GoodData
17
17
  raise 'Unable to connect to AWS. Parameter "aws_client" seems to be empty' unless params['aws_client']
18
18
  raise 'Unable to connect to AWS. Parameter "access_key_id" is missing' if params['aws_client']['access_key_id'].blank?
19
19
  raise 'Unable to connect to AWS. Parameter "secret_access_key" is missing' if params['aws_client']['secret_access_key'].blank?
20
- if params['aws_client'].key?('use_ssl')
21
- params['aws_client']['use_ssl'] =
22
- params['aws_client']['use_ssl'].to_b
23
- end
24
- s3 = AWS::S3.new(params['aws_client'])
20
+ params['aws_client'] = rewrite_for_aws_sdk_v2(params['aws_client'])
21
+ symbolized_config = GoodData::Helpers.symbolize_keys(params['aws_client'])
22
+ s3 = Aws::S3::Resource.new(symbolized_config)
25
23
  params['aws_client']['s3_client'] = s3
26
24
  end
27
25
  @app.call(params)
28
26
  end
27
+
28
+ private
29
+
30
+ def rewrite_for_aws_sdk_v2(config)
31
+ config['region'] = 'us-west-2' unless config['region']
32
+ if config['use_ssl']
33
+ fail 'Parameter use_ssl has been deprecated. Version 2 of the AWS ' \
34
+ 'SDK uses SSL everywhere. To disable SSL you must ' \
35
+ 'configure an endpoint that uses http://.'
36
+ end
37
+ config
38
+ end
29
39
  end
30
40
  end
31
41
  end
@@ -15,10 +15,22 @@ module GoodData
15
15
  def call(params)
16
16
  if params.key?('ads_client') && (RUBY_PLATFORM == 'java')
17
17
  GoodData.logger.info "Setting up ADS connection to #{params['ads_client']['ads_id'] || params['ads_client']['jdbc_url']}"
18
- raise "ADS middleware needs username either as part of ads_client spec or as a global 'GDC_USERNAME' parameter" unless params['ads_client']['username'] || params['GDC_USERNAME']
19
- raise "ADS middleware needs password either as part of ads_client spec or as a global 'GDC_PASSWORD' parameter" unless params['ads_client']['password'] || params['GDC_PASSWORD']
18
+ unless params['ads_client']['username'] || params['GDC_USERNAME']
19
+ raise "ADS middleware needs username either as part of " \
20
+ "ads_client spec or as a global 'GDC_USERNAME' parameter"
21
+ end
20
22
 
21
- ads = GoodData::Datawarehouse.new(params['ads_client']['username'] || params['GDC_USERNAME'], params['ads_client']['password'] || params['GDC_PASSWORD'], params['ads_client']['ads_id'], jdbc_url: params['ads_client']['jdbc_url'])
23
+ unless params['ads_client']['password'] || params['GDC_PASSWORD']
24
+ raise "ADS middleware needs password either as part of " \
25
+ "ads_client spec or as a global 'GDC_PASSWORD' parameter"
26
+ end
27
+
28
+ ads = GoodData::Datawarehouse.new(
29
+ params['ads_client']['username'] || params['GDC_USERNAME'],
30
+ params['ads_client']['password'] || params['GDC_PASSWORD'],
31
+ params['ads_client']['ads_id'],
32
+ jdbc_url: params['ads_client']['jdbc_url']
33
+ )
22
34
  @app.call(params.merge('ads_client' => ads, :ads_client => ads))
23
35
  else
24
36
  @app.call(params)
@@ -25,9 +25,15 @@ module GoodData
25
25
  logger = params['GDC_LOGGER']
26
26
  GoodData.logger = logger
27
27
 
28
+ # Set parallelism
29
+ max_concurrency = params['max_concurrency'] || params['MAX_CONCURRENCY']
30
+ if max_concurrency && max_concurrency.to_i > 0
31
+ $pmap_default_thread_count = max_concurrency.to_i # rubocop:disable GlobalVars
32
+ end
33
+
28
34
  # Connect Client
29
- protocol = params['CLIENT_GDC_PROTOCOL'] || DEFAULT_PROTOCOL
30
- hostname = params['CLIENT_GDC_HOSTNAME'] || DEFAULT_HOSTNAME
35
+ protocol = params['CLIENT_GDC_PROTOCOL'] || params['GDC_PROTOCOL'] || DEFAULT_PROTOCOL
36
+ hostname = params['CLIENT_GDC_HOSTNAME'] || params['GDC_HOSTNAME'] || DEFAULT_HOSTNAME
31
37
  server = "#{protocol}://#{hostname}"
32
38
  client = GoodDataMiddleware.connect(
33
39
  server,
@@ -91,11 +97,14 @@ module GoodData
91
97
  if username.nil? || password.nil?
92
98
  puts "Connecting with SST to server #{server}"
93
99
  raise 'SST (SuperSecureToken) not present in params' if sst_token.nil?
94
- GoodData.connect(sst_token: sst_token, server: server, verify_ssl: verify_ssl)
100
+ conn = GoodData.connect(sst_token: sst_token, server: server, verify_ssl: verify_ssl)
95
101
  else
96
102
  puts "Connecting as #{username} to server #{server}"
97
- GoodData.connect(username, password, server: server, verify_ssl: verify_ssl)
103
+ conn = GoodData.connect(username, password, server: server, verify_ssl: verify_ssl)
98
104
  end
105
+ conn.stats_on
106
+
107
+ conn
99
108
  end
100
109
  end
101
110
  end
@@ -18,9 +18,12 @@ module GoodData
18
18
  logger = NilLogger.new
19
19
  else
20
20
  logger = params[:GDC_LOGGER_FILE].nil? ? Logger.new(STDOUT) : Logger.new(params[:GDC_LOGGER_FILE])
21
+ logger.level = params['GDC_LOG_LEVEL'] if params['GDC_LOG_LEVEL']
21
22
  logger.info('Pipeline starts')
22
23
  end
23
24
  params['GDC_LOGGER'] = logger
25
+ GoodData.logging_http_on if params['HTTP_LOGGING'] && params['HTTP_LOGGING'].to_b
26
+
24
27
  returning(@app.call(params)) do |_result|
25
28
  logger.info('Pipeline ending')
26
29
  end
@@ -6,7 +6,11 @@
6
6
 
7
7
  module GoodData
8
8
  class NoProjectError < RuntimeError
9
- DEFAULT_MSG = 'You have to provide "project_id". You can either provide it through -p flag or even better way is to fill it in in your Goodfile under key "project_id". If you just started a project you have to create it first. One way might be through "gooddata project build"'
9
+ DEFAULT_MSG = 'You have to provide "project_id". You can either provide ' \
10
+ 'it through -p flag or even better way is to fill it in in ' \
11
+ 'your Goodfile under key "project_id". If you just started ' \
12
+ 'a project you have to create it first. One way might be ' \
13
+ 'through "gooddata project build"'
10
14
 
11
15
  def initialize(msg = DEFAULT_MSG)
12
16
  super(msg)
@@ -96,18 +96,19 @@ module GoodData
96
96
  pairs = get_uris(expression).pmap do |uri|
97
97
  if uri =~ /elements/
98
98
  begin
99
- [uri, Attribute.find_element_value(uri, opts)]
99
+ ['element', uri, Attribute.find_element_value(uri, opts)]
100
100
  rescue AttributeElementNotFound
101
- [uri, '(empty value)']
101
+ ['element', uri, '(empty value)']
102
102
  end
103
103
  else
104
- [uri, GoodData::MdObject[uri, opts].title]
104
+ ['object', uri, GoodData::MdObject[uri, opts].title]
105
105
  end
106
106
  end
107
+ pairs.sort_by! { |p| p[0] }
107
108
  pairs.each do |el|
108
- uri = el[0]
109
- obj = el[1]
110
- temp.sub!(uri, obj)
109
+ uri = el[1]
110
+ obj = el[2]
111
+ temp.gsub!(uri, obj)
111
112
  end
112
113
  temp
113
114
  end
@@ -104,17 +104,17 @@ module GoodData
104
104
  def realize_s3(params)
105
105
  params = GoodData::Helpers.stringify_keys(params)
106
106
  s3_client = params['aws_client'] && params['aws_client']['s3_client']
107
- raise 'AWS client not present. Perhaps S3Middleware is missing in the brick definition?' if !s3_client || !s3_client.respond_to?(:buckets)
107
+ raise 'AWS client not present. Perhaps S3Middleware is missing in the brick definition?' if !s3_client || !s3_client.respond_to?(:bucket)
108
108
  bucket_name = @options[:bucket]
109
109
  key = @options[:key]
110
110
  raise 'Key "bucket" is missing in S3 datasource' if bucket_name.blank?
111
111
  raise 'Key "key" is missing in S3 datasource' if key.blank?
112
112
  puts "Realizing download from S3. Bucket #{bucket_name}, object with key #{key}."
113
113
  filename = Digest::SHA256.new.hexdigest(@options.to_json)
114
- bucket = s3_client.buckets[bucket_name]
115
- obj = bucket.objects[key]
114
+ bucket = s3_client.bucket(bucket_name)
115
+ obj = bucket.object(key)
116
116
  File.open(filename, 'wb') do |file|
117
- obj.read do |chunk|
117
+ obj.get do |chunk|
118
118
  file.write(chunk)
119
119
  end
120
120
  end
@@ -11,8 +11,12 @@ module GoodData
11
11
 
12
12
  class << self
13
13
  # Encodes parameters for passing them to GD execution platform.
14
- # Core types are kept and complex types (arrays, structures, etc) are JSON encoded into key hash "gd_encoded_params" or "gd_encoded_hidden_params", depending on the 'hidden' method param.
15
- # The two different keys are used because the params and hidden params are merged by the platform and if we use the same key, the param would be overwritten.
14
+ # Core types are kept and complex types (arrays, structures, etc) are
15
+ # JSON encoded into key hash "gd_encoded_params" or
16
+ # "gd_encoded_hidden_params", depending on the 'hidden' method param.
17
+ # The two different keys are used because the params and hidden params
18
+ # are merged by the platform and if we use the same key,
19
+ # the param would be overwritten.
16
20
  #
17
21
  # Core types are following:
18
22
  # - Boolean (true, false)
@@ -68,52 +72,26 @@ module GoodData
68
72
  '{}'
69
73
  end
70
74
 
75
+ reference_values = []
71
76
  # Replace reference parameters by the actual values. Use backslash to escape a reference parameter, e.g: \${not_a_param},
72
77
  # the ${not_a_param} will not be replaced
73
78
  if options[:resolve_reference_params]
74
- regexps = Regexp.union(/\\\\/, /\\\$/, /\$\{(\w+)\}/)
75
- resolve_reference = lambda do |v|
76
- if v.is_a? Hash
77
- Hash[
78
- v.map do |k, v2|
79
- [k, resolve_reference.call(v2)]
80
- end
81
- ]
82
- elsif v.is_a? Array
83
- v.map do |v2|
84
- resolve_reference.call(v2)
85
- end
86
- elsif !v.is_a?(String)
87
- v
88
- else
89
- v.gsub(regexps) do |match|
90
- if match =~ /\\\\/
91
- data_params.is_a?(Hash) ? '\\' : '\\\\' # rubocop: disable Metrics/BlockNesting
92
- elsif match =~ /\\\$/
93
- '$'
94
- elsif match =~ /\$\{(\w+)\}/
95
- params["#{$1}"] || raise("The gd_encoded_params parameter contains unknow reference #{$1}") # rubocop: disable Style/PerlBackrefs
96
- end
97
- end
98
- end
99
- end
100
-
101
- data_params = if data_params.is_a? Hash
102
- Hash[
103
- data_params.map do |k, v|
104
- [k, resolve_reference.call(v)]
105
- end
106
- ]
107
- else
108
- resolve_reference.call(data_params)
109
- end
79
+ data_params, reference_values = resolve_reference_params(data_params, params)
80
+ hidden_data_params, = resolve_reference_params(hidden_data_params, params)
110
81
  end
111
82
 
112
83
  begin
113
84
  parsed_data_params = data_params.is_a?(Hash) ? data_params : JSON.parse(data_params)
85
+ rescue JSON::ParserError => exception
86
+ reason = exception.message
87
+ reference_values.each { |secret_value| reason.gsub!("\"#{secret_value}\"", '"***"') }
88
+ raise exception.class, "Error reading json from '#{key}', reason: #{reason}"
89
+ end
90
+
91
+ begin
114
92
  parsed_hidden_data_params = hidden_data_params.is_a?(Hash) ? hidden_data_params : JSON.parse(hidden_data_params)
115
93
  rescue JSON::ParserError => exception
116
- raise exception.class, "Error reading json from '#{key}' or '#{hidden_key}', reason: #{exception.message}"
94
+ raise exception.class, "Error reading json from '#{hidden_key}'"
117
95
  end
118
96
 
119
97
  # Add the nil on ENCODED_HIDDEN_PARAMS_KEY
@@ -260,6 +238,50 @@ module GoodData
260
238
  value.to_s
261
239
  end
262
240
  end
241
+
242
+ private
243
+
244
+ def resolve_reference_params(data_params, params)
245
+ reference_values = []
246
+ regexps = Regexp.union(/\\\\/, /\\\$/, /\$\{(\w+)\}/)
247
+ resolve_reference = lambda do |v|
248
+ if v.is_a? Hash
249
+ Hash[
250
+ v.map do |k, v2|
251
+ [k, resolve_reference.call(v2)]
252
+ end
253
+ ]
254
+ elsif v.is_a? Array
255
+ v.map do |v2|
256
+ resolve_reference.call(v2)
257
+ end
258
+ elsif !v.is_a?(String)
259
+ v
260
+ else
261
+ v.gsub(regexps) do |match|
262
+ if match =~ /\\\\/
263
+ data_params.is_a?(Hash) ? '\\' : '\\\\' # rubocop: disable Metrics/BlockNesting
264
+ elsif match =~ /\\\$/
265
+ '$'
266
+ elsif match =~ /\$\{(\w+)\}/
267
+ val = params["#{$1}"] || raise("The gd_encoded_params parameter contains unknow reference #{$1}") # rubocop: disable Style/PerlBackrefs
268
+ reference_values << val
269
+ val
270
+ end
271
+ end
272
+ end
273
+ end
274
+
275
+ data_params = if data_params.is_a? Hash
276
+ Hash[data_params.map do |k, v|
277
+ [k, resolve_reference.call(v)]
278
+ end]
279
+ else
280
+ resolve_reference.call(data_params)
281
+ end
282
+
283
+ [data_params, reference_values]
284
+ end
263
285
  end
264
286
  end
265
287
  end