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: false description 'Domain' param :domain, instance_of(Type::StringType), required: false description 'Segments to manage' param :segments, array_of(instance_of(Type::SegmentType)), required: true description 'DataProduct to manage' param :data_product, instance_of(Type::GDDataProductType), required: false description 'Logger' param :gdc_logger, instance_of(Type::GdLogger), required: false description 'Abort on error' param :abort_on_error, instance_of(Type::StringType), required: false description 'Collect synced status' param :collect_synced_status, instance_of(Type::BooleanType), required: false description 'Sync failed list' param :sync_failed_list, instance_of(Type::HashType), required: false end
- RESULT_HEADER =
[ :id, :status, :project_uri, :error, :type ]
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
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/gooddata/lcm/actions/provision_clients.rb', line 53 def call(params) synchronize_projects = [] data_product = params.data_product client = params.gdc_gd_client collect_synced_status = collect_synced_status(params) continue_on_error = continue_on_error(params) domain_name = params.organization || params.domain fail "Either organisation or domain has to be specified in params" unless domain_name domain = client.domain(domain_name) || fail("Invalid domain name specified - #{domain_name}") = nil invalid_client_ids = [] begin results = params.segments.map do |segment| next if sync_failed_segment(segment.segment_id, params) segment_object = domain.segments(segment.segment_id, data_product) tmp = segment_object.provision_client_projects.map do |m| Hash[m.each_pair.to_a].merge(type: :provision_result) end unless tmp.empty? synchronize_project = { segment_id: segment.segment_id, from: segment.development_pid, to: tmp.map do |entry| unless entry[:project_uri] = "There was error during provisioning clients: #{entry[:error]}" unless invalid_client_ids << entry[:id] if collect_synced_status = "Failed to provision client #{entry[:id]} in segment #{segment.segment_id}. Error: #{entry[:error]}" add_failed_client(entry[:id], , short_name, params) end next end project_id = entry[:project_uri].split('/').last if collect_synced_status && entry[:status] == 'CREATED' && entry[:id] # Update project client mappings when there are create new clients during provision clients of the segment add_new_clients_to_project_client_mapping(project_id, entry[:id], segment.segment_id, params) end { pid: project_id, client_id: entry[:id] } end.compact } synchronize_projects << synchronize_project unless synchronize_project[:to].empty? end if params.gdc_logger.debug "#{}. Purge all invalid clients now ..." deleted_client_ids = [] segment_object.clients.map do |segment_client| project = segment_client.project if (project.nil? || project.deleted?) client_id = segment_client.client_id if invalid_client_ids.include?(client_id) segment_client.delete deleted_client_ids << client_id end end end params.gdc_logger.debug "Deleted clients: #{deleted_client_ids.join(', ')}" unless ['TooManyProjectsCreatedException'] || ['Max number registered projects'] raise unless continue_on_error next end break tmp end tmp end rescue => e params.gdc_logger.error "Problem occurs when provisioning clients. Error: #{e}" raise e unless continue_on_error end results.flatten! if results # Return results { results: results, params: { synchronize: synchronize_projects } } end |