gooddata 1.1.0-java → 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. checksums.yaml +4 -4
  2. data/.document +0 -0
  3. data/.flayignore +2 -0
  4. data/.travis.yml +24 -7
  5. data/.yardopts +0 -0
  6. data/CHANGELOG.md +144 -0
  7. data/CLI.md +0 -0
  8. data/Dockerfile.jruby +7 -2
  9. data/Dockerfile.ruby +1 -1
  10. data/Gemfile +0 -0
  11. data/Guardfile +0 -0
  12. data/Rakefile +23 -9
  13. data/TODO.md +0 -0
  14. data/bin/gitflow-init.sh +8 -0
  15. data/ci.rake +3 -3
  16. data/data/2008.crt +39 -0
  17. data/data/new_ca.cer +22 -0
  18. data/dependency_decisions.yml +0 -0
  19. data/docker-compose.lcm.yml +31 -0
  20. data/docker-compose.yml +4 -2
  21. data/gooddata.gemspec +3 -3
  22. data/lcm.rake +288 -0
  23. data/lib/gooddata.rb +1 -0
  24. data/lib/gooddata/bricks/base_downloader.rb +1 -1
  25. data/lib/gooddata/bricks/brick.rb +0 -1
  26. data/lib/gooddata/bricks/middleware/aws_middleware.rb +1 -1
  27. data/lib/gooddata/bricks/middleware/logger_middleware.rb +1 -1
  28. data/lib/gooddata/bricks/pipeline.rb +67 -0
  29. data/lib/gooddata/bricks/provisioning_brick.rb +18 -0
  30. data/lib/gooddata/bricks/release_brick.rb +18 -0
  31. data/lib/gooddata/bricks/rollout_brick.rb +14 -0
  32. data/lib/gooddata/bricks/user_filters_brick.rb +13 -0
  33. data/lib/gooddata/bricks/users_brick.rb +13 -0
  34. data/lib/gooddata/core/logging.rb +1 -1
  35. data/lib/gooddata/exceptions/maql_execution.rb +1 -1
  36. data/lib/gooddata/extensions/string.rb +0 -0
  37. data/lib/gooddata/lcm/actions/associate_clients.rb +34 -8
  38. data/lib/gooddata/lcm/actions/collect_data_product.rb +8 -1
  39. data/lib/gooddata/lcm/actions/collect_segment_clients.rb +13 -23
  40. data/lib/gooddata/lcm/actions/collect_segments.rb +10 -0
  41. data/lib/gooddata/lcm/actions/synchronize_clients.rb +3 -1
  42. data/lib/gooddata/lcm/actions/synchronize_ldm.rb +61 -34
  43. data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +6 -4
  44. data/lib/gooddata/lcm/actions/update_release_table.rb +4 -12
  45. data/lib/gooddata/lcm/dsl/params_dsl.rb +0 -4
  46. data/lib/gooddata/lcm/dsl/type_dsl.rb +0 -4
  47. data/lib/gooddata/lcm/helpers/check_helper.rb +1 -1
  48. data/lib/gooddata/lcm/lcm2.rb +0 -2
  49. data/lib/gooddata/lcm/types/special/enum.rb +6 -0
  50. data/lib/gooddata/lcm/types/special/enum/synchronize_ldm.rb +20 -0
  51. data/lib/gooddata/lcm/types/special/types.rb +1 -1
  52. data/lib/gooddata/mixins/is_folder.rb +0 -0
  53. data/lib/gooddata/mixins/to_json.rb +0 -0
  54. data/lib/gooddata/mixins/uri_getter.rb +0 -0
  55. data/lib/gooddata/models/project_creator.rb +38 -30
  56. data/lib/gooddata/models/user_filters/user_filter_builder.rb +1 -0
  57. data/lib/gooddata/rest/README.md +0 -0
  58. data/lib/gooddata/version.rb +1 -1
  59. data/lib/templates/bricks/brick.rb.erb +0 -0
  60. data/lib/templates/bricks/main.rb.erb +0 -0
  61. data/lib/templates/project/Goodfile.erb +0 -0
  62. data/lib/templates/project/data/commits.csv +0 -0
  63. data/lib/templates/project/data/devs.csv +0 -0
  64. data/lib/templates/project/data/repos.csv +0 -0
  65. data/lib/templates/project/model/model.rb.erb +0 -0
  66. metadata +23 -452
  67. data/lib/gooddata/lcm/actions/ensure_data_product.rb +0 -63
  68. data/spec/.rubocop.yml +0 -16
  69. data/spec/bricks/bricks_spec.rb +0 -110
  70. data/spec/bricks/default-config.json +0 -8
  71. data/spec/data/.gooddata +0 -4
  72. data/spec/data/blueprints/additional_dataset_module.json +0 -32
  73. data/spec/data/blueprints/attribute_sort_order_blueprint.json +0 -72
  74. data/spec/data/blueprints/big_blueprint_not_pruned.json +0 -2079
  75. data/spec/data/blueprints/invalid_blueprint.json +0 -103
  76. data/spec/data/blueprints/m_n_model.json +0 -104
  77. data/spec/data/blueprints/model_module.json +0 -25
  78. data/spec/data/blueprints/test_blueprint.json +0 -39
  79. data/spec/data/blueprints/test_project_model_spec.json +0 -106
  80. data/spec/data/cc/data/source/commits.csv +0 -4
  81. data/spec/data/cc/data/source/devs.csv +0 -4
  82. data/spec/data/cc/data/source/repos.csv +0 -3
  83. data/spec/data/cc/devel.prm +0 -0
  84. data/spec/data/cc/graph/graph.grf +0 -11
  85. data/spec/data/cc/workspace.prm +0 -19
  86. data/spec/data/column_based_permissions.csv +0 -7
  87. data/spec/data/column_based_permissions2.csv +0 -6
  88. data/spec/data/dynamic_schedule_params_table.csv +0 -7
  89. data/spec/data/gd_gse_data_blueprint.json +0 -1371
  90. data/spec/data/gd_gse_data_manifest.json +0 -1424
  91. data/spec/data/gd_gse_data_model.json +0 -1772
  92. data/spec/data/gooddata_version_process/gooddata_version.rb +0 -9
  93. data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
  94. data/spec/data/hello_world_process/hello_world.rb +0 -9
  95. data/spec/data/hello_world_process/hello_world.zip +0 -0
  96. data/spec/data/integration_model.json +0 -252
  97. data/spec/data/integration_policies.csv +0 -9134
  98. data/spec/data/line_based_permissions.csv +0 -3
  99. data/spec/data/manifests/test_blueprint.json +0 -32
  100. data/spec/data/manifests/test_project.json +0 -107
  101. data/spec/data/reports/left_attr_report.json +0 -108
  102. data/spec/data/reports/metric_only_one_line.json +0 -83
  103. data/spec/data/reports/report_1.json +0 -197
  104. data/spec/data/reports/top_attr_report.json +0 -108
  105. data/spec/data/ruby_params_process/ruby_params.rb +0 -9
  106. data/spec/data/ruby_process/deep_files/deep_stuff.txt +0 -1
  107. data/spec/data/ruby_process/process.rb +0 -8
  108. data/spec/data/ruby_process/stuff.txt +0 -1
  109. data/spec/data/superfluous_titles_view.json +0 -81
  110. data/spec/data/test-ci-data.csv +0 -2
  111. data/spec/data/user_filters.csv +0 -2
  112. data/spec/data/users.csv +0 -12
  113. data/spec/data/wire_models/attribute_sort_by_model.json +0 -73
  114. data/spec/data/wire_models/model_view.json +0 -1775
  115. data/spec/data/wire_models/nu_model.json +0 -3046
  116. data/spec/data/wire_models/test_blueprint.json +0 -66
  117. data/spec/data/wire_test_project.json +0 -150
  118. data/spec/data/workspace_table.csv +0 -3
  119. data/spec/environment/default.rb +0 -43
  120. data/spec/environment/development.rb +0 -32
  121. data/spec/environment/environment.rb +0 -38
  122. data/spec/environment/production.rb +0 -27
  123. data/spec/environment/staging.rb +0 -32
  124. data/spec/environment/testing.rb +0 -32
  125. data/spec/helpers/appstore_project_helper.rb +0 -221
  126. data/spec/helpers/blueprint_helper.rb +0 -27
  127. data/spec/helpers/cli_helper.rb +0 -38
  128. data/spec/helpers/connection_helper.rb +0 -43
  129. data/spec/helpers/constants.rb +0 -32
  130. data/spec/helpers/crypto_helper.rb +0 -19
  131. data/spec/helpers/csv_helper.rb +0 -20
  132. data/spec/helpers/process_helper.rb +0 -35
  133. data/spec/helpers/project_helper.rb +0 -74
  134. data/spec/helpers/schedule_helper.rb +0 -33
  135. data/spec/helpers/spec_helper.rb +0 -17
  136. data/spec/integration/ads_output_stage_spec.rb +0 -45
  137. data/spec/integration/blueprint_updates_spec.rb +0 -107
  138. data/spec/integration/blueprint_with_ca_spec.rb +0 -56
  139. data/spec/integration/blueprint_with_grain_spec.rb +0 -74
  140. data/spec/integration/channel_configuration_spec.rb +0 -67
  141. data/spec/integration/clients_spec.rb +0 -164
  142. data/spec/integration/command_datawarehouse_spec.rb +0 -45
  143. data/spec/integration/command_projects_spec.rb +0 -32
  144. data/spec/integration/commands/command_projects_spec.rb +0 -22
  145. data/spec/integration/connection_spec.rb +0 -37
  146. data/spec/integration/core/connection_spec.rb +0 -56
  147. data/spec/integration/core/logging_spec.rb +0 -132
  148. data/spec/integration/core/project_spec.rb +0 -54
  149. data/spec/integration/create_from_template_spec.rb +0 -29
  150. data/spec/integration/create_project_spec.rb +0 -27
  151. data/spec/integration/date_dim_switch_spec.rb +0 -154
  152. data/spec/integration/deprecated_load_spec.rb +0 -60
  153. data/spec/integration/full_process_schedule_spec.rb +0 -367
  154. data/spec/integration/full_project_spec.rb +0 -592
  155. data/spec/integration/helpers_spec.rb +0 -16
  156. data/spec/integration/lcm_spec.rb +0 -54
  157. data/spec/integration/mandatory_user_filter_spec.rb +0 -53
  158. data/spec/integration/mixins/id_to_uri_spec.rb +0 -56
  159. data/spec/integration/models/data_product_spec.rb +0 -71
  160. data/spec/integration/models/domain_spec.rb +0 -162
  161. data/spec/integration/models/invitation_spec.rb +0 -17
  162. data/spec/integration/models/label_spec.rb +0 -49
  163. data/spec/integration/models/membership_spec.rb +0 -127
  164. data/spec/integration/models/metadata/report_spec.rb +0 -54
  165. data/spec/integration/models/metric_spec.rb +0 -24
  166. data/spec/integration/models/params_spec.rb +0 -118
  167. data/spec/integration/models/process_spec.rb +0 -35
  168. data/spec/integration/models/profile_spec.rb +0 -210
  169. data/spec/integration/models/project_role_spec.rb +0 -94
  170. data/spec/integration/models/project_spec.rb +0 -225
  171. data/spec/integration/models/schedule_spec.rb +0 -477
  172. data/spec/integration/models/unit_project_spec.rb +0 -130
  173. data/spec/integration/over_to_user_filters_spec.rb +0 -98
  174. data/spec/integration/partial_md_export_import_spec.rb +0 -41
  175. data/spec/integration/project_spec.rb +0 -381
  176. data/spec/integration/rest_spec.rb +0 -214
  177. data/spec/integration/schedule_spec.rb +0 -611
  178. data/spec/integration/segments_spec.rb +0 -100
  179. data/spec/integration/subscription_spec.rb +0 -88
  180. data/spec/integration/urn_date_dim_spec.rb +0 -53
  181. data/spec/integration/user_filters_spec.rb +0 -310
  182. data/spec/integration/user_group_spec.rb +0 -147
  183. data/spec/integration/variables_spec.rb +0 -189
  184. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/can_assign_a_custom_logger.yml +0 -2287
  185. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/client_logs_when_given_custom_message.yml +0 -2287
  186. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/has_the_request_id_logged_when_I_passed_it.yml +0 -2287
  187. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_off/Disables_logging.yml +0 -2287
  188. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_on/Enables_logging.yml +0 -2287
  189. data/spec/integration/vcr_cassettes/GoodData_-_project/_project/Returns_project_assigned.yml +0 -354
  190. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_nil.yml +0 -299
  191. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_directly.yml +0 -354
  192. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_ID.yml +0 -354
  193. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_URL.yml +0 -354
  194. data/spec/integration/vcr_cassettes/GoodData_-_project/_with_project/Uses_project_specified.yml +0 -354
  195. data/spec/integration/vcr_cassettes/GoodData_Metric/all.yml +0 -2065
  196. data/spec/integration/vcr_cassettes/GoodData_Metric/should_be_able_to_update_folders.yml +0 -119
  197. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/all.yml +0 -9812
  198. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_get_json_containing_correct_id.yml +0 -174
  199. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_return_nil_for_unknown_id.yml +0 -58
  200. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_throw_BadRequest_for_-1.yml +0 -63
  201. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_connect/Connects_using_username_and_password.yml +0 -299
  202. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_disconnect/Connects_using_username_and_password.yml +0 -299
  203. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_generate_request_id/Generates_a_non-empty_string.yml +0 -2287
  204. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_/Should_list_user_groups_as_Array.yml +0 -56
  205. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_add_members/Should_add_member.yml +0 -315
  206. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_members/Should_return_members_as_array.yml +0 -54
  207. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_remove_members/Should_remove_existing_members.yml +0 -258
  208. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_save/updates_existing_group.yml +0 -159
  209. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_set_members/Should_set_new_members.yml +0 -158
  210. data/spec/integration/vcr_cassettes/GoodData_UserGroup/all.yml +0 -809
  211. data/spec/logging_in_logging_out_spec.rb +0 -91
  212. data/spec/spec_helper.rb +0 -110
  213. data/spec/unit/actions/associate_clients_spec.rb +0 -48
  214. data/spec/unit/actions/collect_client_projects_spec.rb +0 -47
  215. data/spec/unit/actions/collect_clients_spec.rb +0 -65
  216. data/spec/unit/actions/collect_data_product_spec.rb +0 -58
  217. data/spec/unit/actions/collect_dynamic_schedule_params_spec.rb +0 -56
  218. data/spec/unit/actions/collect_meta_spec.rb +0 -88
  219. data/spec/unit/actions/collect_segment_clients_spec.rb +0 -82
  220. data/spec/unit/actions/collect_tagged_objects_spec.rb +0 -126
  221. data/spec/unit/actions/collect_users_brick_users_spec.rb +0 -36
  222. data/spec/unit/actions/create_segment_masters_spec.rb +0 -65
  223. data/spec/unit/actions/ensure_data_product_spec.rb +0 -39
  224. data/spec/unit/actions/ensure_technical_users_domain_spec.rb +0 -53
  225. data/spec/unit/actions/ensure_technical_users_project_spec.rb +0 -76
  226. data/spec/unit/actions/execute_schedules_spec.rb +0 -94
  227. data/spec/unit/actions/provision_clients_spec.rb +0 -46
  228. data/spec/unit/actions/purge_clients_spec.rb +0 -47
  229. data/spec/unit/actions/rename_existing_client_projects_spec.rb +0 -54
  230. data/spec/unit/actions/segments_filter_spec.rb +0 -46
  231. data/spec/unit/actions/shared_examples_for_user_actions.rb +0 -43
  232. data/spec/unit/actions/synchronize_cas_spec.rb +0 -58
  233. data/spec/unit/actions/synchronize_clients_spec.rb +0 -71
  234. data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +0 -206
  235. data/spec/unit/actions/synchronize_ldm_spec.rb +0 -70
  236. data/spec/unit/actions/synchronize_user_filters_spec.rb +0 -208
  237. data/spec/unit/actions/synchronize_user_groups_spec.rb +0 -49
  238. data/spec/unit/actions/synchronize_users_spec.rb +0 -180
  239. data/spec/unit/bricks/bricks_spec.rb +0 -34
  240. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +0 -98
  241. data/spec/unit/bricks/middleware/bench_middleware_spec.rb +0 -15
  242. data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +0 -15
  243. data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +0 -15
  244. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +0 -30
  245. data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +0 -15
  246. data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +0 -15
  247. data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +0 -15
  248. data/spec/unit/cli/cli_spec.rb +0 -17
  249. data/spec/unit/cli/commands/cmd_auth_spec.rb +0 -17
  250. data/spec/unit/core/nil_logger_spec.rb +0 -13
  251. data/spec/unit/extensions/hash_spec.rb +0 -22
  252. data/spec/unit/godzilla/goodzilla_spec.rb +0 -74
  253. data/spec/unit/helpers/check_helper_production_spec.rb +0 -34
  254. data/spec/unit/helpers/check_helper_spec.rb +0 -134
  255. data/spec/unit/helpers/csv_helper_spec.rb +0 -22
  256. data/spec/unit/helpers/data_helper_spec.rb +0 -67
  257. data/spec/unit/helpers/global_helpers_spec.rb +0 -264
  258. data/spec/unit/helpers_spec.rb +0 -254
  259. data/spec/unit/lcm/lcm2_spec.rb +0 -100
  260. data/spec/unit/lcm/user_bricks_helper_spec.rb +0 -58
  261. data/spec/unit/models/blueprint/attribute_sort_by_spec.rb +0 -20
  262. data/spec/unit/models/blueprint/attributes_spec.rb +0 -28
  263. data/spec/unit/models/blueprint/dataset_spec.rb +0 -120
  264. data/spec/unit/models/blueprint/label_blueprint_field_spec.rb +0 -43
  265. data/spec/unit/models/blueprint/project_blueprint_spec.rb +0 -642
  266. data/spec/unit/models/blueprint/reference_spec.rb +0 -28
  267. data/spec/unit/models/blueprint/schema_builder_spec.rb +0 -36
  268. data/spec/unit/models/blueprint/to_wire_spec.rb +0 -196
  269. data/spec/unit/models/dataset_blueprint.rb +0 -14
  270. data/spec/unit/models/execution_spec.rb +0 -109
  271. data/spec/unit/models/from_wire_spec.rb +0 -321
  272. data/spec/unit/models/metadata_spec.rb +0 -140
  273. data/spec/unit/models/metric_spec.rb +0 -129
  274. data/spec/unit/models/model_spec.rb +0 -87
  275. data/spec/unit/models/project_creator_spec.rb +0 -90
  276. data/spec/unit/models/project_spec.rb +0 -94
  277. data/spec/unit/models/report_result_data_spec.rb +0 -194
  278. data/spec/unit/models/to_manifest_spec.rb +0 -165
  279. data/spec/unit/models/user_filters/user_filter_builder_spec.rb +0 -149
  280. data/spec/unit/models/user_filters_spec.rb +0 -95
  281. data/spec/unit/models/variable_spec.rb +0 -280
  282. data/spec/unit/rest/phmap_spec.rb +0 -117
  283. data/spec/unit/rest/polling_spec.rb +0 -101
  284. data/spec/unit/rest/resource_spec.rb +0 -10
  285. data/spec/vcr_configurer.rb +0 -63
@@ -0,0 +1,18 @@
1
+ require_relative 'brick'
2
+
3
+ module GoodData::Bricks
4
+ class ProvisioningBrick < GoodData::Bricks::Brick
5
+ def version
6
+ '0.0.1'
7
+ end
8
+
9
+ # Provisioning brick entry-point
10
+ #
11
+ # @param [Hash] params Parameters
12
+ # @option [String] 'associate' ('true') Do association - true, false
13
+ # @option [String] 'provision' ('true') Do provision - true, false
14
+ def call(params)
15
+ GoodData::LCM2.perform('provision', params)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'brick'
2
+
3
+ module GoodData::Bricks
4
+ class ReleaseBrick < GoodData::Bricks::Brick
5
+ def version
6
+ '0.0.1'
7
+ end
8
+
9
+ # Provisioning brick entry-point
10
+ #
11
+ # @param [Hash] params Parameters
12
+ # @option [String] 'associate' ('true') Do association - true, false
13
+ # @option [String] 'provision' ('true') Do provision - true, false
14
+ def call(params)
15
+ GoodData::LCM2.perform('release', params)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'brick'
2
+
3
+ module GoodData::Bricks
4
+ class RolloutBrick < GoodData::Bricks::Brick
5
+ def version
6
+ '0.0.1'
7
+ end
8
+
9
+ # Rollout brick entry-point
10
+ def call(params)
11
+ GoodData::LCM2.perform('rollout', params)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'brick'
2
+
3
+ module GoodData::Bricks
4
+ class UserFiltersBrick < GoodData::Bricks::Brick
5
+ def version
6
+ "0.0.1"
7
+ end
8
+
9
+ def call(params)
10
+ GoodData::LCM2.perform('user_filters', params)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'brick'
2
+
3
+ module GoodData::Bricks
4
+ class UsersBrick < GoodData::Bricks::Brick
5
+ def version
6
+ '0.0.1'
7
+ end
8
+
9
+ def call(params)
10
+ GoodData::LCM2.perform('users', params)
11
+ end
12
+ end
13
+ end
@@ -93,7 +93,7 @@ module GoodData
93
93
  end
94
94
 
95
95
  # Initial setup of logger
96
- GoodData.logger = GoodData.logging_on
96
+ GoodData.logger = GoodData.logging_on(ENV['GD_LOG_LEVEL'] || DEFAULT_LOG_LEVEL)
97
97
 
98
98
  # Initial setup of rest logger
99
99
  GoodData.rest_logger = GoodData.logging_http_on(
@@ -8,7 +8,7 @@ module GoodData
8
8
  class MaqlExecutionError < RuntimeError
9
9
  attr_accessor :data
10
10
 
11
- def initialize(message, data)
11
+ def initialize(message, data = nil)
12
12
  super(message || 'Execution of maql failed')
13
13
  @data = data
14
14
  end
File without changes
@@ -22,10 +22,13 @@ module GoodData
22
22
  param :domain, instance_of(Type::StringType), required: false
23
23
 
24
24
  description 'Delete Extra Clients'
25
- param :delete_extra, instance_of(Type::BooleanType), required: false, default: false
25
+ param :delete_extra, instance_of(Type::BooleanType), required: false, default: false, deprecated: true, replacement: :delete_mode
26
26
 
27
27
  description 'Physically Delete Client Projects'
28
- param :delete_projects, instance_of(Type::BooleanType), required: false, default: false
28
+ param :delete_projects, instance_of(Type::BooleanType), required: false, default: false, deprecated: true, replacement: :delete_mode
29
+
30
+ description 'Physically Delete Client Projects'
31
+ param :delete_mode, instance_of(Type::StringType), required: false, default: 'none'
29
32
 
30
33
  description 'Clients'
31
34
  param :clients, array_of(instance_of(Type::HashType)), required: true, generated: true
@@ -46,7 +49,33 @@ module GoodData
46
49
  ]
47
50
 
48
51
  class << self
52
+ DELETE_MODES = %w(
53
+ none
54
+ delete_projects
55
+ delete_extra
56
+ )
49
57
  def call(params)
58
+ unless DELETE_MODES.include?(params.delete_mode) || params.delete_mode.nil?
59
+ fail "The parameter \"delete_mode\" has to have one of the values #{DELETE_MODES.map(&:to_s).join(', ')} or has to be empty."
60
+ end
61
+
62
+ case params.delete_mode
63
+ when 'delete_projects'
64
+ delete_projects = true
65
+ delete_extra = true
66
+ when 'delete_extra'
67
+ delete_projects = false
68
+ delete_extra = true
69
+ else
70
+ # Usage of the depracated params
71
+ delete_projects = GoodData::Helpers.to_boolean(params.delete_projects)
72
+ delete_extra = GoodData::Helpers.to_boolean(params.delete_extra)
73
+ end
74
+
75
+ if delete_projects && !delete_extra
76
+ GoodData.logger.warn("Parameter `delete_projects` is set to true and parameter `delete_extra` is set to false (which is default) this action will not delete anything!")
77
+ end
78
+
50
79
  client = params.gdc_gd_client
51
80
 
52
81
  domain_name = params.organization || params.domain
@@ -70,22 +99,19 @@ module GoodData
70
99
  end
71
100
 
72
101
  domain.update_clients_settings(params.clients)
73
-
74
- delete_projects = GoodData::Helpers.to_boolean(params.delete_projects)
75
- delete_extra = GoodData::Helpers.to_boolean(params.delete_extra)
76
102
  options = { delete_projects: delete_projects }
77
- options.merge!(delete_extra_option(params)) if delete_extra
103
+ options.merge!(delete_extra_option(params, delete_extra)) if delete_extra
78
104
 
79
105
  domain.update_clients(params.clients, options)
80
106
  end
81
107
 
82
108
  private
83
109
 
84
- def delete_extra_option(params)
110
+ def delete_extra_option(params, delete_extra)
85
111
  if params.segments_filter && params.segments_filter.any?
86
112
  { delete_extra_in_segments: params.segments_filter }
87
113
  else
88
- { delete_extra: GoodData::Helpers.to_boolean(params.delete_extra) }
114
+ { delete_extra: GoodData::Helpers.to_boolean(delete_extra) }
89
115
  end
90
116
  end
91
117
  end
@@ -45,7 +45,14 @@ module GoodData
45
45
  params.gdc_logger.info "Using data product 'default' since none was specified in brick parameters"
46
46
  data_product_id = 'default'
47
47
  end
48
- data_product = domain.data_products(data_product_id)
48
+
49
+ begin
50
+ data_product = domain.data_products(data_product_id)
51
+ rescue RestClient::BadRequest
52
+ params.gdc_logger.info "Can not find DataProduct #{params.data_product}, creating it instead"
53
+ data_product = domain.create_data_product(id: params.data_product)
54
+ end
55
+
49
56
  results = [
50
57
  {
51
58
  data_product: data_product_id
@@ -15,12 +15,6 @@ module GoodData
15
15
  description 'Client Used for Connecting to GD'
16
16
  param :gdc_gd_client, instance_of(Type::GdClientType), required: true
17
17
 
18
- description 'Organization Name'
19
- param :organization, instance_of(Type::StringType), required: false
20
-
21
- description 'Domain'
22
- param :domain, instance_of(Type::StringType), required: false
23
-
24
18
  description 'ADS Client'
25
19
  param :ads_client, instance_of(Type::AdsClientType), required: true
26
20
 
@@ -47,20 +41,9 @@ module GoodData
47
41
  def call(params)
48
42
  client = params.gdc_gd_client
49
43
 
50
- domain_name = params.organization || params.domain
51
- fail "Either organisation or domain has to be specified in params" unless domain_name
52
- domain = client.domain(domain_name) || fail("Invalid domain name specified - #{domain_name}")
53
- data_product = params.data_product
54
- domain_segments = domain.segments(:all, data_product)
55
-
56
- segments = params.segments.map do |seg|
57
- domain_segments.find do |s|
58
- s.segment_id == seg.segment_id
59
- end
60
- end
61
-
62
44
  results = []
63
- synchronize_clients = segments.map do |segment|
45
+ synchronize_clients = params[:segments].map do |segment_hash|
46
+ segment = segment_hash[:segment]
64
47
  segment_clients = segment.clients
65
48
  missing_project_clients = segment_clients.reject(&:project?).map(&:client_id)
66
49
 
@@ -75,15 +58,21 @@ module GoodData
75
58
  query = GoodData::Helpers::ErbHelper.template_file(path, replacements)
76
59
 
77
60
  res = params.ads_client.execute_select(query)
61
+ latest_master_id = res.max_by { |row| row[:version] }[:master_project_id]
62
+ latest_master = client.projects(latest_master_id)
78
63
 
79
64
  # TODO: Check res.first.nil? || res.first[:master_project_id].nil?
80
- master = client.projects(res.first[:master_project_id])
81
- master_pid = master.pid
82
- master_name = master.title
65
+ master_pid = latest_master.pid
66
+ master_name = latest_master.title
67
+
68
+ previous_master = segment_hash[:segment_master] if
69
+ segment_hash[:segment_master] &&
70
+ segment_hash[:segment_master].pid != latest_master.pid
83
71
 
84
72
  sync_info = {
85
73
  segment_id: segment.segment_id,
86
74
  from: master_pid,
75
+ previous_master: previous_master,
87
76
  to: segment_clients.map do |segment_client|
88
77
  client_project = segment_client.project
89
78
  to_pid = client_project.pid
@@ -91,7 +80,8 @@ module GoodData
91
80
  from_name: master_name,
92
81
  from_pid: master_pid,
93
82
  to_name: client_project.title,
94
- to_pid: to_pid
83
+ to_pid: to_pid,
84
+ previous_master: previous_master
95
85
  }
96
86
 
97
87
  {
@@ -23,6 +23,14 @@ module GoodData
23
23
  param :gdc_logger, instance_of(Type::GdLogger), required: true
24
24
  end
25
25
 
26
+ RESULT_HEADER = [
27
+ :segment_id,
28
+ :development_pid,
29
+ :driver,
30
+ :master_name,
31
+ :uri
32
+ ]
33
+
26
34
  class << self
27
35
  def call(params)
28
36
  data_product = params.data_product
@@ -50,9 +58,11 @@ module GoodData
50
58
 
51
59
  {
52
60
  segment_id: segment.segment_id,
61
+ segment: segment,
53
62
  development_pid: project.pid,
54
63
  driver: project.driver.downcase,
55
64
  master_name: project.title,
65
+ segment_master: project,
56
66
  uri: segment.uri
57
67
  }
58
68
  end
@@ -72,9 +72,11 @@ module GoodData
72
72
  query = GoodData::Helpers::ErbHelper.template_file(path, replacements)
73
73
 
74
74
  res = params.ads_client.execute_select(query)
75
+ sorted = res.sort_by { |row| row[:version] }
76
+ current_master = sorted.last[:master_project_id]
75
77
 
76
78
  # TODO: Check res.first.nil? || res.first[:master_project_id].nil?
77
- master = client.projects(res.first[:master_project_id])
79
+ master = client.projects(current_master)
78
80
 
79
81
  segment.master_project = master
80
82
  segment.save
@@ -35,57 +35,84 @@ module GoodData
35
35
 
36
36
  description 'Allows to have facts with higher precision decimals'
37
37
  param :exclude_fact_rule, instance_of(Type::BooleanType), required: false, default: false
38
+
39
+ description 'Specifies how to synchronize LDM and resolve possible conflicts'
40
+ param :synchronize_ldm, instance_of(Type::SynchronizeLDM), required: false, default: 'diff_against_master_with_fallback'
38
41
  end
39
42
 
40
43
  class << self
41
44
  def call(params)
42
- include_ca = params.include_computed_attributes.to_b
43
- exclude_fact_rule = params.exclude_fact_rule.to_b
44
-
45
45
  results = []
46
+ synchronize = []
47
+ params.synchronize.map do |segment_info|
48
+ new_segment_info, segment_results = sync_segment_ldm(params, segment_info)
49
+ results.concat(segment_results)
50
+ synchronize << new_segment_info
51
+ end
46
52
 
47
- client = params.gdc_gd_client
48
- development_client = params.development_client
53
+ {
54
+ results: results,
55
+ params: {
56
+ synchronize: synchronize
57
+ }
58
+ }
59
+ end
49
60
 
50
- synchronize = params.synchronize.map do |info|
51
- from_project = info.from
52
- to_projects = info.to
61
+ private
53
62
 
54
- from = development_client.projects(from_project) || fail("Invalid 'from' project specified - '#{from_project}'")
55
- params.gdc_logger.info "Creating Blueprint, project: '#{from.title}', PID: #{from.pid}"
63
+ def sync_segment_ldm(params, segment_info)
64
+ results = []
65
+ client = params.gdc_gd_client
66
+ exclude_fact_rule = params.exclude_fact_rule.to_b
67
+ from_pid = segment_info[:from]
68
+ from = params.development_client.projects(from_pid) || fail("Invalid 'from' project specified - '#{from_pid}'")
69
+
70
+ GoodData.logger.info "Creating Blueprint, project: '#{from.title}', PID: #{from_pid}"
71
+ blueprint = from.blueprint(include_ca: params.include_computed_attributes.to_b)
72
+ maql_diff = nil
73
+ previous_master = segment_info[:previous_master]
74
+ diff_against_master = %w(diff_against_master_with_fallback diff_against_master)
75
+ .include?(params[:synchronize_ldm].downcase)
76
+ if previous_master && diff_against_master
77
+ maql_diff_params = [:includeGrain]
78
+ maql_diff_params << :excludeFactRule if exclude_fact_rule
79
+ maql_diff = previous_master.maql_diff(blueprint: blueprint, params: maql_diff_params)
80
+ end
56
81
 
57
- blueprint = from.blueprint(include_ca: include_ca)
58
- info[:to] = to_projects.pmap do |entry|
59
- pid = entry[:pid]
60
- to_project = client.projects(pid) || fail("Invalid 'to' project specified - '#{pid}'")
82
+ segment_info[:to] = segment_info[:to].pmap do |entry|
83
+ pid = entry[:pid]
84
+ to_project = client.projects(pid) || fail("Invalid 'to' project specified - '#{pid}'")
61
85
 
62
- params.gdc_logger.info "Updating from Blueprint, project: '#{to_project.title}', PID: #{pid}"
63
- ca_scripts = to_project.update_from_blueprint(
86
+ GoodData.logger.info "Updating from Blueprint, project: '#{to_project.title}', PID: #{pid}"
87
+ begin
88
+ entry[:ca_scripts] = to_project.update_from_blueprint(
64
89
  blueprint,
65
- update_preference: params.update_preference,
90
+ update_preference: params[:update_preference],
91
+ exclude_fact_rule: exclude_fact_rule,
66
92
  execute_ca_scripts: false,
67
- exclude_fact_rule: exclude_fact_rule
93
+ maql_diff: maql_diff
94
+ )
95
+ rescue MaqlExecutionError => e
96
+ GoodData.logger.info("Applying MAQL to project #{to_project.title} - #{pid} failed. Reason: #{e}")
97
+ fail e unless previous_master && params[:synchronize_ldm] == 'diff_against_master_with_fallback'
98
+ GoodData.logger.info("Restoring the client project #{to_project.title} from master.")
99
+ entry[:ca_scripts] = to_project.update_from_blueprint(
100
+ blueprint,
101
+ update_preference: params[:update_preference],
102
+ exclude_fact_rule: exclude_fact_rule,
103
+ execute_ca_scripts: false
68
104
  )
69
-
70
- entry[:ca_scripts] = ca_scripts
71
-
72
- results << {
73
- from: from_project,
74
- to: pid,
75
- status: 'ok'
76
- }
77
- entry
78
105
  end
79
106
 
80
- info
107
+ results << {
108
+ from: from_pid,
109
+ to: pid,
110
+ status: 'ok'
111
+ }
112
+ entry
81
113
  end
82
114
 
83
- {
84
- results: results,
85
- params: {
86
- synchronize: synchronize
87
- }
88
- }
115
+ [segment_info, results]
89
116
  end
90
117
  end
91
118
  end
@@ -127,7 +127,7 @@ module GoodData
127
127
  ignore_missing_values: params.ignore_missing_values == 'true',
128
128
  do_not_touch_filters_that_are_not_mentioned: params.do_not_touch_filters_that_are_not_mentioned == 'true',
129
129
  domain: domain,
130
- dry_run: params[:dry_run],
130
+ dry_run: params[:dry_run].to_b,
131
131
  users_brick_input: params.users_brick_users
132
132
  }
133
133
 
@@ -220,6 +220,7 @@ module GoodData
220
220
 
221
221
  working_client_ids = []
222
222
 
223
+ results = []
223
224
  filters.group_by { |u| u[multiple_projects_column] }.flat_map do |client_id, new_filters|
224
225
  fail "Client id cannot be empty" if client_id.blank?
225
226
  c = domain.clients(client_id, data_product)
@@ -232,10 +233,10 @@ module GoodData
232
233
  working_client_ids << client_id
233
234
  filters_to_load = GoodData::UserFilterBuilder.get_filters(new_filters, symbolized_config)
234
235
  puts "Synchronizing #{filters_to_load.count} filters in project #{project.pid} of client #{client_id}"
235
- project.add_data_permissions(filters_to_load, run_params)
236
+ partial_results = project.add_data_permissions(filters_to_load, run_params)
237
+ results.concat(partial_results[:results])
236
238
  end
237
239
 
238
- results = []
239
240
  unless run_params[:do_not_touch_filters_that_are_not_mentioned]
240
241
  domain_clients.each do |c|
241
242
  next if working_client_ids.include?(c.client_id)
@@ -255,7 +256,8 @@ module GoodData
255
256
  end
256
257
 
257
258
  puts "Delete all filters in project #{project.pid} of client #{c.client_id}"
258
- results << project.add_data_permissions([], run_params)
259
+ delete_results = project.add_data_permissions([], run_params)
260
+ results.concat(delete_results[:results])
259
261
  end
260
262
  end
261
263