Class: GoodData::LCM2::CollectSegmentClients
- Inherits:
-
BaseAction
- Object
- BaseAction
- GoodData::LCM2::CollectSegmentClients
- Defined in:
- lib/gooddata/lcm/actions/collect_segment_clients.rb
Constant Summary collapse
- DESCRIPTION =
'Collect Clients'
- PARAMS =
define_params(self) do description 'Client Used for Connecting to GD' param :gdc_gd_client, instance_of(Type::GdClientType), required: true description 'ADS Client' param :ads_client, instance_of(Type::AdsClientType), required: false description 'Segments to manage' param :segments, array_of(instance_of(Type::SegmentType)), required: true description 'Table Name' param :release_table_name, instance_of(Type::StringType), required: false description 'DataProduct' param :data_product, instance_of(Type::GDDataProductType), required: false description 'Organization Name' param :organization, instance_of(Type::StringType), required: false description 'Domain' param :domain, instance_of(Type::StringType), required: false end
- RESULT_HEADER =
[ :from_name, :from_pid, :to_name, :to_pid ]
Constants included from Dsl::Dsl
Dsl::Dsl::DEFAULT_OPTS, Dsl::Dsl::TYPES
Class Method Summary collapse
Methods inherited from BaseAction
Methods included from Dsl::Dsl
#define_params, #define_type, #process
Class Method Details
.call(params) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/gooddata/lcm/actions/collect_segment_clients.rb', line 45 def call(params) client = params.gdc_gd_client results = [] synchronize_clients = params[:segments].map do |segment_hash| segment = segment_hash[:segment] segment_clients = segment.clients missing_project_clients = segment_clients.reject(&:project?).map(&:client_id) raise "Client(s) missing workspace: #{missing_project_clients.join(', ')}. Please make sure all clients have workspace." unless missing_project_clients.empty? domain_name = params.organization || params.domain fail "Either organisation or domain has to be specified in params" unless domain_name client.domain(domain_name) || fail("Invalid domain name specified - #{domain_name}") if params.ads_client latest_master = GoodData::LCM2::Helpers.latest_master_project_from_ads( params.release_table_name, params.ads_client, segment.segment_id ) else data_product = params.data_product data_product_id = data_product.data_product_id latest_master = GoodData::LCM2::Helpers.latest_master_project_from_nfs(domain_name, data_product_id, segment.segment_id) end raise 'Release table has no data' unless latest_master latest_master = client.projects(latest_master[:master_project_id]) # TODO: Check res.first.nil? || res.first[:master_project_id].nil? master_pid = latest_master.pid master_name = latest_master.title previous_master = segment_hash[:segment_master] if segment_hash[:segment_master] && segment_hash[:segment_master].pid != latest_master.pid sync_info = { segment_id: segment.segment_id, from: master_pid, previous_master: previous_master, to: segment_clients.map do |segment_client| client_project = segment_client.project to_pid = client_project.pid results << { from_name: master_name, from_pid: master_pid, to_name: client_project.title, to_pid: to_pid, previous_master: previous_master } { pid: to_pid, client_id: segment_client.client_id } end } sync_info end results.flatten! # Return results { results: results, params: { synchronize: synchronize_clients } } end |