Class: GoodData::LCM2::CollectSegments
- Inherits:
-
BaseAction
- Object
- BaseAction
- GoodData::LCM2::CollectSegments
- Defined in:
- lib/gooddata/lcm/actions/collect_segments.rb
Constant Summary collapse
- DESCRIPTION =
'Collect Segments from API'
- PARAMS =
define_params(self) do description 'Segments to provision' param :segments_filter, array_of(instance_of(Type::StringType)), required: false description 'DataProduct' param :data_product, instance_of(Type::GDDataProductType), required: false description 'Logger' param :gdc_logger, instance_of(Type::GdLogger), required: true end
- RESULT_HEADER =
[ :segment_id, :development_pid, :driver, :master_name, :uri ]
Constants inherited from BaseAction
BaseAction::FAILED_CLIENTS, BaseAction::FAILED_PROJECTS, BaseAction::FAILED_SEGMENTS, BaseAction::SYNC_FAILED_LIST
Constants included from Dsl::Dsl
Dsl::Dsl::DEFAULT_OPTS, Dsl::Dsl::TYPES
Class Method Summary collapse
Methods inherited from BaseAction
add_failed_client, add_failed_project, add_failed_segment, add_new_clients_to_project_client_mapping, check_params, collect_synced_status, continue_on_error, print_result, process_failed_project, process_failed_projects, sync_failed_client, sync_failed_project, sync_failed_segment, without_check
Methods included from Dsl::Dsl
#define_params, #define_type, #process
Class Method Details
.call(params) ⇒ Object
35 36 37 38 39 40 41 42 43 44 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 |
# File 'lib/gooddata/lcm/actions/collect_segments.rb', line 35 def call(params) data_product = params.data_product data_product_segments = data_product.segments segment_names = data_product_segments.map(&:segment_id) params.gdc_logger.debug("Domain segments: #{segment_names}") if params.segments_filter params.gdc_logger.info("Segments filter: #{params.segments_filter}") data_product_segments.select! do |segment| params.segments_filter.include?(segment.segment_id) end end segments = data_product_segments.pmap do |segment| project = nil begin project = segment.master_project rescue RestClient::BadRequest => e raise "Failed to retrieve master project for segment #{segment.id}. Error: #{e}" end raise "Master project for segment #{segment.id} doesn't exist." unless project { segment_id: segment.segment_id, segment: segment, development_pid: project.pid, driver: project.driver.downcase, master_name: project.title, segment_master: project, uri: segment.uri } end segments.compact! # Return results { results: segments, params: { segments: segments } } end |