lib/gooddata/lcm/actions/synchronize_ldm.rb in gooddata-0.6.51 vs lib/gooddata/lcm/actions/synchronize_ldm.rb in gooddata-0.6.52

- old
+ new

@@ -13,51 +13,60 @@ PARAMS = define_params(self) do description 'Client Used for Connecting to GD' param :gdc_gd_client, instance_of(Type::GdClientType), required: true + description 'Development Client Used for Connecting to GD' + param :development_client, instance_of(Type::GdClientType), required: true + description 'Synchronization Info' param :synchronize, array_of(instance_of(Type::SynchronizationInfoType)), required: true, generated: true description 'LDM Update Preference' param :update_preference, instance_of(Type::UpdatePreferenceType), required: false end class << self def call(params) - # Check if all required parameters were passed - BaseAction.check_params(PARAMS, params) - results = [] client = params.gdc_gd_client development_client = params.development_client - params.synchronize.each do |info| + synchronize = params.synchronize.map do |info| from_project = info.from to_projects = info.to from = development_client.projects(from_project) || fail("Invalid 'from' project specified - '#{from_project}'") params.gdc_logger.info "Creating Blueprint, project: '#{from.title}', PID: #{from.pid}" blueprint = from.blueprint - to_projects.each do |entry| + info[:to] = to_projects.pmap do |entry| pid = entry[:pid] to_project = client.projects(pid) || fail("Invalid 'to' project specified - '#{pid}'") params.gdc_logger.info "Updating from Blueprint, project: '#{to_project.title}', PID: #{pid}" - to_project.update_from_blueprint(blueprint) + ca_scripts = to_project.update_from_blueprint(blueprint, update_preference: params.update_preference, execute_ca_scripts: false) + entry[:ca_scripts] = ca_scripts + results << { from: from_project, to: pid, status: 'ok' } + entry end + + info end - # Return results - results + { + results: results, + params: { + synchronize: synchronize + } + } end end end end end