Class: GoodData::LCM2::ProvisionClients
- Inherits:
-
BaseAction
- Object
- BaseAction
- GoodData::LCM2::ProvisionClients
- Defined in:
- lib/gooddata/lcm/actions/provision_clients.rb
Constant Summary collapse
- DESCRIPTION =
'Provisions LCM Clients'- PARAMS =
define_params(self) do description 'Client Used for Connecting to GD' param :gdc_gd_client, instance_of(Type::GdClientType), required: true description 'Organization Name' param :organization, instance_of(Type::StringType), required: true description 'Segments to manage' param :segments, array_of(instance_of(Type::SegmentType)), required: true end
- RESULT_HEADER =
[ :id, :status, :project_uri, :error, :type ]
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
34 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 |
# File 'lib/gooddata/lcm/actions/provision_clients.rb', line 34 def call(params) # Check if all required parameters were passed BaseAction.check_params(PARAMS, params) client = params.gdc_gd_client domain_name = params.organization || params.domain domain = client.domain(domain_name) || fail("Invalid domain name specified - #{domain_name}") synchronize_projects = [] results = params.segments.map do |segment| tmp = domain.provision_client_projects(segment.segment_id).map do |m| Hash[m.each_pair.to_a].merge(type: :provision_result) end unless tmp.empty? synchronize_projects << { segment_id: segment.segment_id, from: segment.development_pid, to: tmp.map do |entry| { pid: entry[:project_uri].split('/').last, client_id: entry[:id] } end } end tmp end results.flatten! # Return results { results: results, params: { synchronize: synchronize_projects } } end |